146 lines
4.5 KiB
Bash
146 lines
4.5 KiB
Bash
HISTFILE=~/.histfile
|
|
HISTSIZE=1000
|
|
SAVEHIST=1000
|
|
setopt autocd extendedglob
|
|
unsetopt beep
|
|
bindkey -e
|
|
|
|
# Completion
|
|
zstyle :compinstall filename '/home/eof/.zshrc'
|
|
autoload -Uz compinit
|
|
compinit
|
|
zstyle ':completion:*' menu select
|
|
setopt COMPLETE_ALIASES
|
|
zstyle ':completion::complete:*' gain-privileges 1
|
|
|
|
# completion colors
|
|
export LS_COLORS='no=00;37:fi=00;37:di=01;36:ln=04;36:pi=33:so=01;35:do=01;35:bd=33;01:cd=33;01:or=31;01:su=37:sg=30:tw=30:ow=34:st=37:ex=01;31:'
|
|
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
|
|
|
# Key bindings
|
|
# create a zkbd compatible hash;
|
|
# to add other keys to this hash, see: man 5 terminfo
|
|
typeset -g -A key
|
|
|
|
key[Home]="${terminfo[khome]}"
|
|
key[End]="${terminfo[kend]}"
|
|
key[Insert]="${terminfo[kich1]}"
|
|
key[Backspace]="${terminfo[kbs]}"
|
|
key[Delete]="${terminfo[kdch1]}"
|
|
key[Up]="${terminfo[kcuu1]}"
|
|
key[Down]="${terminfo[kcud1]}"
|
|
key[Left]="${terminfo[kcub1]}"
|
|
key[Right]="${terminfo[kcuf1]}"
|
|
key[PageUp]="${terminfo[kpp]}"
|
|
key[PageDown]="${terminfo[knp]}"
|
|
key[ShiftTab]="${terminfo[kcbt]}"
|
|
|
|
# setup key accordingly
|
|
[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line
|
|
[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line
|
|
[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode
|
|
[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char
|
|
[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char
|
|
[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history
|
|
[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history
|
|
[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char
|
|
[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char
|
|
[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history
|
|
[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history
|
|
[[ -n "${key[ShiftTab]}" ]] && bindkey -- "${key[ShiftTab]}" reverse-menu-complete
|
|
|
|
# Finally, make sure the terminal is in application mode, when zle is
|
|
# active. Only then are the values from $terminfo valid.
|
|
if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
|
|
autoload -Uz add-zle-hook-widget
|
|
function zle_application_mode_start {
|
|
echoti smkx
|
|
}
|
|
function zle_application_mode_stop {
|
|
echoti rmkx
|
|
}
|
|
add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
|
|
add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
|
|
fi
|
|
|
|
# History search
|
|
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
|
|
zle -N up-line-or-beginning-search
|
|
zle -N down-line-or-beginning-search
|
|
|
|
[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-beginning-search
|
|
[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search
|
|
|
|
# Prompt
|
|
#autoload -Uz promptinit
|
|
#promptinit
|
|
#prompt redhat
|
|
|
|
autoload -U colors && colors
|
|
|
|
apos=`expr index "$USER" @`
|
|
if [[ $apos -ne '0' ]]; then
|
|
U=${USER:0:$apos}
|
|
PROMPT="%B%F{2}[$U%m %~]%#%f%b "
|
|
else
|
|
PROMPT="%B%F{2}[%n@%m %~]%#%f%b "
|
|
fi
|
|
|
|
#RPROMPT='%T'
|
|
|
|
# Extract archives
|
|
extract () {
|
|
if [ -f $1 ] ; then
|
|
case $1 in
|
|
*.tar.bz2) tar xvjf $1 ;;
|
|
*.tar.gz) tar xvzf $1 ;;
|
|
*.tar.xz) tar xvfJ $1 ;;
|
|
*.bz2) bunzip2 $1 ;;
|
|
*.rar) unrar x $1 ;;
|
|
*.gz) gunzip $1 ;;
|
|
*.tar) tar xvf $1 ;;
|
|
*.tbz2) tar xvjf $1 ;;
|
|
*.tgz) tar xvzf $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
|
|
}
|
|
|
|
# Aliases
|
|
|
|
# enable color support of ls and also add handy aliases
|
|
if [ -x /usr/bin/dircolors ]; then
|
|
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
|
alias ls='ls --color=auto'
|
|
alias dir='dir --color=auto'
|
|
alias vdir='vdir --color=auto'
|
|
alias grep='grep --color=auto'
|
|
alias fgrep='fgrep --color=auto'
|
|
alias egrep='egrep --color=auto'
|
|
fi
|
|
|
|
alias -g L='| less'
|
|
alias -g G='| grep'
|
|
alias -g GI='|grep -i'
|
|
alias -g H='| head'
|
|
alias -g T='| tail'
|
|
alias -g S='| sort'
|
|
alias -g SU='|sort -u'
|
|
alias -g P='| patch -p1'
|
|
alias -g PD='| patch -p1 --dry-run'
|
|
alias -g WC='| wc -l'
|
|
alias -g IK='| iconv -c -f koi8r -t cp1251'
|
|
alias -g IU='| iconv -c -f utf8 -t cp1251'
|
|
|
|
# SSH Agent
|
|
#alias ssh='eval $(/usr/bin/keychain --eval --agents ssh -Q --quiet ~/.ssh/id_ed25519) && ssh'
|
|
|
|
# start tmux on SSH-sessions
|
|
if [ -n "$SSH_CONNECTION" ]; then
|
|
tmux attach -d || tmux new
|
|
fi |