Add dotfiles

This commit is contained in:
ItsDrike 2020-10-22 18:00:38 +02:00
commit 02565d76fc
No known key found for this signature in database
GPG key ID: F4E8FF4F6AC7F3B4
12 changed files with 1802 additions and 0 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "home/.local/share/vim/bundle/Vundle.vim"]
path = home/.local/share/vim/bundle/Vundle.vim
url = https://github.com/VundleVim/Vundle.vim

0
home/.cache/history Normal file
View file

117
home/.config/sh/aliases Executable file
View file

@ -0,0 +1,117 @@
#!/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'
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
# Shortcuts
alias vi='vim'
alias rr='rm -r'
alias sv='systemctl'
# Changing directories
alias ..='cd ..'
alias ...='cd ../../'
alias ....='cd ../../../'
alias .....='cd ../../../../'
alias .2='cd ../../'
alias .3='cd ../../../'
alias .4='cd ../../../../'
alias .5='cd ../../../../../'
# Python
alias py3='python3'
alias py2='python2'
alias py='ipython'
alias ipy='ipython'
alias bpy='bpython'
# Config access shortcuts
alias cfzshrc='vim ~/.zshrc'
alias cfvim='vim ~/.config/vim/vimrc'
alias cfalias='vim ~/.config/sh/aliases'
# Replacements
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 reload="exec \$SHELL" # Reload the shell (i.e. invoke as a login shell
alias ip-show="dig +short myip.opendns.com @resolver1.opendns.com" # Gets your IP address
alias fhere='find . -name' # Find file/dir from currrent dir
alias ssh-list='ss | grep ssh' # List all SSH connections
alias swapout='sudo swapoff -a; sudo swapon -a' # Reset swap (move everything to RAM)
alias cpu-stress='fulload() { dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null | dd if=/dev/zero of=/dev/null & }; fulload; read; killall dd'
alias psg='\ps aux | grep -v grep | grep -i -e VSZ -e' # Get searchable process with nice output
alias path='echo -e ${PATH//:/\\n}' # Print each PATH entry on a separate line
alias colors-256='curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash' # Show color table
alias mount-table='df' # Show list of all mounted devices and their mount locations
alias create_mirror_list='reflector --country Slovakia --country Czechia --country Poland --country Hungary --country Ukraine --country Germany --country US --latest 800 --protocol https --sort rate --save mirrorlist'
alias pacman-extract='pacman -Syw --cachedir .' # Extract package/es into current floders
alias clean='rm -rf ~/.local/share/Trash/* && rm -rf ~/Downloads/*' # Remove trash and downloads files
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 nvidia='__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia' # Run app with nvidia (on hybrid mode with optimus)
alias o='dolphin .' # open in dolphin (file manager)
alias batinfo='sudo watch -d -n 2 tlp-stat -b'
alias sound_control='alsamixer' # Sound control tool in alsa_utils package
alias firefox="GTK_USE_PORTAL=1 firefox"
alias pdf-reader='mupdf' # Open pdf file
alias md-to-pdf='pandoc -s -o' # Convert markdown to pdf
alias minecraft='minecraft-launcher'
alias metasploit='msfconsole'
# 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
# Normalize `open` across Linux, macOS, and Windows.
# This is needed to make `open` 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
# Functions
if [ -f ~/.config/sh/functions ]; then
source ~/.config/sh/functions
fi
# Extra
if [ -f ~/.config/sh/extra ]; then
source ~/.config/sh/extra
fi

169
home/.config/sh/functions Executable file
View file

@ -0,0 +1,169 @@
#!/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
}
# 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')";
}
# 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";
}
# 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;
}
# `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;
}

View file

View file

@ -0,0 +1 @@
Subproject commit b255382d6242d7ea3877bf059d2934125e0c4d95

View file

View file

File diff suppressed because it is too large Load diff

75
home/.zshrc Executable file
View file

@ -0,0 +1,75 @@
ZSH_CACHE="$HOME/.cache/zsh"
# History in cache directory
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=$ZSH_CACHE/history
# Move .zsh-update to $ZSH_CACHE
[ -f ~/.zsh-update ] && mv ~/.zsh-update $ZSH_CACHE/.zsh-update
export ZSH_COMPDUMP="$ZSH_CACHE/zcompdump-$ZSH_VERSION"
# Export oh-my-zsh location as $ZSH
export ZSH="/usr/share/oh-my-zsh"
# Set theme
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
# Enable colors
autoload -U colors && colors
# Basic auto/tab complete
autoload -U compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit -d $ZSH_COMPDUMP
comp_options+=(globdots)
# Setup aliases
[ -f ~/.config/sh/aliases ] && source ~/.config/sh/aliases
# XDG Exports
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
# ~/ Clean-up
export WGETRC="$XDG_CONFIG_HOME"/wget/wgetrc
export LESSHISTFILE="-"
export VIMINIT=":source $XDG_CONFIG_HOME"/vim/vimrc
export GTK2_RC_FILES="$XDG_CONFIG_HOME"/gtk-2.0/gtkrc
export KDEHOME="$XDG_CONFIG_HOME"/kde
export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv
export GNUPGHOME="$XDG_DATA_HOME"/gnupg
export TS3_CONFIG_DIR="$XDG_CONFIG_HOME"/ts3client
export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker
export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME"/java
export NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc
export PYLINTHOME="$XDG_CACHE_HOME"/pylint
export SQLITE_HISTORY=$XDG_DATA_HOME/sqlite_history
export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime"
export GOPATH="$XDG_DATA_HOME"/go
export IPYTHONDIR="$XDG_CONFIG_HOME"/ipython
export JUPYTER_CONFIG_DIR="$XDG_CONFIG_HOME"/jupyter
# Add executable directories into PATH
PATH+=":$HOME/.local/bin"
# Force pipenv to create new enviroments within projects
export PIPENV_VENV_IN_PROJECT=1
# Load zsh-syntax-highlighting (should be last)
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
#neofetch --cpu_temp C --gtk2 off --gtk3 off --color_blocks on --pixterm

View file

@ -0,0 +1,44 @@
# af-magic.zsh-theme
# Repo: https://github.com/andyfleming/oh-my-zsh
# Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme
# settings
typeset +H return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
typeset +H my_gray="$FG[237]"
typeset +H my_orange="$FG[214]"
typeset +H my_red="$FG[196]"
# separator dashes size
function afmagic_dashes {
# [[ -n "${VIRTUAL_ENV-}" && -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" && "$PS1" = \(* ]] \
# && echo $(( COLUMNS - ${#VIRTUAL_ENV} - 3 )) \
# || echo $COLUMNS
}
# primary prompt
[ "$EUID" -eq 0 ] && PS1='$my_red%n@%m ' || PS1='$my_gray%n@%m '
PS1+='$FG[032]%~$(git_prompt_info)$(hg_prompt_info) $FG[105]%(!.#.»)%{$reset_color%} '
PS2='%{$fg[red]%}\ %{$reset_color%}'
RPS1='${return_code}'
# right prompt
(( $+functions[virtualenv_prompt_info] )) && RPS1+='$(virtualenv_prompt_info)'
#RPS1+=' $my_gray%n@%m%{$reset_color%}%'
# git settings
ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075]($FG[078]"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
# hg settings
ZSH_THEME_HG_PROMPT_PREFIX="$FG[075]($FG[078]"
ZSH_THEME_HG_PROMPT_CLEAN=""
ZSH_THEME_HG_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
ZSH_THEME_HG_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
# virtualenv settings
ZSH_THEME_VIRTUALENV_PREFIX=" $FG[075]["
ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}"