My zsh configuration
git clone https://mcol.xyz/code/zshrc
Log | Files | Refs | Submodules | README

commit d94d2659ac66a2dc2c9103cc93691eea4113eb10
parent 85b979265b48d952cbbd9b3fcd9685a625d35c8f
Author: mcol <mcol@posteo.net>
Date:   Tue, 30 Jul 2019 22:58:17 +0100

functions in separate file; add tig to ranger

Diffstat:
Maliases | 131+++++++++++++++++--------------------------------------------------------------
Afunctions.zsh | 42++++++++++++++++++++++++++++++++++++++++++
Mrc.conf | 7++++---
Mthemes/ban.zsh-theme | 2+-
4 files changed, 75 insertions(+), 107 deletions(-)

diff --git a/aliases b/aliases @@ -1,17 +1,15 @@ # # General aliases go here # Machine-specific aliases go in $HOME/.config/aliases -# +# # misc alias ..='cd ../' alias ...='cd ../../' alias l='ls -alhF' alias lc='ls -c1' -alias q="exit" -alias :q="exit" -alias tmp="cd /tmp; l" -alias _="sudo" +alias tmp='cd /tmp; l' +alias _='sudo' # systemd alias sc='systemctl' @@ -23,16 +21,6 @@ alias sce='systemctl enable' alias scen='systemctl enable --now' alias scd='systemctl disable' alias scdr='systemctl daemon-reload' -alias scc='systemctl cat' - -alias uscs='systemctl --user status' -alias uscsta='systemctl --user start' -alias uscsto='systemctl --user stop' -alias uscr='systemctl --user restart' -alias usce='systemctl --user enable' -alias uscen='systemctl --user enable --now' -alias uscd='systemctl --user disable' -alias uscdr='systemctl --user daemon-reload' alias ssc='sudo systemctl' alias sscs='sudo systemctl status' @@ -43,115 +31,52 @@ alias ssce='sudo systemctl enable' alias sscen='sudo systemctl enable --now' alias sscd='sudo systemctl disable' alias sscdr='sudo systemctl daemon-reload' -alias sscc='sudo systemctl cat' # networking -alias eduroam='nmcli con up eduroam' -alias pinga='ping archlinux.org' -alias ip="ip -c" -alias dns="cat /etc/resolv.conf" -alias wnet="sudo netstat -nputw" -alias wnetl="sudo netstat -nputlw" +alias ip='ip -c' +alias dns='cat /etc/resolv.conf' +alias wnet='sudo netstat -nputw' +alias wnetl='sudo netstat -nputlw' # launchers -alias ra="ranger" -alias v="vim" -alias tmux="tmux -u" -alias ta="tmux attach" +alias ra='ranger' +alias v='vim' +alias tmux='tmux -u' +alias ta='tmux attach' # git -alias gs="git status" -alias ad="git add" -alias cm="git commit -m" -alias psh="git push" -alias pshu="git push --set-upstream" -alias pl="git pull" -alias grm="git rm" -alias br="git branch" -alias brs="git branch -v" -alias ch="git checkout" -alias dif="git diff" +alias gs='git status' +alias ad='git add' +alias cm='git commit -m' +alias psh='git push' +alias fe='git fetch && git status' +alias pl='git pull' +alias rb='git pull --rebase upstream master' +alias br='git branch' +alias brs='git branch -v' +alias ch='git checkout' +alias dif='git diff' +alias cl='git clone' # tools -alias usync="rsync -avPzh --delete" -alias cl='clear' -alias removespaces="for run in {1..20}; do; find . -type f -name \"* *\" -exec rename \" \" \"_\" {} \; ; done" +alias usync='rsync -avPzh --delete' # quick edits -alias modalia='vim $HOME/.config/aliases && source $HOME/.config/aliases' -alias modaliaz='vim $ZSH/aliases && source $ZSH/aliases' +alias modalia='vim $HOME/.config/aliases' +alias modaliaz='vim $ZSH/aliases' alias vimrc='vim $HOME/.vim/bundle/vim-misc/vimrc' -alias vimkeys='vim $HOME/.vim/bundle/vim-misc/plugin/keybindings.vim' -alias modtux='vim $HOME/.vim/bundle/vim-misc/tmux.conf' alias zshrc='vim $HOME/.zsh/zshrc' alias modrc='vim $HOME/.config/ranger/rc.conf' # shortcuts alias gc='cd $HOME/.config; l' -alias gcs='cd $HOME/.config/systemd/user; ranger' alias gh='cd $HOME; ls' alias gd='cd $HOME/documents' alias gD='cd $HOME/Downloads' alias gg='cd $HOME/git; l' -alias gb='cd $HOME/bin; ls' +alias gb='cd $HOME/.config/bin; ls' alias ge='cd /etc' -alias gv='cd $HOME/.vim; ranger' +alias gv='cd $HOME/.vim/bundle; ranger' alias gvm='cd $HOME/.vim/bundle/vim-misc; ra' alias gz='cd $HOME/.zsh; l' alias gR='cd $HOME/reach' - - -# colourise man pages -function man() { - env \ - LESS_TERMCAP_mb=$(printf "\e[1;31m") \ - LESS_TERMCAP_md=$(printf "\e[1;31m") \ - LESS_TERMCAP_me=$(printf "\e[0m") \ - LESS_TERMCAP_se=$(printf "\e[0m") \ - LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ - LESS_TERMCAP_ue=$(printf "\e[0m") \ - LESS_TERMCAP_us=$(printf "\e[1;32m") \ - PAGER="${commands[less]:-$PAGER}" \ - _NROFF_U=1 \ - PATH="$HOME/bin:$PATH" \ - man "$@" -} - -# use last browsed directory automatically with ranger -ranger-cd() { - tempfile="$(mktemp -t tmp.XXXXXX)" - if [[ -f /usr/local/bin/ranger ]] - then - /usr/local/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}" - else - /usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}" - fi - test -f "$tempfile" && - if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then - cd -- "$(cat "$tempfile")" - fi - rm -f -- "$tempfile" -} -ranger() { # prevent nested ranger instances when shelling from ranger - if [ -z "$RANGER_LEVEL" ]; then - ranger-cd "$@" - else - exit - fi -} - - -shebang() { # create new file, add shebang, and vim - touch $1 - chmod +x $1 - echo -e "#!/usr/bin/env bash\n" > $1 - vim +2 $1 -} -shebangpy() { # create new file, add shebang, and vim - touch $1 - chmod +x $1 - echo -e "#!/usr/bin/env python3\n" > $1 - vim +2 $1 -} - -# vim: ft=sh diff --git a/functions.zsh b/functions.zsh @@ -0,0 +1,42 @@ +# +# misc functions +# + +# use last browsed directory automatically with ranger +ranger-cd() { + tempfile="$(mktemp -t tmp.XXXXXX)" + if [[ -f /usr/local/bin/ranger ]] + then + /usr/local/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}" + else + /usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}" + fi + test -f "$tempfile" && + if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then + cd -- "$(cat "$tempfile")" + fi + rm -f -- "$tempfile" +} +ranger() { # prevent nested ranger instances when shelling from ranger + if [ -z "$RANGER_LEVEL" ]; then + ranger-cd "$@" + else + exit + fi +} + +shebang() { # create new file, add shebang, and vim + touch $1 + chmod +x $1 + echo -e "#!/usr/bin/env bash\n" > $1 + vim +2 $1 +} +shebangpy() { # create new file, add shebang, and vim + touch $1 + chmod +x $1 + echo -e "#!/usr/bin/env python3\n" > $1 + vim +2 $1 +} + +# copy file path to clipboard +cpath() { readlink -f $1 | copy } diff --git a/rc.conf b/rc.conf @@ -641,11 +641,11 @@ map gU cd ~/.cache/aurutils/sync map gc cd ~/.config map gx cd ~/.config/Xresources.d map gm cd ~/media -map gb cd ~/bin +map gb cd ~/.config/bin map gP cd ~/pictures map gw cd ~/work map ga cd ~/work/analysis -map gp cd ~/work/research/papers +map gp cd ~/work/research/research.wiki/papers/pdfs map gf cd ~/work/analysis/Figures map gW cd ~/work/research/research.wiki map gr cd ~/work/analysis/rochefort-tools @@ -657,7 +657,7 @@ map gq cd /usr/lib/python3.7/site-packages/libqtile # git -map bs shell git status | less -r +map bs shell git -c color.status=always status | less -r map bm console shell git commit -m ' map bd shell git diff --color=always %s | less -r map bD shell git diff --color=always | less -r @@ -666,3 +666,4 @@ map bA shell git add -f %s map bc console shell git checkout%space map bp shell git push | less -r map bl shell git pull | less -r +map bt shell tig diff --git a/themes/ban.zsh-theme b/themes/ban.zsh-theme @@ -3,7 +3,7 @@ # ban zsh theme # -## Segment drawing +# Segment drawing # A few utility functions to make it easy and re-usable to draw segmented prompts