Initial Commit

This commit is contained in:
koumakpet 2020-02-29 22:11:42 +01:00
commit e456ebf6ae
12 changed files with 895 additions and 0 deletions

94
files/.config/sh/.aliases Executable file
View file

@ -0,0 +1,94 @@
#!/usr/bin/env bash
# enable color support
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias cgrep='grep --color=always'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# Exa aliases (replacement for ls, if you are using ls, comment or change this
alias ls='exa'
alias ll='exa -glah'
alias ld='exa -glahD'
alias lt='exa -Tlagh'
alias tree='exa -T'
# Shortcuts
alias vi='vim'
alias rr='rm -r'
alias mnt='mount'
# Changing directories
alias ..='cd ..'
alias ...='cd ../../'
alias ....='cd ../../../'
alias .....='cd ../../../../'
alias .2='cd ../../'
alias .3='cd ../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../../'
# Reconfigure default py to py3
alias py3='python3'
alias py='python3'
alias py2='python2'
# Config access shortcuts
alias cfvim='vim ~/.vimrc'
alias cfzsh='vim ~/config/zsh/.zsh_config'
alias cfzshrc='vim ~/.zshrc'
# Replacements
alias dd='dcfldd' # Use dcfldd instead of dd (shows progress)
alias du='du -ach | sort -h' # Sort du by size
alias mkdir='mkdir -p' # Mkdir with automatic creation of parent directories
alias ps='ps auxf' # Print all processes
alias tty-clock='tty-clock -Ssc' # Terminal clock screensaver
# Custom aliases
alias fhere='find . -name' # Find file/dir from currrent dir
alias ssh-list='ss | grep ssh' # List all SSH connections
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias psg='\ps aux | grep -v grep | grep -i -e VSZ -e' # Get searchable process with nice output
alias ip-show="dig +short myip.opendns.com @resolver1.opendns.com" # Gets your IP address
alias reload="exec \$SHELL" # Reload the shell (i.e. invoke as a login shell
alias path='echo -e ${PATH//:/\\n}' # Print each PATH entry on a separate line
alias dotfiles='exa -hula -d .[a-z]* | grep -v ^d' # Show all dotfiles
alias dotdirs='exa -hulaD -d .[a-z]*' # Show all dotdirs
alias dotall='exa -hula -d .[a-z]*' # Show both dotdirs and dotfiles
alias clean='rm -rf ~/.local/share/Trash/* && rm -rf ~/Downloads/*' # Remove trash and downloads files
alias colors-256='curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash' # Show color table
alias minecraft='minecraft-launcher'
alias o='dolphin .' # open in dolphin (file manager)
alias pacman-extract='pacman -Syw --cachedir .' # Extract package/es into current floders
alias mount-table='df' # Show list of all mounted devices and their mount locations
alias swapout='sudo swapoff -a; sudo swapon -a' # Reset swap (move everything to RAM)
alias sound_control='alsamixer' # Sound control tool in alsa_utils package
# If user is not root, pass all commands via sudo
if [ $UID -ne 0 ]; then
# Enable aliases to be sudoed
## Uncomment if you are using autocompletion (is ZSH)
#alias sudo='nocorrect sudo'
## Comment this if you are not using autocompletion (in ZSH)
alias sudo='sudo '
alias unsudo='sudo -k' # Reset sudo timeout (sudo will require password)
fi
# Functions
if [ -f ~/.config/sh/.functions ]; then
source ~/.config/sh/.functions
fi

237
files/.config/sh/.functions Executable file
View file

@ -0,0 +1,237 @@
#!/usr/bin/env bash
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
return 1
else
for n in $@
do
if [ -f "$n" ] ; then
case "${n%,}" in
*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
tar xvf "$n" ;;
*.lzma) unlzma ./"$n" ;;
*.bz2) bunzip2 ./"$n" ;;
*.rar) unrar x -ad ./"$n" ;;
*.gz) gunzip ./"$n" ;;
*.zip) unzip ./"$n" ;;
*.z) uncompress ./"$n" ;;
*.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar)
7z x ./"$n" ;;
*.xz) unxz ./"$n" ;;
*.exe) cabextract ./"$n" ;;
*)
echo "extract: '$n' - unknown archive method"
return 1
;;
esac
else
echo "'$n' - file does not exist"
return 1
fi
done
fi
}
# Hide any file / directory in ls using .hidden file
#function ls () {
# if [ -f .hidden ]; then
# declare GLOBIGNORE="$GLOBIGNORE:.*:$(tr '\n' ':' < .hidden)"
# ls "$@"
# fi
#}
# Create a new directory and enter it
function mkd() {
mkdir -p "$@" && cd "$_";
}
# Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression
function targz() {
local tmpFile="${@%/}.tar";
tar -cvf "${tmpFile}" "${@}" || return 1;
size=$(
stat -f"%z" "${tmpFile}" 2> /dev/null; # macOS `stat`
stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat`
);
local cmd="";
if (( size < 52428800 )) && hash zopfli 2> /dev/null; then
# the .tar file is smaller than 50 MB and Zopfli is available; use it
cmd="zopfli";
else
if hash pigz 2> /dev/null; then
cmd="pigz";
else
cmd="gzip";
fi;
fi;
echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`…";
"${cmd}" -v "${tmpFile}" || return 1;
[ -f "${tmpFile}" ] && rm "${tmpFile}";
zippedSize=$(
stat -f"%z" "${tmpFile}.gz" 2> /dev/null; # macOS `stat`
stat -c"%s" "${tmpFile}.gz" 2> /dev/null; # GNU `stat`
);
echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully.";
}
# Determine size of a file or total size of a directory
function dir-size() {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh;
else
local arg=-sh;
fi
if [[ -n "$@" ]]; then
\du $arg -- "$@";
else
\du $arg .[^.]* ./*;
fi;
}
# Use Gits colored diff when available
hash git &>/dev/null;
if [ $? -eq 0 ]; then
function diff() {
git diff --no-index --color-words "$@";
}
fi;
# Create a data URL from a file
function dataurl() {
local mimeType=$(file -b --mime-type "$1");
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8";
fi
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')";
}
# Start an HTTP server from a directory, optionally specifying the port
function server() {
local port="${1:-8000}";
sleep 1 && open "http://localhost:${port}/" &
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesnt break anything for binary files)
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port";
}
# Start a PHP server from a directory, optionally specifying the port
# (Requires PHP 5.4.0+.)
function phpserver() {
local port="${1:-4000}";
local ip=$(ipconfig getifaddr en1);
sleep 1 && open "http://${ip}:${port}/" &
php -S "${ip}:${port}";
}
# Compare original and gzipped file size
function gz() {
local origsize=$(wc -c < "$1");
local gzipsize=$(gzip -c "$1" | wc -c);
local ratio=$(echo "$gzipsize * 100 / $origsize" | bc -l);
printf "orig: %d bytes\n" "$origsize";
printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
}
# Run `dig` and display the most useful info
function digga() {
dig +nocmd "$1" any +multiline +noall +answer;
}
# Show all the names (CNs and SANs) listed in the SSL certificate
# for a given domain
function getcertnames() {
if [ -z "${1}" ]; then
echo "ERROR: No domain specified.";
return 1;
fi;
local domain="${1}";
echo "Testing ${domain}…";
echo ""; # newline
local tmp=$(echo -e "GET / HTTP/1.0\nEOT" \
| openssl s_client -connect "${domain}:443" -servername "${domain}" 2>&1);
if [[ "${tmp}" = *"-----BEGIN CERTIFICATE-----"* ]]; then
local certText=$(echo "${tmp}" \
| openssl x509 -text -certopt "no_aux, no_header, no_issuer, no_pubkey, \
no_serial, no_sigdump, no_signame, no_validity, no_version");
echo "Common Name:";
echo ""; # newline
echo "${certText}" | grep "Subject:" | sed -e "s/^.*CN=//" | sed -e "s/\/emailAddress=.*//";
echo ""; # newline
echo "Subject Alternative Name(s):";
echo ""; # newline
echo "${certText}" | grep -A 1 "Subject Alternative Name:" \
| sed -e "2s/DNS://g" -e "s/ //g" | tr "," "\n" | tail -n +2;
return 0;
else
echo "ERROR: Certificate not found.";
return 1;
fi;
}
# Normalize `open` across Linux, macOS, and Windows.
# This is needed to make the `o` function (see below) cross-platform.
if [ ! $(uname -s) = 'Darwin' ]; then
if grep -q Microsoft /proc/version; then
# Ubuntu on Windows using the Linux subsystem
alias open='explorer.exe';
else
alias open='xdg-open';
fi
fi
# `o` with no arguments opens the current directory, otherwise opens the given
# location
function o() {
if [ $# -eq 0 ]; then
open .;
else
open "$@";
fi;
}
# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring
# the `.git` directory, listing directories first. The output gets piped into
# `less` with options to preserve color and line numbers, unless the output is
# small enough for one screen.
function tre() {
tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
}
# Will update all git repositories found in current directory and its subdirectories
function update-git-repos() {
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo -e "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
echo "";
echo -e "\033[33m"+$i+"\033[0m";
# We have to go to the .git parent directory to call the pull command
cd "$i";
cd ..;
# finally pull
git pull origin master;
# lets get back to the CUR_DIR
cd $CUR_DIR
done
echo -e "\n\033[32mComplete!\033[0m\n"
}

View file

@ -0,0 +1,19 @@
# Enable colors
autoload -U colors && colors
# Basic auto/tab complete
autoload -U compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
_comp_options+=(globdots)
# Setup aliases
if [ -f ~/.config/sh/.aliases ]; then
source ~/.config/sh/.aliases
fi
# Load zsh-syntax-highlighting (should be last)
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

View file

@ -0,0 +1,17 @@
[global_config]
[keybindings]
[layouts]
[[default]]
[[[child1]]]
parent = window0
profile = default
type = Terminal
[[[window0]]]
parent = ""
type = Window
[plugins]
[profiles]
[[default]]
background_darkness = 0.92
background_type = transparent
cursor_color = "#aaaaaa"

17
files/.gitconfig Executable file
View file

@ -0,0 +1,17 @@
# This is Git's per-user configuration file.
[user]
name = koumakpet
email = koumakpet@protonmail.com
[credential]
helper = store
[alias]
l = log --oneline --decorate --all --graph
lol = log --pretty=oneline --abbrev-commit --graph
lg = log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
[merge]
tool = meld
[mergetool]
keepbackup = false
keeptemporaries = false
[diff]
tool = meld

135
files/.vimrc Executable file
View file

@ -0,0 +1,135 @@
" TODO: Spell Checking
set nocompatible " Disable vi compatibilty (Use vi improved only)
set encoding=utf-8 " Use UTF-8
syntax enable " Turn on syntax highlighting
set showmatch " Show matching brackets
set ignorecase " Do case insensitive matching
set incsearch " Show partial matches for a search phrase
set number " Show numbers
set relativenumber " Show relative numbersi
set undolevels=999 " Lots of these
set hlsearch " Highlight Search
set tabstop=4 " Tab size
set noexpandtab " Do not expand tab into spaces (change to expandtab to use spaces)
set shiftwidth=4 " Indentation size
set softtabstop=4 " Tabs/Spaces interrop
set autoindent " Enable autoindent
set ruler " Show cursor position
set cursorline " Highlight cursor line
set mouse=a " Enable mouse mode
set termguicolors " Enable true colors
set backspace=indent,eol,start " Delete everything
set laststatus=2 " Always show status line
set wildmode=longest,list,full " Enable autocompletion
set splitbelow splitright " Split in more natural way
"set nomodeline " Disable as a security precaution
"set wildmenu " Enable wildmenu
"set conceallevel=0 " Disable concealing
"set complete-=i " Better completion
"set smarttab " Better tabs
"set ttimeout " Set timeout
"set ttimeoutlen=100
"set synmaxcol=500 " Syntax limit
"set scrolloff=3 " Scroll offset
"set sidescrolloff=5
"set autoread " Reload files on change
"set tabpagemax=50 " More tabs
"set history=1000 " More history
"set viminfo^=! " Better viminfo
"set formatoptions+=j " Delete comment character when joining commented lines
"set listchars=tab:,nbsp:_,trail:,extends:>,precedes:<
"set list " Highlight non whitespace characters
"set nrformats-=octal " 007 != 010
"set sessionoptions-=options
"set viewoptions-=option
"set listchars=tab:\|\ " Set tab lines
"set listchars=tab:\|\- " Set tab lines with -
" Always use terminal background
autocmd ColorScheme * highlight! Normal ctermbg=NONE guibg=NONE
" Have Vim jump to the last position when reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\""
endif
" Shortcutting split navigation, saving a keystroke
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Check file in shellcheck
map <leader>s :!clear && shellcheck %<CR>
" Copy selected text to system clipboard (requires gvim)
vnoremap <C-c> "*Y :let @+=@*<CR>
map <C-p> "+P
" Automatically deletes all trailing whitespace on save
autocmd BufWritePre * %s/\s\+$//e
" Vundle Init
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Plugins
Plugin 'VundleVim/Vundle.vim'
Plugin 'airblade/vim-gitgutter' " Shows Git diff
Plugin 'joshdick/onedark.vim' " OneDark Theme
Plugin 'tpope/vim-fugitive' " Git Wrapper (also shows branch on statusline)
Plugin 'vim-airline/vim-airline' " AirLine statusline
Plugin 'vim-airline/vim-airline-themes' " AirLine statusline themes
Plugin 'scrooloose/nerdtree' " Adds File-tree
Plugin 'Xuyuanp/nerdtree-git-plugin' " Shows git status in nerd-tree
Plugin 'vim-syntastic/syntastic' " Syntax checking
Plugin 'PotatoesMaster/i3-vim-syntax' " Add syntax for i3 config
Plugin 'jmcantrell/vim-virtualenv' " Manage Virtual Enviroment
Plugin 'wakatime/vim-wakatime' " Install WakaTime (Shows coding time)
Plugin 'gko/vim-coloresque' " Show color highlight in css/html/less/sass
" Vundle End
call vundle#end()
filetype plugin indent on
" NERD Tree
autocmd StdinReadPre * let s:std_in=1
" Show tree when opening directory
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
" Use Ctrl+n to open tree
map <C-n> :NERDTreeToggle<CR>
" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_checkers = ['flake8']
map <leader>c :SyntasticCheck<CR>
map <leader>z :Errors<CR>
" Airline
let g:airline_theme='onedark'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline_left_sep = "\uE0B0"
let g:airline_right_sep = "\uE0B2"
" One Dark
let g:onedark_color_overrides = {
\ "comment_grey": {"gui": "#69747C","cterm": "245", "cterm16": "8"},
\ "gutter_fg_grey": { "gui": "#69747C", "cterm": "245", "cterm16": "8"}
\}
if !exists('$TMUX')
let g:onedark_terminal_italics = 1
endif
colorscheme onedark

40
files/.zshrc Executable file
View file

@ -0,0 +1,40 @@
#save_aliases=$(alias -L)
# History in cache directory
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history
# Export oh-my-zsh location as $ZSH
export ZSH="$HOME/.config/oh-my-zsh"
# Set theme
#ZSH_THEME="agnoster"
#ZSH_THEME="bira"
#ZSH_THEME="gnzh"
#ZSH_THEME="rkj-repos"i
ZSH_THEME="af-magic"
# How often should zsh be updated
export UPDATE_ZSH_DAYS=5
# Enable command auto-correction
ENABLE_CORRECTION="false"
# Run oh-my-zsh
source $ZSH/oh-my-zsh.sh
# Load plugins
plugins=(
git
python
pylint
pyenv
autopep8
zsh-autosuggestions
)
if [ -f "$HOME/.config/sh/zsh/.zsh_config" ]; then
source "$HOME/.config/sh/zsh/.zsh_config"
fi
#neofetch --cpu_temp C --gtk2 off --gtk3 off --color_blocks on --pixterm