This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
configuration:zsh [2014/12/25 17:09] sjorge |
configuration:zsh [2017/05/01 18:32] sjorge [.zshrc] |
||
---|---|---|---|
Line 36: | Line 36: | ||
## .zshrc | ## .zshrc | ||
# by Jorge Schrauwen <jorge@blackdot.be> | # by Jorge Schrauwen <jorge@blackdot.be> | ||
- | # Version 20141225028 | + | # Version 20170501001 |
# YYYYMMDD### | # YYYYMMDD### | ||
Line 43: | Line 43: | ||
# | # | ||
# Change Log | # Change Log | ||
- | # - 20141225: new - switched to promptinit, converted themes and renamed minimal -> compact | + | # - 20170501: --- - disabled auto update |
+ | # - 20160621: --- - optimizations | ||
+ | # - 20160621: fix - if .aliases is missing initial exit indicator was fasle | ||
+ | # - 20160320: fix - color ls on SmartOS, drop obd support | ||
+ | # - 20160219: fix - fix vncviewer alias | ||
+ | # - 20151128: --- - cleanup and removal of old code | ||
+ | # - 20151001: fix - support new pkgsrc layout on OSX | ||
+ | # - 20141225: new - added 'developer' theme (same as dual but with git helpers) | ||
+ | # - 20141225: new - switched to promptinit, converted themes and renamed minimal | ||
# - 20141225: new - added CMD_SAFE_WRAP (defaults to 1) | # - 20141225: new - added CMD_SAFE_WRAP (defaults to 1) | ||
# - 20141225: --- - switch to selective nocorrect/noglob | # - 20141225: --- - switch to selective nocorrect/noglob | ||
Line 79: | Line 87: | ||
# {{{ updater | # {{{ updater | ||
NZSHRC="https://docu.blackdot.be/getRaw.php?onlyCode=true&id=configuration:zsh" | NZSHRC="https://docu.blackdot.be/getRaw.php?onlyCode=true&id=configuration:zsh" | ||
- | CHECK_UPDATE=1 | + | CHECK_UPDATE=0 |
- | AUTO_UPDATE=1 | + | AUTO_UPDATE=0 |
# }}} | # }}} | ||
# {{{ options | # {{{ options | ||
## change directory | ## change directory | ||
- | setopt auto_cd # drop cd | + | setopt auto_cd |
| | ||
## enable command correction | ## enable command correction | ||
- | #setopt correct | + | setopt correct |
- | setopt correct_all | + | #setopt correct_all |
## prevent file overwrite | ## prevent file overwrite | ||
Line 98: | Line 106: | ||
## superglobs | ## superglobs | ||
- | #setopt extended_glob | ||
unsetopt case_glob | unsetopt case_glob | ||
| | ||
Line 120: | Line 127: | ||
## make some commands safer | ## make some commands safer | ||
CMD_SAFE_WRAP=0 | CMD_SAFE_WRAP=0 | ||
+ | setopt mark_dirs | ||
## include local options | ## include local options | ||
Line 279: | Line 287: | ||
| | ||
# colorization | # colorization | ||
+ | eval $(dircolors) | ||
[ -f /etc/DIR_COLORS ] && eval $(dircolors -b /etc/DIR_COLORS) | [ -f /etc/DIR_COLORS ] && eval $(dircolors -b /etc/DIR_COLORS) | ||
[ -f ~/.dir_colors ] && eval $(dircolors -b ~/.dir_colors) | [ -f ~/.dir_colors ] && eval $(dircolors -b ~/.dir_colors) | ||
Line 290: | Line 299: | ||
| | ||
# LX BrandZ | # LX BrandZ | ||
- | [ -d /native/usr/bin ] && export PATH=$PATH:/native/usr/bin | + | if [ -d /native ]; then |
- | [ -d /native/sbin ] && [[ -n $WANT_SBIN ]] && export PATH=$PATH:/native/sbin | + | export PATH=$PATH:/native/usr/bin |
- | [ -d /native/usr/sbin ] && [[ -n $WANT_SBIN ]] && export PATH=$PATH:/native/usr/sbin | + | if [ -n $WANT_SBIN ]; then |
+ | export PATH=$PATH:/native/sbin | ||
+ | export PATH=$PATH:/native/usr/sbin | ||
+ | fi | ||
+ | fi | ||
;; esac | ;; esac | ||
case $OSTYPE in solaris*) | case $OSTYPE in solaris*) | ||
Line 303: | Line 316: | ||
# add /usr/sbin if wanted | # add /usr/sbin if wanted | ||
[ $(echo $PATH | grep -c '/usr/sbin:') -eq 0 ] && | [ $(echo $PATH | grep -c '/usr/sbin:') -eq 0 ] && | ||
- | [[ -n $WANT_SBIN ]] && export PATH=$PATH:/usr/sbin | + | [ -n $WANT_SBIN ] && export PATH=$PATH:/usr/sbin |
# check for gnu | # check for gnu | ||
export PATH=$(echo $PATH | /bin/sed -r 's#:/usr/gnu/s?bin##g') | export PATH=$(echo $PATH | /bin/sed -r 's#:/usr/gnu/s?bin##g') | ||
- | [ -d /usr/gnu/bin ] && export PATH=$PATH:/usr/gnu/bin | + | if [ -d /usr/gnu ]; then |
- | [ -d /usr/gnu/sbin ] && [[ -n $WANT_SBIN ]] && export PATH=$PATH:/usr/gnu/sbin | + | export PATH=$PATH:/usr/gnu/bin |
- | + | [ -n $WANT_SBIN ] && export PATH=$PATH:/usr/gnu/sbin | |
- | # check for obd repository (omnios) | + | |
- | export PATH=$(echo $PATH | /bin/sed -r 's#/opt/obd/s?bin:##g') | + | # selective gnu / colorization |
- | export MANPATH=$(echo $MANPATH | /bin/sed -r 's#/opt/obd/share/man:##g') | + | [ -e /usr/gnu/bin/sed ] && alias sed='/usr/gnu/bin/sed' |
- | [ -d /opt/obd/bin ] && export PATH=$PATH:/opt/obd/bin | + | [ -e /usr/gnu/bin/diff ] && alias diff='/usr/gnu/bin/diff' |
- | [ -d /opt/obd/sbin ] && [[ -n $WANT_SBIN ]] && export PATH=$PATH:/opt/obd/sbin | + | [ -e /usr/gnu/bin/tar ] && alias tar='/usr/gnu/bin/tar' |
- | [ -d /opt/obd/share/man ] && export MANPATH=$MANPATH:/opt/obd/share/man | + | [ -e /usr/gnu/bin/rm ] && alias rm='/usr/gnu/bin/rm' |
+ | fi | ||
| | ||
# check for pkgsrc (smartos) | # check for pkgsrc (smartos) | ||
export PATH=$(echo $PATH | /bin/sed -r 's#/opt/local/s?bin:##g') | export PATH=$(echo $PATH | /bin/sed -r 's#/opt/local/s?bin:##g') | ||
- | [ -d /opt/local/bin ] && export PATH=/opt/local/bin:$PATH | + | export MANPATH=$(echo $MANPATH | /bin/sed -r 's#/opt/local/man:##g') |
- | [ -d /opt/local/sbin ] && [[ -n $WANT_SBIN ]] && export PATH=/opt/local/sbin:$PATH | + | if [ -d /opt/local ]; then |
- | [ -d /opt/local/man ] && export MANPATH=/opt/local/man:$MANPATH | + | export MANPATH=/opt/local/man:$MANPATH |
+ | export PATH=/opt/local/bin:$PATH | ||
+ | [ -n $WANT_SBIN ] && export PATH=/opt/local/sbin:$PATH | ||
+ | fi | ||
# check for omniti repository (omnios) | # check for omniti repository (omnios) | ||
export PATH=$(echo $PATH | /bin/sed -r 's#/opt/omni/s?bin:##g') | export PATH=$(echo $PATH | /bin/sed -r 's#/opt/omni/s?bin:##g') | ||
export MANPATH=$(echo $MANPATH | /bin/sed -r 's#/opt/omni/share/man:##g') | export MANPATH=$(echo $MANPATH | /bin/sed -r 's#/opt/omni/share/man:##g') | ||
- | [ -d /opt/omni/bin ] && export PATH=$PATH:/opt/omni/bin | + | if [ -d /opt/local ]; then |
- | [ -d /opt/omni/sbin ] && [[ -n $WANT_SBIN ]] && export PATH=$PATH:/opt/omni/sbin | + | export MANPATH=$MANPATH:/opt/omni/share/man |
- | [ -d /opt/omni/share/man ] && export MANPATH=$MANPATH:/opt/omni/share/man | + | export PATH=$PATH:/opt/omni/bin |
- | + | [ -n $WANT_SBIN ] && export PATH=$PATH:/opt/omni/sbin | |
- | # check for sfw | + | fi |
- | export PATH=$(echo $PATH | /bin/sed -r 's#:/usr/sfw/s?bin##g') | + | |
- | [ -d /usr/sfw/bin ] && export PATH=$PATH:/usr/sfw/bin | + | |
# check for local | # check for local | ||
export PATH=$(echo $PATH | /bin/sed -r 's#/usr/local/s?bin:##g') | export PATH=$(echo $PATH | /bin/sed -r 's#/usr/local/s?bin:##g') | ||
- | [ -d /usr/local/bin ] && export PATH=/usr/local/bin:$PATH | + | if [ -d /usr/local ]; then |
- | [ -d /usr/local/sbin ] && [[ -n $WANT_SBIN ]] && export PATH=/usr/local/sbin:$PATH | + | export PATH=/usr/local/bin:$PATH |
+ | [ -n $WANT_SBIN ] && export PATH=/usr/local/sbin:$PATH | ||
+ | fi | ||
# check for opencsw | # check for opencsw | ||
export PATH=$(echo $PATH | /bin/sed -r 's#:/opt/csw/s?bin##g') | export PATH=$(echo $PATH | /bin/sed -r 's#:/opt/csw/s?bin##g') | ||
- | [ -d /opt/csw/bin ] && export PATH=$PATH:/opt/csw/gnu:/opt/csw/bin | + | if [ -d /opt/csw ]; then |
- | [ -d /opt/csw/sbin ] && [[ -n $WANT_SBIN ]] && export PATH=$PATH:/opt/csw/sbin | + | export PATH=$PATH:/opt/csw/gnu:/opt/csw/bin |
+ | [ -n $WANT_SBIN ] && export PATH=$PATH:/opt/csw/sbin | ||
+ | fi | ||
# colorization | # colorization | ||
- | [ "$(which ls)" = "/usr/bin/ls" ] && alias ls='ls --color' | + | case $(which ls) in |
- | + | /opt/local/bin/ls) alias ls='ls --color' ;; | |
- | # selective gnu / colorization | + | /usr/bin/ls) alias ls='ls --color' ;; |
- | [ "$(which ls)" = "/usr/gnu/bin/ls" ] && alias ls='/usr/gnu/bin/ls --color=auto' | + | /usr/gnu/bin/ls) ls='ls --color=auto' ;; |
- | [ -e /usr/gnu/bin/grep ] && alias grep='/usr/gnu/bin/grep --color=auto' | + | esac |
- | [ -e /usr/gnu/bin/sed ] && alias sed='/usr/gnu/bin/sed' | + | case $(which grep) in |
- | [ -e /usr/gnu/bin/diff ] && alias diff='/usr/gnu/bin/diff' | + | /opt/local/bin/grep) alias grep='grep --color=auto' ;; |
- | [ -e /usr/gnu/bin/tar ] && alias tar='/usr/gnu/bin/tar' | + | /usr/gnu/bin/grep) alias grep='grep --color=auto' ;; |
- | [ -e /usr/gnu/bin/rm ] && alias rm='/usr/gnu/bin/rm' | + | esac |
;; esac | ;; esac | ||
case $OSTYPE in openbsd*) | case $OSTYPE in openbsd*) | ||
Line 383: | Line 402: | ||
| | ||
# pkgsrc | # pkgsrc | ||
- | if [ -e /usr/pkg/bin/pkgin ]; then | + | if [ -e /opt/pkg/bin/pkgin ]; then |
+ | export PATH=/opt/pkg/gnu/bin:/opt/pkg/bin:/opt/pkg/sbin:$PATH | ||
+ | export MANPATH=/opt/pkg/man:$MANPATH | ||
+ | if [ -f ~/.dir_colors ]; then | ||
+ | eval $(dircolors -b ~/.dir_colors) | ||
+ | export ZLSCOLORS="${LS_COLORS}" | ||
+ | unalias ls &> /dev/null | ||
+ | alias ls='ls --color=auto' | ||
+ | fi | ||
+ | alias pkgin='sudo pkgin' | ||
+ | elif [ -e /usr/pkg/bin/pkgin ]; then | ||
export PATH=/usr/pkg/gnu/bin:/usr/pkg/bin:/usr/pkg/sbin:$PATH | export PATH=/usr/pkg/gnu/bin:/usr/pkg/bin:/usr/pkg/sbin:$PATH | ||
export MANPATH=/usr/pkg/man:$MANPATH | export MANPATH=/usr/pkg/man:$MANPATH | ||
Line 395: | Line 424: | ||
fi | fi | ||
| | ||
- | ## helpers | + | ## helpers |
- | function trash() { | + | function vnc() { |
- | local trash_dir="${HOME}/.Trash" | + | |
- | local temp_ifs="$IFS" | + | |
- | IFS=$'\n' | + | |
- | for item in "$@"; do | + | |
- | if [[ -e "$item" ]]; then | + | |
- | item_name="$(basename $item)" | + | |
- | if [[ -e "${trash_dir}/${item_name}" ]]; then | + | |
- | mv -f "$item" "${trash_dir}/${item_name} $(date "+%H-%M-%S")" | + | |
- | else | + | |
- | mv -f "$item" "${trash_dir}/" | + | |
- | fi | + | |
- | fi | + | |
- | done | + | |
- | IFS=$temp_ifs | + | |
- | } | + | |
- | + | ||
- | function vncviewer() { | + | |
which vncviewer &> /dev/null | which vncviewer &> /dev/null | ||
if [ $? -eq 0 ]; then | if [ $? -eq 0 ]; then | ||
Line 425: | Line 437: | ||
## host specific | ## host specific | ||
case ${HOST:r} in | case ${HOST:r} in | ||
- | (axion*|tachyon*) | + | (axion*|tachyon*|photon*) |
- | # add a little info banner | + | |
- | if [[ $SHLVL -eq 1 ]] ; then | + | |
- | clear | + | |
- | echo | + | |
- | print -P "\e[1;33m Welcome to: \e[1;34m%m" | + | |
- | print -P "\e[1;33m Running: \e[1;34m`uname -srm`\e[1;33m on \e[1;34m%l" | + | |
- | print -P "\e[1;33m It is:\e[1;34m %D{%r} \e[1;33m on \e[1;34m%D{%A %b %f %G}" | + | |
- | echo | + | |
- | tput sgr0 | + | |
- | fi | + | |
# proper UTF-8 | # proper UTF-8 | ||
export LANG=en_US.UTF-8 | export LANG=en_US.UTF-8 | ||
Line 443: | Line 444: | ||
PROMPT_HOST_COLOR=green | PROMPT_HOST_COLOR=green | ||
;; | ;; | ||
- | (artemis*|monolith*) | + | (exosphere*|crust*) |
PROMPT_HOST_COLOR=red | PROMPT_HOST_COLOR=red | ||
;; | ;; | ||
Line 628: | Line 629: | ||
alias scp='noglob scp' | alias scp='noglob scp' | ||
alias sftp='noglob sftp' | alias sftp='noglob sftp' | ||
- | alias ssh='noglob sftp' | + | alias ssh='noglob ssh' |
# }}} | # }}} | ||
Line 646: | Line 647: | ||
autoload -Uz promptinit && promptinit | autoload -Uz promptinit && promptinit | ||
- | ## utf8 checkmarks | + | ## checkmarks |
PROMPT_CO='.' | PROMPT_CO='.' | ||
PROMPT_CE='!' | PROMPT_CE='!' | ||
- | case $LANG in *UTF-8) | ||
- | case $TERM in (xterm*) | ||
- | if [[ -z $NOFANCY_PROMPT ]] ; then | ||
- | PROMPT_CO='✓' | ||
- | PROMPT_CE='✗' | ||
- | fi | ||
- | ;; esac | ||
- | ;; esac | ||
## create themes | ## create themes | ||
Line 682: | Line 675: | ||
} | } | ||
prompt_themes=($prompt_themes dual) | prompt_themes=($prompt_themes dual) | ||
+ | | ||
+ | prompt_developer_setup() { | ||
+ | _developer_git() { | ||
+ | git status 2> /dev/null > /dev/null | ||
+ | if [ $? -eq 0 ]; then | ||
+ | BRANCH=${$(git symbolic-ref HEAD 2> /dev/null)#refs/heads/} | ||
+ | if [[ -n $BRANCH ]]; then | ||
+ | STATUS=$(git status --porcelain 2> /dev/null | tail -n1) | ||
+ | if [[ -n $STATUS ]]; then | ||
+ | git_color=$fg_bold[red] | ||
+ | else | ||
+ | git_color=$fg_bold[green] | ||
+ | fi | ||
+ | echo "%{$fg_bold[grey]%} :: %{$fg_bold[white]%}${BRANCH}%{${git_color}#%{$fg_bold[grey]%}" | ||
+ | fi | ||
+ | fi | ||
+ | } | ||
+ | | ||
+ | PROMPT=$'%{$fg_bold[grey]%}[%{$fg_bold[$PROMPT_HOST_COLOR]%}%m %{$fg_bold[grey]%}:: %(!.%{$fg_bold[red]%}.%{$fg_bold[green]%})%n%{$fg_bold[grey]%}][%{$fg_bold[white]%}%~%{$fg_bold[grey]%}$(_developer_git)]\n[%(?,%{$fg_bold[green]%}$PROMPT_CO%{$reset_color%},%{$fg_bold[red]%}$PROMPT_CE%{$reset_color%})%{$fg_bold[grey]%}]%(!.%{$fg_bold[red]%}#.%{$fg_bold[green]%}$)%{$reset_color%} ' | ||
+ | RPROMPT='' | ||
+ | } | ||
+ | prompt_themes=($prompt_themes developer) | ||
| | ||
## enable theme | ## enable theme | ||
Line 692: | Line 707: | ||
# preferences | # preferences | ||
which nano &> /dev/null ; [ $? -eq 0 ] && export EDITOR='nano' | which nano &> /dev/null ; [ $? -eq 0 ] && export EDITOR='nano' | ||
+ | which vi &> /dev/null ; [ $? -eq 0 ] && export EDITOR='vi' | ||
which vim &> /dev/null ; [ $? -eq 0 ] && export EDITOR='vim' | which vim &> /dev/null ; [ $? -eq 0 ] && export EDITOR='vim' | ||
export PAGER='less' | export PAGER='less' | ||
Line 704: | Line 720: | ||
case $OSTYPE in solaris*) | case $OSTYPE in solaris*) | ||
- | alias zfs_rsync='rsync -avAPh' | + | alias zfs_rsync='rsync -aviAPh' |
- | alias zfs_rsync+='rsync -avAPh --delete' | + | alias zfs_rsync+='rsync -aviAPh --delete' |
;; esac | ;; esac | ||
# include local aliases | # include local aliases | ||
- | [[ -e ~/.aliasses ]] && mv ~/.aliasses ~/.aliases | + | [[ -e ~/.aliases ]] && source ~/.aliases || true |
- | [[ -e ~/.aliases ]] && source ~/.aliases | + | |
# }}} | # }}} | ||
</code> | </code> | ||