From 7da6720baa91138db50e6d02a2b8dd741f07f471 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sat, 20 Oct 2018 15:11:16 +0000 Subject: [PATCH] zshrc: Major cleanup --- zshrc | 114 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 50 insertions(+), 64 deletions(-) diff --git a/zshrc b/zshrc index 170f11d..a8c8488 100644 --- a/zshrc +++ b/zshrc @@ -1,21 +1,15 @@ -AUDIO_PLAYER="audacious" -VIDEO_PLAYER="mpv" -ARCHIVE_FORMATS=(7z bz2 gz xz tar tbz tbz2 tgz txz tar.gz tar.bz2 tar.xz rar zip) -AUDIO_PLAYER_FORMATS=(aac flac it m4a mod mp3 mpc ogg sid spc wma wv xm) -VIDEO_PLAYER_FORMATS=(avi divx flv mkv mov mpeg mp4 mpg ogm wmv) -EDITOR="vim" -PAGER="less" -GREP="" -GREP_COLOUR="auto" -FGREP="" -LS="" -LS_COLOUR="auto" -LS_ON_CD="yes" -LS_ON_INIT="no" -LS_COLORS='di=34:ow=44;37:tw=44;37:st=44;37:ex=31:su=7;31:sg=7;31:ln=33:or=7;33:pi=32:do=32:bd=35:cd=35:so=32:*.bz2=36:*.dmg=36:*.gz=36:*.gpg=36:*.rar=36:*.tar=36:*.tbz2=36:*.tgz=36:*.xz=36:*.zip=36:*.orig=90:*~=90' -FEMALE="no" # Whether the user is female ;) +export EDITOR="vim" +export PAGER="less" +export LS_COLORS='di=34:ow=44;37:tw=44;37:st=44;37:ex=31:su=7;31:sg=7;31:ln=33:or=7;33:pi=32:do=32:bd=35:cd=35:so=32:*.bz2=36:*.dmg=36:*.gz=36:*.gpg=36:*.rar=36:*.tar=36:*.tbz2=36:*.tgz=36:*.xz=36:*.zip=36:*.orig=90:*~=90' LISTMAX=32768 WORDCHARS="*?[];!#~" +local grep="" +local grep_color="auto" +local fgrep="" +local ls="" +local ls_color="auto" +local ls_on_cd="yes" +local ls_on_init="no" bindkey -v # history-incremental-search-backward is much more useful than @@ -42,46 +36,46 @@ compinit -C # Ignore case on completion zstyle ':completion:*' matcher-list 'm:{A-Z}={a-z} m:{a-z}={A-Z}' -if [ "$GREP" -o "$GREP_COLOUR" ]; then - if [ -z "$GREP" ]; then +if [ -n "$grep" -o -n "$grep_color" ]; then + if [ -z "$grep" ]; then if which ggrep &>/dev/null; then - GREP="ggrep" + grep="ggrep" else - GREP="grep" + grep="grep" fi fi - [ ! -z "$GREP_COLOUR" -a "$GREP_COLOUR[1]" != "-" ] && \ - GREP_COLOUR="--colour=$GREP_COLOUR" - alias grep="$GREP $GREP_COLOUR" + [ -n "$grep_color" -a "$grep_color[1]" != "-" ] && \ + grep_color="--color=$grep_color" + alias grep="$grep $grep_color" fi -if [ "$FGREP" -o "$GREP_COLOUR" ]; then - if [ -z "$FGREP" ]; then +if [ -n "$fgrep" -o -n "$grep_color" ]; then + if [ -z "$fgrep" ]; then if which ggrep &>/dev/null; then - FGREP="ggrep -F" + fgrep="ggrep -F" else - FGREP="fgrep" + fgrep="fgrep" fi fi - [ ! -z "$GREP_COLOUR" -a "$GREP_COLOUR[1]" != "-" ] && \ - GREP_COLOUR="--colour=$GREP_COLOUR" - alias fgrep="$FGREP $GREP_COLOUR" + [ -n "$grep_color" -a "$grep_color[1]" != "-" ] && \ + grep_color="--color=$grep_color" + alias fgrep="$fgrep $grep_color" fi -if [ "$LS" -o "$LS_COLOUR" ]; then - if [ -z "$LS" ]; then +if [ -n "$ls" -o -n "$ls_color" ]; then + if [ -z "$ls" ]; then if which gls &>/dev/null; then - LS="gls" + ls="gls" else - LS="ls" + ls="ls" fi fi - [ ! -z "$LS_COLOUR" -a "$LS_COLOUR[1]" != "-" ] && \ - LS_COLOUR="--color=$LS_COLOUR" - alias ls="$LS $LS_COLOUR" + [ -n "$ls_color" -a "$ls_color[1]" != "-" ] && \ + ls_color="--color=$ls_color" + alias ls="$ls $ls_color" fi -if [ "$LS_ON_CD" -a "$LS_ON_CD" != "no" ]; then +if [ "$ls_on_cd" = "yes" ]; then chpwd() { ls } @@ -97,12 +91,7 @@ else fi set_prompt() { - if [ "$FEMALE" = "yes" ]; then - PS1="%m:%c$@%B%(!.#.%{$(print "\e[1;35m")%}♥" - PS1+="%{$(print "\e[0m")%})%b " - else - PS1="%m:%c$@%B%(!.#.$)%b " - fi + PS1="%m:%c$@%B%(!.#.$)%b " PS2="%B>%b " RPS1="%(1j.%{$(print "\e[1;33m")%}%j%{$(print "\e[0m")%}.)" RPS1+="%(?..%(1j. .)%{$(print "\e[1;31m")%}%?%{$(print "\e[0m")%})" @@ -116,7 +105,7 @@ _precmd() { local branch_name branch_name="$(git symbolic-ref HEAD 2>/dev/null)" branch_name="${branch_name##refs/heads/}" - if [ ! -z "$branch_name" -a "$branch_name" != "master" ]; then + if [ -n "$branch_name" -a "$branch_name" != "master" ]; then local branch branch="%{$(print "\e[1;30m")%}(" branch+="%{$(print "\e[0;36m")%}$branch_name" @@ -161,14 +150,17 @@ extr() { *.7z) 7za x $i ;; + *.lha) + ofarc -x $i + ;; *.tar) - tar xfv $i + ofarc -x $i ;; *.tbz | *.tbz2 | *.tar.bz2) - bzcat $i | tar xfv - + bzcat $i | ofarc -ttar -x - ;; *.tgz | *.tar.gz) - gzcat $i | tar xfv - + ofarc -x $i ;; *.txz | *.tar.xz) xzcat $i | tar xfv - @@ -177,14 +169,14 @@ extr() { unrar x $i ;; *.zip) - unzip $i + ofarc -x $i ;; # These have to be the last for obvious reasons *.bz2) bunzip2 $i ;; *.gz) - gunzip $i + ofarc -x $i ;; *.xz) unxz $i @@ -196,20 +188,14 @@ extr() { esac done } +for ext in 7z lha tar tbz tbz2 tar.bz2 tgz tar.gz txz tar.xz rar zip bz2 gz xz +do + alias -s "$ext=extr" +done -[ "$EDITOR" = "vim" ] && alias vi="vim" +[ "$EDITOR" = "vim" ] && alias vi=vim +which gpg2 &>/dev/null && alias gpg=gpg2 -for ext in $ARCHIVE_FORMATS; do alias -s $ext=extr; done +[ "$ls_on_init" = "yes" ] && ls -[ "$AUDIO_PLAYER" ] && \ - for ext in $AUDIO_PLAYER_FORMATS; do alias -s $ext=$AUDIO_PLAYER; done - -[ "$VIDEO_PLAYER" ] && \ - for ext in $VIDEO_PLAYER_FORMATS; do alias -s $ext=$VIDEO_PLAYER; done - -[ "$LS_ON_INIT" = "yes" ] && ls - -unset AUDIO_PLAYER VIDEO_PLAYER -unset ARCHIVE_FORMATS AUDIO_PLAYER_FORMATS VIDEO_PLAYER_FORMATS -unset FGREP GREP GREP_COLOUR LS LS_COLOUR LS_ON_CD LS_ON_INIT -export EDITOR LS_COLORS +unset fgrep grep grep_color ls ls_color ls_on_cd ls_on_init