Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###############################################################################
- # Safety Check
- ###############################################################################
- # Don't do anything for non-interactive shells
- [[ -z "$PS1" ]] && return
- # Need to know if this is Linux or AIX
- OS=`uname -a|awk '{print $1}'`
- # On AIX, we need to source /etc/environment first and foremost.
- if [[ ${OS} == "AIX" && -s /etc/environment ]]; then
- . /etc/environment
- fi
- ###############################################################################
- # Local Settings
- ###############################################################################
- # Add any machine specific settings/aliases to your login
- eval LOCAL_SETUP_FILE="~/.zshrc.local"
- if [[ -s ${LOCAL_SETUP_FILE} ]]; then
- . ${LOCAL_SETUP_FILE}
- fi
- # If applicable, add any machine specifics scripts to your login
- if [[ -d ${LOCAL_SCRIPT_DIR} && -n ${LOCAL_SCRIPT_DIR} ]]; then
- export PATH=${PATH}:${LOCAL_SCRIPT_DIR}
- fi
- ###############################################################################
- # History
- ###############################################################################
- HISTFILE=~/.history
- HISTSIZE=10500
- SAVEHIST=10000
- setopt appendhistory nomatch # Add everything to the history.
- setopt incappendhistory # Write after every command
- setopt sharehistory # Share between sessions
- setopt histexpiredupsfirst # Kill duplicates in history first (when full)
- setopt histfindnodups # Don't find dupes, either.
- setopt histsavenodups # I hate duplicates, obviously... Don't save them.
- setopt histverify # Preview history expansions
- export HISTIGNORE="&:ls:[bf]g:exit:reset:clear:cd:cd ..:cd.."
- ###############################################################################
- # Editor Settings
- ###############################################################################
- # Check for VIM, use that if possible.
- which vim 2>&1 1>/dev/null
- if [[ $? == 0 ]]; then
- export EDITOR=vim
- export VISUAL=vim
- alias vi='vim'
- else
- export EDITOR=vi
- export VISUAL=vi
- fi
- ###############################################################################
- # Autocompletion
- ###############################################################################
- # The below somehow screw up vi searching from a prompt with esc+/ ... ?
- #autoload -U compinit # Load these two for the case-insensitive globbing.
- #compinit -C
- # Case-insensitive (all),partial-word and then substring completion
- #zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
- ## case-insensitive (all),partial-word and then substring completion
- zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
- setopt autoparamslash # Append a slash on directory completion
- setopt completealiases # Treat aliases as commands
- setopt extendedglob # Assume [#~^] refer to patterns
- setopt globdots # Assume leading . for hidden files
- setopt nonomatch # Ignore globs if they match nothing
- setopt autopushd # Automatically add directories to pushd
- setopt autocd # Automatically change directories if no cmd given
- setopt nomenucomplete # Disable ZSH menu completion
- setopt noautomenu # Disable ZSH tab cycle completion
- setopt bashautolist # Enable Bash/KSH style completion.
- ###############################################################################
- # Aliases
- ###############################################################################
- if [[ ${OS} == "AIX" && -a /usr/linux/bin/ls ]]; then
- # To install ZSH, you have to have CoreUtils... This shouldn't be needed.
- LS="/usr/linux/bin/ls"
- EGREP="/usr/linux/bin/egrep"
- else
- LS="ls"
- EGREP="egrep"
- fi
- alias grep=`echo ${EGREP}`' --color=tty -d skip'
- alias ls=`echo ${LS}`' --color=tty'
- alias ld='ls -ld [^.]*/ 2>/dev/null || echo "No directories..."'
- alias ll='ls -l'
- alias la='ls -la'
- alias lt='ls -ltr'
- alias tf='tail -f'
- alias ruler='echo .........1.........2.........3.........4.........5.........6.........7.........8'
- ###############################################################################
- # Color man pages - Linux Only
- ###############################################################################
- if [[ ${OS} == "Linux" ]]; then
- export LESS_TERMCAP_mb=$'\e[01;34m'
- export LESS_TERMCAP_md=$'\e[01;34m'
- export LESS_TERMCAP_me=$'\e[0m'
- export LESS_TERMCAP_se=$'\e[0m'
- export LESS_TERMCAP_so=$'\e[01;44;33m'
- export LESS_TERMCAP_ue=$'\e[0m'
- export LESS_TERMCAP_us=$'\e[38;05;111m;'
- fi
- ###############################################################################
- # Key Bindings
- ###############################################################################
- # Force ZSH to use VI keybindings
- bindkey -v # VI Keybindings
- # Generic Key Bindings (XTerm)
- bindkey "\e[1~" beginning-of-line # Home
- bindkey "\e[4~" end-of-line # End
- bindkey "\e[5~" beginning-of-history # PageUp
- bindkey "\e[6~" end-of-history # PageDown
- bindkey "\e[2~" quoted-insert # Ins
- bindkey "\e[3~" delete-char # Del
- # RXVT Keybinding
- bindkey "\e[7~" beginning-of-line # Home
- bindkey "\e[8~" end-of-line # End
- # XTerm - non-RH/Debian
- bindkey "\eOH" beginning-of-line # Home
- bindkey "\eOF" end-of-line # End
- # FreeBSD Console
- bindkey "\e[H" beginning-of-line # Home
- bindkey "\e[F" end-of-line # End
- ###############################################################################
- # Misc Functions
- ###############################################################################
- function backup() { cp $1{,.$(date '+%Y%m%d-%H%M%S')}; }
- ex () {
- if [ -f $1 ] ; then
- case $1 in
- *.tar.bz2) tar xjf $1 ;;
- *.tar.gz) tar xzf $1 ;;
- *.bz2) bunzip2 $1 ;;
- *.rar) rar x $1 ;;
- *.gz) gunzip $1 ;;
- *.tar) tar xf $1 ;;
- *.tbz2) tar xjf $1 ;;
- *.tgz) tar xzf $1 ;;
- *.zip) unzip $1 ;;
- *.Z) uncompress $1 ;;
- *.7z) 7z x $1 ;;
- *) echo "'$1' cannot be extracted via extract()" ;;
- esac
- else
- echo "'$1' is not a valid file"
- fi
- }
- ###############################################################################
- # Prompt Settings
- ###############################################################################
- setprompt () {
- # Need this so the prompt will work.
- setopt prompt_subst
- # See if we can use colors. AIX VTMenu terminals notably will not.
- autoload colors zsh/terminfo
- if [[ "$terminfo[colors]" -ge 8 ]]; then
- colors
- fi
- for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
- eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
- eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
- done
- PR_NO_COLOR="%{$terminfo[sgr0]%}"
- # The default non-root prompt symbol is a %, which throws me off, change that.
- if [[ `id -u` == 0 ]]; then
- PromptChar="#"
- else
- PromptChar="$"
- fi
- PROMPT="${COLOR1}[${COLOR2}%D{%H:%M:%S}${COLOR1}] [${COLOR2}%n${COLOR1}@${COLOR2}%m${COLOR1}:${COLOR2}%~${COLOR1}]
- %(?..${COLOR1}[${COLOR_ERR}RTN: %?${PS_NO_COLOR}${COLOR1}] )${PR_NO_COLOR}${PromptChar} "
- RPROMPT=""
- PS2="${COLOR1}-(${COLOR2}%_${COLOR1})-${PR_NO_COLOR} "
- }
- setprompt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement