some massive changes for both shells
This commit is contained in:
parent
08613b53cd
commit
d9f5fb7855
1 changed files with 95 additions and 62 deletions
157
shellrc
157
shellrc
|
@ -2,13 +2,14 @@
|
||||||
# If not running interactively, don't do anything
|
# If not running interactively, don't do anything
|
||||||
[[ $- != *i* ]] && return
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
# {{{ common
|
# common
|
||||||
# {{{ environment
|
# {{{ environment
|
||||||
newline="
|
newline="
|
||||||
"
|
"
|
||||||
local_bin="${HOME}/.local/bin"
|
local_bin="${HOME}/.local/bin"
|
||||||
dotfiles="${HOME}/vdotfiles"
|
dotfiles="${HOME}/vdotfiles"
|
||||||
comp_enabled=true
|
comp_enabled=true
|
||||||
|
vcs_enabled=true
|
||||||
|
|
||||||
export TIME_STYLE='long-iso'
|
export TIME_STYLE='long-iso'
|
||||||
export LC_ALL='en_US.UTF-8'
|
export LC_ALL='en_US.UTF-8'
|
||||||
|
@ -28,7 +29,7 @@ else
|
||||||
is_exec() { [[ -x $(type -P ${1}) ]]; }
|
is_exec() { [[ -x $(type -P ${1}) ]]; }
|
||||||
fi
|
fi
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ aliases
|
# {{{ common aliases
|
||||||
alias vi='command vim'
|
alias vi='command vim'
|
||||||
alias less='command less -R'
|
alias less='command less -R'
|
||||||
alias cower='command cower -c'
|
alias cower='command cower -c'
|
||||||
|
@ -87,25 +88,32 @@ alias sdf='command svn diff'
|
||||||
alias sci='command svn commit'
|
alias sci='command svn commit'
|
||||||
alias sup='command svn up'
|
alias sup='command svn up'
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ functions
|
# {{{ common functions
|
||||||
screenoffdisable() {
|
screenoff-disable() {
|
||||||
xset -dpms
|
xset -dpms
|
||||||
xset s off
|
xset s off
|
||||||
}
|
}
|
||||||
|
|
||||||
screenoffenable() {
|
screenoff-enable() {
|
||||||
xset +dpms
|
xset +dpms
|
||||||
xset s on
|
xset s on
|
||||||
}
|
}
|
||||||
|
|
||||||
dotfiles_update() {
|
dotfiles-update() {
|
||||||
git --work-tree="${dotfiles}" --git-dir="${dotfiles}/.git" pull
|
git --work-tree="${dotfiles}" --git-dir="${dotfiles}/.git" pull
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
# }}}
|
|
||||||
|
hide-info() {
|
||||||
|
hide_info=true
|
||||||
|
}
|
||||||
|
|
||||||
|
unhide-info() {
|
||||||
|
unset hide_info
|
||||||
|
}
|
||||||
# }}}
|
# }}}
|
||||||
if is_zsh; then
|
if is_zsh; then
|
||||||
# {{{ zsh
|
# zsh
|
||||||
# {{{ options
|
# {{{ options
|
||||||
setopt APPEND_HISTORY EXTENDED_HISTORY HIST_IGNORE_DUPS EXTENDED_GLOB AUTO_CD AUTO_PUSHD PRINT_EXIT_VALUE
|
setopt APPEND_HISTORY EXTENDED_HISTORY HIST_IGNORE_DUPS EXTENDED_GLOB AUTO_CD AUTO_PUSHD PRINT_EXIT_VALUE
|
||||||
unsetopt BEEP NO_MATCH NOTIFY
|
unsetopt BEEP NO_MATCH NOTIFY
|
||||||
|
@ -137,53 +145,65 @@ if is_zsh; then
|
||||||
zstyle ':completion:*:processes-names' command 'ps axho command'
|
zstyle ':completion:*:processes-names' command 'ps axho command'
|
||||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||||
fi
|
fi
|
||||||
|
if [[ -n ${vcs_enabled} ]]; then
|
||||||
|
autoload -Uz vcs_info
|
||||||
|
zstyle ':vcs_info:*' enable git svn
|
||||||
|
zstyle ':vcs_info:*' check-for-changes true
|
||||||
|
zstyle ':vcs_info:*' stagedstr " %F{green}✓%f"
|
||||||
|
zstyle ':vcs_info:*' unstagedstr " %B%F{red}✗%f%b"
|
||||||
|
zstyle ':vcs_info:svn*' branchformat '%r'
|
||||||
|
zstyle ':vcs_info:*' formats "%B%F{yellow}[%f%%b%s%B%F{yellow}: %F{magenta}%r%f %F{yellow}%f%%b %F{yellow}%b%f%u%c%B%F{yellow}]%f%%b"
|
||||||
|
fi
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ prompt
|
# {{{ prompt
|
||||||
prompt() {
|
lb='%B%F{yellow}[%f%b'
|
||||||
case ${KEYMAP} in
|
rb='%B%F{yellow}]%f%b'
|
||||||
'main')
|
bb='%B%F{yellow} %f%b'
|
||||||
mode='>'
|
prompt_status='%(?.%F{green}✓%f.%F{red}✗%f)'
|
||||||
;;
|
prompt_cwd='%B%d%b'
|
||||||
'vicmd')
|
prompt_user='%(1000#..%(1205#..%B%F{red}%n%F{yellow}@%f%b))'
|
||||||
mode='|'
|
prompt_host='%m'
|
||||||
;;
|
prompt_bang='%B%(!.%F{red}.%F{green})%#%f%b'
|
||||||
*)
|
precmd() {
|
||||||
mode=''
|
[[ -n ${vcs_enabled} ]] && vcs_info
|
||||||
;;
|
if [[ -z ${hide_info} ]]; then
|
||||||
esac
|
prompt_info="${lb}${prompt_user}${prompt_host}${bb}${prompt_cwd}${rb}${vcs_info_msg_0_} zsh${newline}"
|
||||||
PROMPT="%(?.%F{green}✓%f.%F{red}✗%f) %(!.%F{red}.%F{blue})%n%f@%B%F{green}%m%f%b %B%d%b:${newline}%(!.%F{red}.)%#%f${mode} "
|
else
|
||||||
zle reset-prompt
|
prompt_info=''
|
||||||
|
fi
|
||||||
|
PROMPT="${prompt_info}${prompt_bang} "
|
||||||
}
|
}
|
||||||
zle-line-init() { prompt; }
|
PROMPT2='%b%f%_%B%F{green}>%f%b '
|
||||||
zle-keymap-select() { prompt; }
|
PROMPT3='%b%f?%B%F{green}#%f%b '
|
||||||
zle -N zle-line-init
|
PROMPT4='%b%f+%N:%i%B%F{green}>%f%b '
|
||||||
zle -N zle-keymap-select
|
#PROMPT="${lb}${prompt_status}${rb}${lb}${prompt_user}${prompt_host}${rb}${lb}${prompt_cwd}${rb}${newline}%B%(!.%F{red}.%F{green})%#%f%b "
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ key bindings
|
# {{{ key bindings
|
||||||
bindkey -v
|
bindkey -e
|
||||||
# urxvt
|
# urxvt
|
||||||
bindkey '^[[7~' beginning-of-line # home
|
bindkey '^[[7~' beginning-of-line # home
|
||||||
bindkey '^[[8~' end-of-line # end
|
bindkey '^[[8~' end-of-line # end
|
||||||
bindkey '^[Oc' forward-word # ctrl + right
|
bindkey '^[Oc' forward-word # ctrl + right
|
||||||
bindkey '^[Od' backward-word # ctrl + left
|
bindkey '^[Od' backward-word # ctrl + left
|
||||||
bindkey '^[[3^' delete-word # ctrl + del
|
bindkey '^[[3^' delete-word # ctrl + del
|
||||||
#bindkey '^H' backward-delete-word # ctrl + backspace
|
#bindkey '^H' backward-delete-word # ctrl + backspace
|
||||||
# screen
|
# screen
|
||||||
bindkey '^[[1~' beginning-of-line # home
|
bindkey '^[[1~' beginning-of-line # home
|
||||||
bindkey '^[[4~' end-of-line # end
|
bindkey '^[[4~' end-of-line # end
|
||||||
# xterm
|
# xterm
|
||||||
bindkey '^[[H' beginning-of-line # home
|
bindkey '^[[H' beginning-of-line # home
|
||||||
bindkey '^[[F' end-of-line # end
|
bindkey '^[[F' end-of-line # end
|
||||||
# most of them (but not urxvt)
|
# most of them (but not urxvt)
|
||||||
bindkey '^[[1;5C' forward-word # ctrl + right
|
bindkey '^[[1;5C' forward-word # ctrl + right
|
||||||
bindkey '^[[1;5D' backward-word # ctrl + left
|
bindkey '^[[1;5D' backward-word # ctrl + left
|
||||||
bindkey '^[[3;5~' delete-word # ctrl + del
|
bindkey '^[[3;5~' delete-word # ctrl + del
|
||||||
# all of them
|
# all of them
|
||||||
bindkey '^[[5~' backward-word # page up
|
bindkey '^[[5~' backward-word # page up
|
||||||
bindkey '^[[6~' forward-word # page down
|
bindkey '^[[6~' forward-word # page down
|
||||||
bindkey '^[[3~' delete-char # del
|
bindkey '^[[3~' delete-char # del
|
||||||
bindkey '^R' history-incremental-search-backward # ctrl + R
|
bindkey '^R' history-incremental-search-backward # ctrl + r
|
||||||
bindkey '^[m' copy-prev-shell-word # alt + m
|
bindkey '^[m' copy-prev-shell-word # alt + m
|
||||||
|
bindkey -s '^j' '^atime ^m' # ctrl + j
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ global aliases
|
# {{{ global aliases
|
||||||
alias -g L='| less -R'
|
alias -g L='| less -R'
|
||||||
|
@ -248,9 +268,8 @@ if is_zsh; then
|
||||||
bindkey '^[[B' history-substring-search-down
|
bindkey '^[[B' history-substring-search-down
|
||||||
fi
|
fi
|
||||||
# }}}
|
# }}}
|
||||||
# }}}
|
|
||||||
else
|
else
|
||||||
# {{{ bash
|
# bash
|
||||||
# {{{ options
|
# {{{ options
|
||||||
HISTSIZE=1000
|
HISTSIZE=1000
|
||||||
HISTCONTROL=ignoredups:ignorespace
|
HISTCONTROL=ignoredups:ignorespace
|
||||||
|
@ -269,23 +288,38 @@ else
|
||||||
# y is color:
|
# y is color:
|
||||||
# 0 - Black, 1 - Red, 2 - Green, 3 - Yellow
|
# 0 - Black, 1 - Red, 2 - Green, 3 - Yellow
|
||||||
# 4 - Blue, 5 - Magenta, 6 - Cyan, 7 - White
|
# 4 - Blue, 5 - Magenta, 6 - Cyan, 7 - White
|
||||||
if [[ ${UID} -eq 1000 || ${UID} -eq 1205 || ${UID} -eq 0 || ${USER} == 'Von Random' ]]; then
|
lb='\[\e[1;33m\][\[\e[0m\]'
|
||||||
user_ps=""
|
rb='\[\e[1;33m\]]\[\e[0m\]'
|
||||||
else
|
bb='\[\e[1;33m\] \[\e[0m\]'
|
||||||
user_ps="\[\e[1;31m\]\u\[\e[0m\]@"
|
prompt_host='\h'
|
||||||
fi
|
prompt_bang='\$\[\e[0m\]'
|
||||||
if [[ $UID -eq 0 ]]; then
|
precmd() {
|
||||||
bang_ps='\[\e[1;31m\]\$\[\e[0m\]'
|
if [[ -z ${hide_info} ]]; then
|
||||||
else
|
prompt_cwd="\[\e[1;37m\]${PWD}\[\e[0m\]"
|
||||||
bang_ps='\[\e[1;32m\]\$\[\e[0m\]'
|
if [[ ${UID} -eq 1000 || ${UID} -eq 1205 ]]; then
|
||||||
fi
|
prompt_user=''
|
||||||
PS1="${user_ps}\[\e[1;34m\]\h\[\e[0m\] \[\e[1;33m\]\v\[\e[0m\] \[\e[37m\]\w\[\e[0m\] ${bang_ps} "
|
else
|
||||||
unset user_ps bang_ps
|
prompt_user='\[\e[1;31m\]\u\[\e[1;33m\]@\[\e[0m\]'
|
||||||
|
fi
|
||||||
|
prompt_info="${lb}${prompt_user}${prompt_host}${bb}${prompt_cwd}${rb} bash-\v${newline}"
|
||||||
|
else
|
||||||
|
prompt_info=''
|
||||||
|
fi
|
||||||
|
if [[ $UID -eq 0 ]]; then
|
||||||
|
prompt_bang_color='\[\e[1;31m\]'
|
||||||
|
else
|
||||||
|
prompt_bang_color='\[\e[1;32m\]'
|
||||||
|
fi
|
||||||
|
PS1="${prompt_info}${prompt_bang_color}${prompt_bang} "
|
||||||
|
}
|
||||||
|
PROMPT_COMMAND='precmd'
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ key bindings
|
# {{{ key bindings
|
||||||
|
# time $command bind
|
||||||
|
bind '"\C-j":"\C-atime \C-m"'
|
||||||
# PgUp/PgDown and ctrl-arrows for skip word
|
# PgUp/PgDown and ctrl-arrows for skip word
|
||||||
bind '"[5~"':backward-word
|
bind '"\e[5~"':backward-word
|
||||||
bind '"[6~"':forward-word
|
bind '"\e[6~"':forward-word
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ plugins
|
# {{{ plugins
|
||||||
completion_path='/usr/share/bash-completion/bash_completion'
|
completion_path='/usr/share/bash-completion/bash_completion'
|
||||||
|
@ -298,7 +332,6 @@ else
|
||||||
# we want to see exit code on error (it also has to be the last entry here)
|
# we want to see exit code on error (it also has to be the last entry here)
|
||||||
trap 'echo -e "\e[0mbash: exit \e[1;37m$?\e[0m"' ERR
|
trap 'echo -e "\e[0mbash: exit \e[1;37m$?\e[0m"' ERR
|
||||||
# }}}
|
# }}}
|
||||||
# }}}
|
|
||||||
fi
|
fi
|
||||||
# {{{ source specific and common extras
|
# {{{ source specific and common extras
|
||||||
for i in ${extras[@]}; do
|
for i in ${extras[@]}; do
|
||||||
|
|
Loading…
Reference in a new issue