Add (mostly) ported zsh configuration
This commit is contained in:
parent
615b0657ee
commit
46dff558ab
45
prompt_fresh_setup
Normal file
45
prompt_fresh_setup
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
prompt_fresh_setup() {
|
||||||
|
autoload -U add-zsh-hook
|
||||||
|
add-zsh-hook precmd prompt_fresh_precmd
|
||||||
|
|
||||||
|
if [ "$USERNAME" = "root" ]; then
|
||||||
|
local user="%{%F{9}%}%n%{%f%}"
|
||||||
|
else
|
||||||
|
local user="%{%F{35}%}%n%{%f%}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SSH_CONNECTION" != "" ]; then
|
||||||
|
local user="%{%F{35}%}$user%{%f%}@%{%F{244}%}%M%{%f%}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PS1="«$user» "
|
||||||
|
# TODO: PS2
|
||||||
|
# TODO: PS3
|
||||||
|
# TODO: PS4
|
||||||
|
# TODO: RPS1
|
||||||
|
|
||||||
|
prompt_opts=(cr subst percent)
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt_fresh_precmd() {
|
||||||
|
local exit_code=$?
|
||||||
|
if [[ $exit_code -ne 0 ]]; then
|
||||||
|
local result="%{%B%F{1}%}$exit_code%{%f%b%}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local time_stamp="%{%F{244}%}%D{%H:%M:%S}%{%f%}"
|
||||||
|
local directory="%{%F{37}%}%~%{%f%}"
|
||||||
|
|
||||||
|
# TODO: git status
|
||||||
|
|
||||||
|
local line="$time_stamp $directory"
|
||||||
|
|
||||||
|
visible_length() { echo $(( ${#${(S%%)1//(\%(KF1]|)\{*\}|\%[Bbkf])}} )) }
|
||||||
|
local length=`visible_length "$line$result"`
|
||||||
|
|
||||||
|
print -P "$line${(l:COLUMNS - $length - 1:: :)}$result"
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt_fresh_setup "$@"
|
||||||
|
|
||||||
|
# vim:ft=zsh
|
36
zshenv
Normal file
36
zshenv
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Enable saving command history to file
|
||||||
|
HISTFILE=$HOME/.histfile
|
||||||
|
HISTSIZE=5000
|
||||||
|
SAVEHIST=5000
|
||||||
|
|
||||||
|
# Enable time stats for long lasting commands
|
||||||
|
REPORTTIME=5
|
||||||
|
|
||||||
|
# Add ~/.local to the environment
|
||||||
|
PATH=$HOME/.local/bin:$PATH
|
||||||
|
MANPATH=$HOME/.local/share/man:$MANPATH
|
||||||
|
INFOPATH=$HOME/.local/share/info:$INFOPATH
|
||||||
|
LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
|
||||||
|
fpath+=$HOME/.local/share/zsh/site-functions
|
||||||
|
|
||||||
|
# Add ccache to the PATH if present
|
||||||
|
if [ -f /usr/bin/ccache ]; then
|
||||||
|
PATH=/usr/lib/ccache:$PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use ~/.local for pip installs on macOS
|
||||||
|
if [ "`uname`" = "Darwin" ]; then
|
||||||
|
export PYTHONUSERBASE=$HOME/.local
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Change colors used by less and man
|
||||||
|
export LESS_TERMCAP_mb=$(printf "\e[0;31m")
|
||||||
|
export LESS_TERMCAP_md=$(printf "\e[0;36m")
|
||||||
|
export LESS_TERMCAP_me=$(printf "\e[0m")
|
||||||
|
export LESS_TERMCAP_so=$(printf "\e[1;40;32m")
|
||||||
|
export LESS_TERMCAP_se=$(printf "\e[0m")
|
||||||
|
export LESS_TERMCAP_us=$(printf "\e[0;34m")
|
||||||
|
export LESS_TERMCAP_ue=$(printf "\e[0m")
|
||||||
|
|
||||||
|
# Disable virtualenv prompt
|
||||||
|
VIRTUAL_ENV_DISABLE_PROMPT=1
|
67
zshrc
Normal file
67
zshrc
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# Load plugin scripts
|
||||||
|
plugin-load() { source ~/.config/zsh/$1/$1.plugin.zsh }
|
||||||
|
plugin-load zsh-syntax-highlighting
|
||||||
|
plugin-load zsh-history-substring-search
|
||||||
|
|
||||||
|
# Disable sound
|
||||||
|
unsetopt BEEP
|
||||||
|
|
||||||
|
# Remove duplicates from history
|
||||||
|
setopt HIST_IGNORE_ALL_DUPS
|
||||||
|
setopt HIST_REDUCE_BLANKS
|
||||||
|
setopt HIST_SAVE_NO_DUPS
|
||||||
|
|
||||||
|
# Enable multi-terminal history
|
||||||
|
setopt INC_APPEND_HISTORY
|
||||||
|
|
||||||
|
# Enable % escape expansion and substitution in the prompt
|
||||||
|
setopt PROMPT_PERCENT
|
||||||
|
setopt PROMPT_SUBST
|
||||||
|
|
||||||
|
# Disable '<Ctrl>D' to logout
|
||||||
|
setopt IGNORE_EOF
|
||||||
|
|
||||||
|
# Enable comments in the prompt
|
||||||
|
setopt INTERACTIVE_COMMENTS
|
||||||
|
|
||||||
|
# Initialize completions
|
||||||
|
autoload -U compinit
|
||||||
|
compinit
|
||||||
|
|
||||||
|
# Enable prompt themes
|
||||||
|
autoload -Uz promptinit
|
||||||
|
promptinit
|
||||||
|
prompt fresh
|
||||||
|
|
||||||
|
# Enable vi mode
|
||||||
|
bindkey -v
|
||||||
|
|
||||||
|
# Enable yank whole line with 'yy' and yank end of line with 'Y'
|
||||||
|
bindkey -M vicmd 'yy' vi-yank-whole-line
|
||||||
|
bindkey -M vicmd 'Y' vi-yank-eol
|
||||||
|
|
||||||
|
# Enable undo with 'u' and redo with 'U'
|
||||||
|
bindkey -M vicmd 'u' undo
|
||||||
|
bindkey -M vicmd 'U' redo
|
||||||
|
|
||||||
|
# Enable substring history search with 'j' and 'k'
|
||||||
|
bindkey -M vicmd 'k' history-substring-search-up
|
||||||
|
bindkey -M vicmd 'j' history-substring-search-down
|
||||||
|
|
||||||
|
# Replace '<Esc>h' with 'K' to view help
|
||||||
|
bindkey -r '^[h'
|
||||||
|
bindkey -M vicmd 'K' run-help
|
||||||
|
|
||||||
|
# Disable Ex mode with ':'
|
||||||
|
bindkey -rM vicmd ':'
|
||||||
|
|
||||||
|
# Use editor to edit command line with '<Ctrl>V'
|
||||||
|
autoload -U edit-command-line
|
||||||
|
zle -N edit-command-line
|
||||||
|
bindkey -M vicmd '^V' edit-command-line
|
||||||
|
|
||||||
|
# Disable tty flow control, allows vim to use '<Ctrl>S'
|
||||||
|
stty -ixon
|
||||||
|
|
||||||
|
# Remove duplicates from PATH
|
||||||
|
typeset -U PATH
|
Loading…
x
Reference in New Issue
Block a user