summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-01-26 02:00:39 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-01-26 02:01:12 +0100
commitc2e3003972f84d5383bd9b2ba45d937e6e683cf9 (patch)
tree371bd1b9d993346eef84f6d1477b744f034929af
parent70ff4eac1f59c8c037c825959e5ef210705b7ecf (diff)
downloaddotfiles-c2e3003972f84d5383bd9b2ba45d937e6e683cf9.tar.xz
zshrc: rewrite and cleanup
-rw-r--r--zshrc119
1 files changed, 51 insertions, 68 deletions
diff --git a/zshrc b/zshrc
index 1ca063f..817d17e 100644
--- a/zshrc
+++ b/zshrc
@@ -36,7 +36,7 @@ eval `dircolors -b ~/.dir_colors`
# }}}
# {{{ Manual pages
-# - colorize, since man-db fails to do so
+# * colorize, since man-db fails to do so
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\E[01;31m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # end mode
@@ -79,8 +79,6 @@ alias ping='ping -c 5'
alias more='less'
alias mc='. /usr/share/mc/bin/mc-wrapper.sh -x'
alias links='links ~/.links/startpage.html'
-alias lynx='\links ~/.links/startpage.html'
-alias sripper='~/code/bash/sripper.sh'
alias cplay='cplay -v'
alias xtr='extract'
alias screen='screen -U -l'
@@ -96,7 +94,7 @@ alias ect='emacsclient -a emacs -t '
alias gpgd='gpg --decrypt'
alias gpge='gpg -ear anrxc'
alias keyshare='synergys -f --config /etc/synergy.conf'
-alias xpop='xprop | grep --color=none "WM_WINDOW_ROLE\|WM_CLASS" | xmessage -file -'
+alias xpop='xprop | grep --color=none "WM_CLASS\|^WM_NAME" | xmessage -file -'
# }}}
# {{{ Pacman
@@ -207,40 +205,42 @@ setopt nobgnice
setopt nobanghist
setopt noclobber
setopt shwordsplit
-#setopt mailwarning
setopt interactivecomments
setopt autopushd pushdminus pushdsilent pushdtohome
setopt histreduceblanks histignorespace inc_append_history
-#
-# new style completion system
+
+# Prompt requirements
+setopt extended_glob prompt_subst
+autoload colors zsh/terminfo
+
+# New style completion system
autoload -U compinit; compinit
-# list of completers to use
+# * List of completers to use
zstyle ':completion:*' completer _complete _match _approximate
-# allow approximate
+# * Allow approximate
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric
-# selection prompt as menu
+# * Selection prompt as menu
zstyle ':completion:*' menu select=1
-# menuselection for pid completion
+# * Menu selection for PID completion
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:kill:*' force-list always
zstyle ':completion:*:processes' command 'ps -au$USER'
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;32'
-# cd don't select parent dir
+# * Don't select parent dir on cd
zstyle ':completion:*:cd:*' ignore-parents parent pwd
-# complete with colors
+# * Complete with colors
zstyle ':completion:*' list-colors ''
# }}}
-# {{{ Prompt settings
+# {{{ Terminal and prompt settings
function precmd {
- ###
- # terminal width to one less than the actual width for lineup
+ # Terminal width = width - 1 (for lineup)
local TERMWIDTH
(( TERMWIDTH = ${COLUMNS} - 1 ))
- ###
- # truncate the path if it's too long
+
+ # Truncate long paths
PR_FILLBAR=""
PR_PWDLEN=""
local promptsize=${#${(%):---(%n@%m:%l)---()--}}
@@ -251,22 +251,16 @@ function precmd {
PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
fi
}
-###
-# set the window title in screen to the currently running program
-setopt extended_glob
+
function preexec () {
+ # Screen window titles as currently running programs
if [[ "$TERM" == "screen-256color" ]]; then
local CMD=${1[(wr)^(*=*|sudo|-*)]}
echo -n "\ek$CMD\e\\"
fi
}
+
function setprompt () {
- ###
- # need this so the prompt will work
- setopt prompt_subst
- ###
- # try to use colors
- autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
@@ -276,8 +270,8 @@ function setprompt () {
(( count = $count + 1 ))
done
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
- ###
- # try to use extended characters to look nicer
+
+ # Try to use extended characters to look nicer
typeset -A altchar
set -A altchar ${(s..)terminfo[acsc]}
PR_SET_CHARSET="%{$terminfo[enacs]%}"
@@ -288,58 +282,47 @@ function setprompt () {
PR_LLCORNER=${altchar[m]:--}
PR_LRCORNER=${altchar[j]:--}
PR_URCORNER=${altchar[k]:--}
- ###
- # set titlebar text on a terminal emulator
+
+ # Terminal specific settings and titlebar text
case $TERM in
rxvt*)
- PR_TITLEBAR=$'%{\e]0;%(!.*ROOT* | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
+ PR_TITLEBAR=$'%{\e]0;%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
;;
screen*)
- PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.*ROOT* |.)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
- # ensure SSH agent is still usable after an X restart
SSH_AUTH_SOCK=`find /tmp/gpg-* -name S.gpg-agent.ssh`
- ;;
- *)
- PR_TITLEBAR=''
+ PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
;;
esac
- ###
- # Linux console and Emacs ansi-term get simpler prompts, the rest have:
- # - (user@hostname:tty)--($PWD) and an exit code of the last command
- # - right hand prompt which makes room if the command line grows past it
- # - PS2 continuation prompt to match PS1 in color
+
+ # Terminal prompt settings
case $TERM in
- dumb)
+ dumb) # Simple prompt for dumb terminals
unsetopt zle
PROMPT='%n@%m:%~%% '
;;
- eterm-color)
- PROMPT='$PR_YELLOW%n$PR_WHITE:%~$PR_NO_COLOUR%% '
- ;;
- linux)
- # zenburn for the Linux console
- echo -en "\e]P01e2320" #zen-black (norm. black)
- echo -en "\e]P8709080" #zen-bright-black (norm. darkgrey)
- echo -en "\e]P1705050" #zen-red (norm. darkred)
- echo -en "\e]P9dca3a3" #zen-bright-red (norm. red)
- echo -en "\e]P260b48a" #zen-green (norm. darkgreen)
- echo -en "\e]PAc3bf9f" #zen-bright-green (norm. green)
- echo -en "\e]P3dfaf8f" #zen-yellow (norm. brown)
- echo -en "\e]PBf0dfaf" #zen-bright-yellow (norm. yellow)
- echo -en "\e]P4506070" #zen-blue (norm. darkblue)
- echo -en "\e]PC94bff3" #zen-bright-blue (norm. blue)
- echo -en "\e]P5dc8cc3" #zen-purple (norm. darkmagenta)
- echo -en "\e]PDec93d3" #zen-bright-purple (norm. magenta)
- echo -en "\e]P68cd0d3" #zen-cyan (norm. darkcyan)
- echo -en "\e]PE93e0e3" #zen-bright-cyan (norm. cyan)
- echo -en "\e]P7dcdccc" #zen-white (norm. lightgrey)
- echo -en "\e]PFffffff" #zen-bright-white (norm. white)
- # avoid 'artefacts'
- #clear
- #
+ linux) # Simple prompt with Zenburn colors for the console
+ echo -en "\e]P01e2320" # zenburn black (normal black)
+ echo -en "\e]P8709080" # bright-black (darkgrey)
+ echo -en "\e]P1705050" # red (darkred)
+ echo -en "\e]P9dca3a3" # bright-red (red)
+ echo -en "\e]P260b48a" # green (darkgreen)
+ echo -en "\e]PAc3bf9f" # bright-green (green)
+ echo -en "\e]P3dfaf8f" # yellow (brown)
+ echo -en "\e]PBf0dfaf" # bright-yellow (yellow)
+ echo -en "\e]P4506070" # blue (darkblue)
+ echo -en "\e]PC94bff3" # bright-blue (blue)
+ echo -en "\e]P5dc8cc3" # purple (darkmagenta)
+ echo -en "\e]PDec93d3" # bright-purple (magenta)
+ echo -en "\e]P68cd0d3" # cyan (darkcyan)
+ echo -en "\e]PE93e0e3" # bright-cyan (cyan)
+ echo -en "\e]P7dcdccc" # white (lightgrey)
+ echo -en "\e]PFffffff" # bright-white (white)
PROMPT='$PR_GREEN%n@%m$PR_WHITE:$PR_YELLOW%l$PR_WHITE:$PR_RED%~$PR_YELLOW%%$PR_NO_COLOUR '
;;
- *)
+ *) # Main prompt:
+ # * (user@hostname:tty)--($PWD) and an exit code of the last command
+ # * Right hand prompt which makes room if command line grows past it
+ # * The PS2 continuation prompt, that matches PS1 in color and style
PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
$PR_GREEN$PR_SHIFT_IN$PR_ULCORNER$PR_GREEN$PR_HBAR$PR_SHIFT_OUT(\
$PR_GREEN%(!.%SROOT%s.%n)$PR_GREEN@%m$PR_WHITE:$PR_YELLOW%l\