My dotfiles for my Linux rice managed with stow and make
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

243 lines
6.4 KiB

#!/usr/bin/zsh
# default applications
alias -s c=nvim
alias -s cpp=nvim
alias -s java=nvim
alias -s md=nvim
alias -s tex=nvim
alias -s log="less -MN"
# aliases for configs
alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"'
alias dhex='dhex -f $XDG_CONFIG_HOME/dhex/dhexrc'
alias gdb='gdb -nh -x $XDG_CONFIG_HOME/gdb/init'
alias tmate='tmate -f $XDG_CONFIG_HOME/tmux/tmux.conf'
alias sbt='sbt -ivy $XDG_DATA_HOME/ivy2 -sbt-dir $XDG_DATA_HOME/sbt'
# aliases for Tmux
alias tmux='tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf -2'
alias ta='tmux attach -t'
alias tnew='tmux new -s'
alias tls='tmux ls'
alias tkill='tmux kill-session -t'
alias tmuxlayout='tmux list-windows|sed "s/^.*\[layout \(.*\)\] @.*$/\1/"'
# weather aliases
wttrf()
{
curl -H "Accept-Language: ${LANG%_*}" wttr.in/"$1"
}
wttr()
{
wttrf "$1?u"
}
wttrm()
{
wttrf "$1?m"
}
wt()
{
wttr "$1?0"
}
# email aliases
alias m='neomutt'
alias msmtpqm='msmtpq --q-mgmt'
# calendar aliases
alias kl='khal'
alias ikl='ikhal'
alias kla='khal -c $XDG_CONFIG_HOME/khal/academicconfig'
alias ikla='ikhal -c $XDG_CONFIG_HOME/khal/academicconfig'
# addressbook aliases
alias kd='khard'
alias kdd='khard details'
# sync aliases
alias oimap='offlineimap'
alias vd='vdirsyncer'
alias vds='vdirsyncer sync'
# various app aliases
alias nb='newsboat'
alias nf='neofetch'
alias yt="mpsyt"
alias vi='nvim'
alias vim='nvim'
alias arc='aria2c'
alias sc='scim'
# gopass aliases
alias pshow='gopass show'
alias pedit='gopass edit'
alias pupdate='gopass update -p'
alias ptail='gopass tail'
alias ptedit='gopass tailedit'
pnew() {
gopass cp template $1 && gopass edit $1
}
# python aliases
alias pip='python -m pip'
alias venv='python -m venv'
vactivate() {
venv_dir="$1"
[ -z "$1" ] && venv_dir="env"
. $venv_dir/bin/activate
}
kernnew() {
basename $VIRTUAL_ENV 2>/dev/null >/dev/null && python -m ipykernel install --user --name=$(basename $VIRTUAL_ENV)
}
kerndel() {
basename $VIRTUAL_ENV 2>/dev/null >/dev/null && jupyter kernelspec uninstall $(basename $VIRTUAL_ENV)
}
httpstart() {
port=8080
[ -n "$1" ] && port=$1
python -m http.server $port
}
# jupyter functions
jqt() {
kern="$(ls $XDG_DATA_HOME/jupyter/kernels | fzf -n 1)"
[ -z "$kern" ] && exit 0
setsid jupyter-qtconsole --kernel=$kern >/dev/null 2>&1 &
}
jt() {
kern="$(ls $XDG_DATA_HOME/jupyter/kernels | fzf -n 1)"
[ -z "$kern" ] && exit 0
jupyter console --kernel=$kern
}
# julia functions
jlactivate() {
[ ! -z "$VIRTUAL_ENV" ] && deactivate
venv_dir="$1"
[ -z "$1" ] && venv_dir="env"
[ ! -e "$venv_dir" ] && venv_dir="$JULIA_HOME/environments/$1"
. $venv_dir/bin/activate
}
jlenv() {
venv_dir="$1"
[ -z "$1" ] && venv_dir="env"
julia -e "using VirtualEnv; venv(\"$venv_dir\")"
}
# git aliases
alias lg='lazygit'
alias g='git'
alias gb='git branch'
alias gcm='git commit -S --message'
alias gco='git checkout'
alias gf='git fetch'
alias gfc='git clone'
alias gfm='git pull'
alias gia='git add'
alias gp='git push'
alias gr='git rebase'
alias gS='git submodule'
alias gSa='git submodule add'
alias gSi='git submodule init'
alias gSI='git submodule update --init --recursive'
alias gws='git status --short'
alias gwS='git status'
alias glv="git log --graph --pretty=format:'%h - %d %s (%cr) <%an>' | nvim -R -c 'set hidden nowrap keywordprg=:enew\ \|\ terminal\ \git\ --no-pager\ show | nnoremap q :bd!<cr>' -"
# git pull, merge master into branch
gpmm() { git checkout $1 && git pull && git merge -S -m "Merge master" master && git push }
# dirs aliases
da() { pushd $1 > /dev/null && dirs -v }
dr() { pushd +$1 > /dev/null && dirs -v }
alias db='popd > /dev/null && dirs -v'
alias dv='dirs -v'
# various utilities
if [ -x /usr/bin/dircolors ]; then
test -r $HOME/.dircolors && eval "$(dircolors -b $HOME/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
alias bemenu='bemenucolor'
alias systemctlu='systemctl --user'
# cp -> rsync
alias cp='rsync -ah --partial --inplace --info=progress2'
alias Rupdate='sudo Rscript -e '"'"'update.packages(checkBuilt=TRUE, ask=FALSE, repos="https://cran.rstudio.com")'"'"
alias chmox='chmod +x'
alias maketags='ctags -R .'
alias ssh='TERM=xterm-color ssh'
alias l='ls'
alias sl='ls'
alias ll='ls -alF'
alias la='ls -A'
alias ..='cd ..'
alias ...='cd ../..'
alias todo='vi $XDG_DATA_HOME/todo.md'
alias makescript="fc -rnl | head -1 >"
alias histg='history | grep'
alias cmount='mount | column -t'
alias meminfo='free -m -l -t'
alias psg='ps aux | grep'
alias ipinfo="curl ifconfig.me && curl ifconfig.me/host"
alias alert='notify-send -i "$([ $? = 0 ] && echo terminal || echo error)" "$(cat $HOME/.zsh_history|tail -n1|cut -d'\'';'\'' -f2-|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias fuck='sudo /usr/bin/zsh -c "$(fc -rnl| head -1)"'
alias sudoe='sudo -E'
alias suroot='sudo -E su -p'
mcd() { mkdir -p -- "$@"; cd -- "$@";}
cls() { cd "$1"; ls;}
crun() { make "$1"; ./$1;}
backup() { cp "$1"{,.bak};}
md5check() { md5sum "$1" | grep "$2";}
# function to control web sync services
websync() { systemctl --user $1 offlineimap-oneshot.timer; systemctl --user $1 vdirsyncer-oneshot.timer }
filetemplate() {
template=$1
file=$2
tempbase=$(basename -- "$template")
ext="${tempbase##*.}"
if [[ $file != '' ]]; then
if [[ ! $file =~ \.$ext$ ]]; then
file=$file.$ext
fi
[ ! -f $file ] && cp $template $file;
vi $file;
fi
}
# LaTeX Template aliases
alias txa="filetemplate $HOME/Documents/latex/templates/article.tex"
alias txb="filetemplate $HOME/Documents/latex/templates/beamer.tex"
alias txm="filetemplate $HOME/Documents/latex/templates/mla.tex"
# Markdown Template aliases
alias mda="filetemplate $HOME/Documents/markdown/templates/article.md"
alias mdb="filetemplate $HOME/Documents/markdown/templates/beamer.md"
alias rmda="filetemplate $HOME/Documents/markdown/templates/article.rmd"
alias rmdb="filetemplate $HOME/Documents/markdown/templates/beamer.rmd"
# C compiling shortcuts for gcc
gccc() {
if [[ $1 =~ \.c$ ]]; then
gcc -std=c99 -Wall -pedantic -Wextra -Werror -O2 -g $1 -o ${1%%.*};
else
echo "$1 is not a c file"
fi
}
gcclm() {
if [[ $1 =~ \.c$ ]]; then
gcc -std=c99 -g $1 -o ${1%%.*} -lm;
else
echo "$1 is not a c file"
fi
}
# unused aliases
#alias gohome='sudo openvpn --script-security 2 --config $HOME/.openvpn/halter_home.ovpn'
#alias dataBackup='$HOME/backupScript/backup.sh'
#alias dataBackupUmount='$HOME/backupScript/backup.sh && sleep 5 && sudo umount /dev/sdd1'