Merged with cleanup

clean_emacs
TuDatTr 2020-05-22 03:08:12 +02:00
commit 87bfeb8da7
18 changed files with 852 additions and 3128 deletions

6
.gitmodules vendored
View File

@ -1,6 +0,0 @@
[submodule "vim/.vim/pack/plugins/start/vim-go"]
path = vim/.vim/pack/plugins/start/vim-go
url = https://github.com/fatih/vim-go/
[submodule "vim/.vim/plugin/vim/.vim/plugged/vim-polyglot"]
path = vim/.vim/plugin/vim/.vim/plugged/vim-polyglot
url = https://github.com/sheerun/vim-polyglot

View File

@ -13,7 +13,21 @@ Main tools I am currently using are:
## Getting started ## Getting started
Todo (along with cleanup) To make full use of the dotfiles we need to install the following packages via pacman:
`pacman -Syu zsh gvim byobu conky firefox rxvt-unicode dunst highlight i3-gaps neofetch ranger rofi`
And the following packages from the AUR:
`yay -S cava polybar`
### zsh setup
```sh
chsh -s /bin/zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
cp -r /usr/share/zsh-theme-powerlevel9k $HOME/.oh-my-zsh/themes/powerlevel9k
rm -rf $HOME/.*bash* # optional, but removes all bash related stuff from the home directory
```
### Font setup ### Font setup
@ -42,4 +56,4 @@ stow config
## License ## License
This project is license under the GPL-3.0 License - see LICENSE file for details. This project is licensed under the GPL-3.0 License - see LICENSE file for details.

View File

@ -1,100 +0,0 @@
* dotfiles ┐【 ̄~ ̄】┌
These are my personal dotfiles.
I'm using:
- [[https://www.gnu.org/software/emacs/][GNU Emacs]]
- [[https://www.gnu.org/software/stow][GNU stow]]
- [[https://github.com/Airblader/i3][i3-gaps]]
- [[https://github.com/jaagr/polybar][Polybar]]
- [[https://github.com/nana-4/materia-theme][Materia Theme]]
- [[http://zsh.sourceforge.net][zsh]]
** TODOS:
1) Making an own [[https://github.com/brndnmtthws/conky/wiki/Configuraion-Settings][conky]], conky_maia-like
** Getting Started
*** Prerequisites
**** Pacman Install
***** System
- lightdm
****** Terminal
- zsh
- termite
***** Essentials
- nyancat
- stow
- git
- python-pip
- xsel
- rofi
***** Lifestyle
- emacs
- texlive-most
- evince
- scrot
- aspell-en
***** Pretty stuff (i.e. ricing, pretty cli-apps)
- cmus
- lxappearance
- conky
- arc-icon-theme
****** oh-my-zsh
- powerline-fonts
- awesome-terminal-fonts
- zsh-theme-powerlevel9k
**** Yaourt Install
***** System
- lightdm-mini-greeter
- i3-gaps (Moved into the official Arch community repo)
- i3lock-color
***** Essentials
- polybar
***** Pretty stuff (i.e. ricing, pretty cli-apps)
- cava
- materia-theme
- neofetch
*** Setting up zsh
#+BEGIN_SRC sh
chsh -s /bin/zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" # Downloading/Installing oh-my-zsh
cp -r /usr/share/zsh-theme-powerlevel9k ~/.oh-my-zsh/themes/powerlevel9k # copying powerlevel9k-theme to the desired directory
rm -rf ~/.*bash* # remove bash related files from your home directory.. don't do it if you wanna keep using bash with this user
#+END_SRC
*** Setting up Emacs
I tried to make this as easy as possible. All packages should be installed automatically.
Config file is =.emacs.d/config.org=
*** Font setup
Stolen from [[https://github.com/powerline/fonts][here]].
#+BEGIN_SRC sh
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts
#+END_SRC
*** "Installing" the dotfiles.
Take a look at already existing files and delete them if necessary.
#+BEGIN_SRC sh
git clone https://github.com/TuDatTr/dotfiles .dotfiles && cd .dotfiles
stow emacs
stow zsh
stow config
sudo ln -s ~/.scripts/pipes.sh /usr/local/bin/pipes
#+END_SRC
* Author
- Tuan-Dat Tran - [[https://github.com/tudattr/][TuDatTr]]
* License
This project is license under the GPL-3.0 License - see LICENSE file for details.
* Acknowledgements
- [[https://www.reddit.com/r/unixporn/][unixporn - the home for *NIX customisation!]]
- [[https://uigradients.com][uiGradients - Beautiful colored gradients]]
- [[http://terminal.sexy/][terminal.sexy - Terminal Color Scheme Designer]]

View File

@ -24,3 +24,42 @@ urxvt*blurRadius: 15
! Xft ! Xft
Xft.dpi: 92 Xft.dpi: 92
Xft.antialias: 1 Xft.antialias: 1
! Color
*.foreground: #98abb2
*.background: #181b28
*.cursorColor: #ffffff
! black
*.color0: #161925
*.color8: #0c0e14
! red
*.color1: #e84f4f
*.color9: #d23d3d
! green
*.color2: #00ffaf
*.color10: #237885
! yellow
*.color3: #ffbb24
*.color11: #f8ec09
! blue
*.color4: #007fff
*.color12: #00c4ff
! magenta
*.color5: #8c00fd
*.color13: #cd00df
! cyan
*.color6: #00e8b7
*.color14: #00d3a7
! white
*.color7: #98abb2
*.color15: #c0bfbc

View File

@ -1,36 +0,0 @@
! Color
*.foreground: #98abb2
*.background: #181b28
*.cursorColor: #ffffff
! black
*.color0: #161925
*.color8: #0c0e14
! red
*.color1: #e84f4f
*.color9: #d23d3d
! green
*.color2: #00ffaf
*.color10: #237885
! yellow
*.color3: #ffbb24
*.color11: #f8ec09
! blue
*.color4: #007fff
*.color12: #00c4ff
! magenta
*.color5: #8c00fd
*.color13: #cd00df
! cyan
*.color6: #00e8b7
*.color14: #00d3a7
! white
*.color7: #98abb2
*.color15: #c0bfbc

View File

@ -1,48 +0,0 @@
from __future__ import (absolute_import, division, print_function)
import os
from ranger.api.commands import Command
class my_edit(Command):
# The so-called doc-string of the class will be visible in the built-in
# help that is accessible by typing "?c" inside ranger.
""":my_edit <filename>
A sample command for demonstration purposes that opens a file in an editor.
"""
# The execute method is called when you run this command in ranger.
def execute(self):
# self.arg(1) is the first (space-separated) argument to the function.
# This way you can write ":my_edit somefilename<ENTER>".
if self.arg(1):
# self.rest(1) contains self.arg(1) and everything that follows
target_filename = self.rest(1)
else:
# self.fm is a ranger.core.filemanager.FileManager object and gives
# you access to internals of ranger.
# self.fm.thisfile is a ranger.container.file.File object and is a
# reference to the currently selected file.
target_filename = self.fm.thisfile.path
# This is a generic function to print text in ranger.
self.fm.notify("Let's edit the file " + target_filename + "!")
# Using bad=True in fm.notify allows you to print error messages:
if not os.path.exists(target_filename):
self.fm.notify("The given file does not exist!", bad=True)
return
# This executes a function from ranger.core.acitons, a module with a
# variety of subroutines that can help you construct commands.
# Check out the source, or run "pydoc ranger.core.actions" for a list.
self.fm.edit_file(target_filename)
# The tab method is called when you press tab, and should return a list of
# suggestions that the user will tab through.
# tabnum is 1 for <TAB> and -1 for <S-TAB> by default
def tab(self, tabnum):
# This is a generic tab-completion function that iterates through the
# content of the current directory.
return self._tab_directory_content()

File diff suppressed because it is too large Load Diff

View File

@ -1,216 +0,0 @@
#!/usr/bin/env bash
set -o noclobber -o noglob -o nounset -o pipefail
IFS=$'\n'
# If the option `use_preview_script` is set to `true`,
# then this script will be called and its output will be displayed in ranger.
# ANSI color codes are supported.
# STDIN is disabled, so interactive scripts won't work properly
# This script is considered a configuration file and must be updated manually.
# It will be left untouched if you upgrade ranger.
# Meanings of exit codes:
# code | meaning | action of ranger
# -----+------------+-------------------------------------------
# 0 | success | Display stdout as preview
# 1 | no preview | Display no preview at all
# 2 | plain text | Display the plain content of the file
# 3 | fix width | Don't reload when width changes
# 4 | fix height | Don't reload when height changes
# 5 | fix both | Don't ever reload
# 6 | image | Display the image `$IMAGE_CACHE_PATH` points to as an image preview
# 7 | image | Display the file directly as an image
# Script arguments
FILE_PATH="${1}" # Full path of the highlighted file
PV_WIDTH="${2}" # Width of the preview pane (number of fitting characters)
PV_HEIGHT="${3}" # Height of the preview pane (number of fitting characters)
IMAGE_CACHE_PATH="${4}" # Full path that should be used to cache image preview
PV_IMAGE_ENABLED="${5}" # 'True' if image previews are enabled, 'False' otherwise.
FILE_EXTENSION="${FILE_PATH##*.}"
FILE_EXTENSION_LOWER=$(echo ${FILE_EXTENSION} | tr '[:upper:]' '[:lower:]')
# Settings
HIGHLIGHT_SIZE_MAX=262143 # 256KiB
HIGHLIGHT_TABWIDTH=8
HIGHLIGHT_STYLE='pablo'
PYGMENTIZE_STYLE='autumn'
handle_extension() {
case "${FILE_EXTENSION_LOWER}" in
# Archive
a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
atool --list -- "${FILE_PATH}" && exit 5
bsdtar --list --file "${FILE_PATH}" && exit 5
exit 1;;
rar)
# Avoid password prompt by providing empty password
unrar lt -p- -- "${FILE_PATH}" && exit 5
exit 1;;
7z)
# Avoid password prompt by providing empty password
7z l -p -- "${FILE_PATH}" && exit 5
exit 1;;
# PDF
pdf)
# Preview as text conversion
pdftotext -l 10 -nopgbrk -q -- "${FILE_PATH}" - | fmt -w ${PV_WIDTH} && exit 5
mutool draw -F txt -i -- "${FILE_PATH}" 1-10 | fmt -w ${PV_WIDTH} && exit 5
exiftool "${FILE_PATH}" && exit 5
exit 1;;
# BitTorrent
torrent)
transmission-show -- "${FILE_PATH}" && exit 5
exit 1;;
# OpenDocument
odt|ods|odp|sxw)
# Preview as text conversion
odt2txt "${FILE_PATH}" && exit 5
exit 1;;
# HTML
htm|html|xhtml)
# Preview as text conversion
w3m -dump "${FILE_PATH}" && exit 5
lynx -dump -- "${FILE_PATH}" && exit 5
elinks -dump "${FILE_PATH}" && exit 5
;; # Continue with next handler on failure
esac
}
handle_image() {
local mimetype="${1}"
case "${mimetype}" in
# SVG
# image/svg+xml)
# convert "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6
# exit 1;;
# Image
image/*)
local orientation
orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}" )"
# If orientation data is present and the image actually
# needs rotating ("1" means no rotation)...
if [[ -n "$orientation" && "$orientation" != 1 ]]; then
# ...auto-rotate the image according to the EXIF data.
convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6
fi
# `w3mimgdisplay` will be called for all images (unless overriden as above),
# but might fail for unsupported types.
exit 7;;
# Video
# video/*)
# # Thumbnail
# ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6
# exit 1;;
# PDF
# application/pdf)
# pdftoppm -f 1 -l 1 \
# -scale-to-x 1920 \
# -scale-to-y -1 \
# -singlefile \
# -jpeg -tiffcompression jpeg \
# -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \
# && exit 6 || exit 1;;
# Preview archives using the first image inside.
# (Very useful for comic book collections for example.)
# application/zip|application/x-rar|application/x-7z-compressed|\
# application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar)
# local fn=""; local fe=""
# local zip=""; local rar=""; local tar=""; local bsd=""
# case "${mimetype}" in
# application/zip) zip=1 ;;
# application/x-rar) rar=1 ;;
# application/x-7z-compressed) ;;
# *) tar=1 ;;
# esac
# { [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}"); } || \
# { fn=$(bsdtar --list --file "${FILE_PATH}") && bsd=1 && tar=""; } || \
# { [ "$rar" ] && fn=$(unrar lb -p- -- "${FILE_PATH}"); } || \
# { [ "$zip" ] && fn=$(zipinfo -1 -- "${FILE_PATH}"); } || return
#
# fn=$(echo "$fn" | python -c "import sys; import mimetypes as m; \
# [ print(l, end='') for l in sys.stdin if \
# (m.guess_type(l[:-1])[0] or '').startswith('image/') ]" |\
# sort -V | head -n 1)
# [ "$fn" = "" ] && return
# [ "$bsd" ] && fn=$(printf '%b' "$fn")
#
# [ "$tar" ] && tar --extract --to-stdout \
# --file "${FILE_PATH}" -- "$fn" > "${IMAGE_CACHE_PATH}" && exit 6
# fe=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g')
# [ "$bsd" ] && bsdtar --extract --to-stdout \
# --file "${FILE_PATH}" -- "$fe" > "${IMAGE_CACHE_PATH}" && exit 6
# [ "$bsd" ] || [ "$tar" ] && rm -- "${IMAGE_CACHE_PATH}"
# [ "$rar" ] && unrar p -p- -inul -- "${FILE_PATH}" "$fn" > \
# "${IMAGE_CACHE_PATH}" && exit 6
# [ "$zip" ] && unzip -pP "" -- "${FILE_PATH}" "$fe" > \
# "${IMAGE_CACHE_PATH}" && exit 6
# [ "$rar" ] || [ "$zip" ] && rm -- "${IMAGE_CACHE_PATH}"
# ;;
esac
}
handle_mime() {
local mimetype="${1}"
case "${mimetype}" in
# Text
text/* | */xml)
# Syntax highlight
if [[ "$( stat --printf='%s' -- "${FILE_PATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then
exit 2
fi
if [[ "$( tput colors )" -ge 256 ]]; then
local pygmentize_format='terminal256'
local highlight_format='xterm256'
else
local pygmentize_format='terminal'
local highlight_format='ansi'
fi
highlight --replace-tabs="${HIGHLIGHT_TABWIDTH}" --out-format="${highlight_format}" \
--style="${HIGHLIGHT_STYLE}" --force -- "${FILE_PATH}" && exit 5
# pygmentize -f "${pygmentize_format}" -O "style=${PYGMENTIZE_STYLE}" -- "${FILE_PATH}" && exit 5
exit 2;;
# Image
image/*)
# Preview as text conversion
# img2txt --gamma=0.6 --width="${PV_WIDTH}" -- "${FILE_PATH}" && exit 4
exiftool "${FILE_PATH}" && exit 5
exit 1;;
# Video and audio
video/* | audio/*)
mediainfo "${FILE_PATH}" && exit 5
exiftool "${FILE_PATH}" && exit 5
exit 1;;
esac
}
handle_fallback() {
echo '----- File Type Classification -----' && file --dereference --brief -- "${FILE_PATH}" && exit 5
exit 1
}
MIMETYPE="$( file --dereference --brief --mime-type -- "${FILE_PATH}" )"
if [[ "${PV_IMAGE_ENABLED}" == 'True' ]]; then
handle_image "${MIMETYPE}"
fi
handle_extension
handle_mime "${MIMETYPE}"
handle_fallback
exit 1

View File

@ -1 +0,0 @@
file:///home/tuan/.nextcloud/

View File

@ -1,18 +0,0 @@
# DO NOT EDIT! This file will be overwritten by LXAppearance.
# Any customization should be done in ~/.gtkrc-2.0.mine instead.
include "/home/tuan/.gtkrc-2.0.mine"
gtk-theme-name="Sweet"
gtk-icon-theme-name="Arc"
gtk-font-name="Hack Nerd Font Mono Regular 9"
gtk-cursor-theme-name="Adwaita"
gtk-cursor-theme-size=0
gtk-toolbar-style=GTK_TOOLBAR_ICONS
gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
gtk-button-images=0
gtk-menu-images=0
gtk-enable-event-sounds=1
gtk-enable-input-feedback-sounds=1
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle="hintmedium"

View File

@ -9,5 +9,5 @@ t:/home/tuan/Templates
w:/home/tuan/workspace_l/Projects w:/home/tuan/workspace_l/Projects
k:/home/tuan/Documents/CTF/TryHackMe/VulnUniversity k:/home/tuan/Documents/CTF/TryHackMe/VulnUniversity
q:/home/tuan/.nextcloud/Quick Drop q:/home/tuan/.nextcloud/Quick Drop
':/home/tuan/.dotfiles/config/.config/ranger ':/home/tuan/.local/share/ranger
e:/home/tuan/Documents/CTF/TryHackMe/Ice/2_Recon e:/home/tuan/Documents/CTF/TryHackMe/Ice/2_Recon

View File

@ -191,4 +191,4 @@ if __name__ == '__main__':
screenshot() screenshot()
pixelate() pixelate()
lock() lock()
log(start_time) # log(start_time)

View File

@ -1,93 +0,0 @@
/* ______ _________ _______ _______ _ _______ _________ _______ _______ _______
* ( __ \ \__ __/( ____ \( ____ \( \ ( ___ )\__ __/( )( ____ \( ____ )
* | ( \ ) ) ( | ( \/| ( \/| ( | ( ) | ) ( | () () || ( \/| ( )|
* | | ) | | | | (_____ | | | | | (___) | | | | || || || (__ | (____)|
* | | | | | | (_____ )| | | | | ___ | | | | |(_)| || __) | __)
* | | ) | | | ) || | | | | ( ) | | | | | | || ( | (\ (
* | (__/ )___) (___/\____) || (____/\| (____/\| ) ( |___) (___| ) ( || (____/\| ) \ \__
* (______/ \_______/\_______)(_______/(_______/|/ \|\_______/|/ \|(_______/|/ \__/
*
*
* THIS IS GARBAGE CODE AND I KNOW IT.
* I KNOW ABSOLUTLY NOTHING ABOUT C++ AND JUST FRANKENSTEINED
* A BUNCH OF CODE SAMPLES, USING MY PYTHON CODE AS A TEMPLATE.
*/
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
#include <dirent.h>
#include <errno.h>
#include <vector>
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
int getdir(string dir, vector<string> &files){
DIR *dp;
struct dirent *dirp;
if((dp = opendir(dir.c_str())) == NULL){
cout << "Error(" << errno << ") opening " << dir << endl;
return errno;
}
while ((dirp = readdir(dp)) != NULL){
files.push_back(string(dirp->d_name));
}
closedir(dp);
return 0;
}
string getfile(string file_path){
ifstream inFile;
string file_content;
inFile.open(file_path);
if(!inFile){
return "";
}
inFile >> file_content;
return file_content;
}
bool spotify_running(){
string dir = string("/proc/");
vector<string> processes = vector<string>();
getdir(dir, processes);
string proc_name = string("");
for (unsigned int i = 0; i < procs.size(); i++){
proc_name = dir + procs[i] + "/cmdline";
if(getfile(proc_name).find(string("/usr/bin/spotify")) != string::npos){
return true;
}
}
return false;
}
int main(){
//
struct passwd *pw = getpwuid(getuid());
const char *homedir = pw->pw_dir;
int state = -1;
int playstate = 0;
string playstate_file = "";
playstate_file += homedir + string("/.scripts/playstate");
while (spotify_running()){
usleep(100000);
// cout << spotify_running() << endl;
playstate = stoi(getfile(playstate_file));
if(playstate != state){
state = playstate;
if (state == 0){
cout << "" << endl;
system("playerctl pause");
}
else if (state == 1){
cout << "" << endl;
system("playerctl play");
}
}
}
cout << endl;
}

Binary file not shown.

View File

@ -1,47 +0,0 @@
#!/usr/bin/python
import subprocess
import time
import os
def find_proc(proc_name):
this_proc = "pythonspotify-play.py"
proc_path = '/proc'
proc = next(os.walk('{}/'.format(proc_path)))[1]
for process in proc:
cmdline_path = '{}/{}/cmdline'.format(proc_path,process)
try:
with open(cmdline_path, 'r') as cmd:
proc_content = cmd.readline()
if (proc_name in proc_content):
return True
except FileNotFoundError:
pass
return False
def spotify_running():
return find_proc('/usr/bin/spotify')
def main():
state = -1
home = os.path.expanduser("~")
while spotify_running():
with open(home + '/.scripts/playstate', 'r') as f:
try:
file_state = int(f.readline().strip('\n'))
except ValueError:
pass
if state != file_state:
state = file_state
if state == 0:
print("")
subprocess.run(["playerctl","pause"])
elif state == 1:
print("")
subprocess.run(["playerctl","play"])
time.sleep(0.1)
if __name__ == '__main__':
main()

View File

@ -1 +0,0 @@
Colorizer.vmb: call delete('/home/tuan/.vim/plugin/ColorizerPlugin.vim')|call delete('/home/tuan/.vim/doc/Colorizer.txt')|call delete('/home/tuan/.vim/autoload/Colorizer.vim')

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +0,0 @@
#
**Category:**
**Points:**
## Challenge
>
## Solution
### Flag
``