[ADD] Zsh configuration files
This commit is contained in:
parent
942b21b71d
commit
23f6ab4c12
2
zsh/.zprofile
Normal file
2
zsh/.zprofile
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# Avoid duplication
|
||||||
|
source .profile
|
53
zsh/.zsh_prompt
Normal file
53
zsh/.zsh_prompt
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
# get current status of git repo
|
||||||
|
function __prompt_parse_git_dirty() {
|
||||||
|
git_status=$(git status 2>&1 | tee)
|
||||||
|
dirty=$(echo -n "${git_status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?")
|
||||||
|
untracked=$(echo -n "${git_status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?")
|
||||||
|
ahead=$(echo -n "${git_status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?")
|
||||||
|
newfile=$(echo -n "${git_status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?")
|
||||||
|
renamed=$(echo -n "${git_status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?")
|
||||||
|
deleted=$(echo -n "${git_status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?")
|
||||||
|
bits=''
|
||||||
|
if [ ${renamed} -eq 0 ]; then
|
||||||
|
bits=">${bits}"
|
||||||
|
fi
|
||||||
|
if [ ${ahead} -eq 0 ]; then
|
||||||
|
bits="*${bits}"
|
||||||
|
fi
|
||||||
|
if [ ${newfile} -eq 0 ]; then
|
||||||
|
bits="+${bits}"
|
||||||
|
fi
|
||||||
|
if [ ${untracked} -eq 0 ]; then
|
||||||
|
bits="?${bits}"
|
||||||
|
fi
|
||||||
|
if [ ${deleted} -eq 0 ]; then
|
||||||
|
bits="x${bits}"
|
||||||
|
fi
|
||||||
|
if [ ${dirty} -eq 0 ]; then
|
||||||
|
bits="!${bits}"
|
||||||
|
fi
|
||||||
|
if [ -z "$bits" ]; then
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo " ${bits}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# get current branch in git repo
|
||||||
|
function __prompt_parse_git_branch() {
|
||||||
|
git_branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
|
||||||
|
if [ -z "${git_branch}" ]; then
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
git_stat=$(__prompt_parse_git_dirty)
|
||||||
|
echo "[${git_branch}${git_stat}]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display return value only when non-zero
|
||||||
|
function __prompt_nonzero_return() {
|
||||||
|
RETVAL=$?
|
||||||
|
[ $RETVAL -ne 0 ] && echo "[$RETVAL]"
|
||||||
|
}
|
||||||
|
|
||||||
|
PS1='[%F{green}%n%f@%F{blue}%m%f %F{cyan}%B%~%b%f]'$'\e[36m''`__prompt_parse_git_branch`'$'\e[0m\n42sh$ '
|
94
zsh/.zshrc
Executable file
94
zsh/.zshrc
Executable file
|
@ -0,0 +1,94 @@
|
||||||
|
# History configuration
|
||||||
|
HISTFILE=~/.zhistory
|
||||||
|
HISTSIZE=10000
|
||||||
|
SAVEHIST=10000
|
||||||
|
|
||||||
|
# Allow for command substitution in PS1 to have a common prompt with bash
|
||||||
|
setopt promptsubst
|
||||||
|
# Append to history to avoid losing commands when multiple shells are open
|
||||||
|
setopt appendhistory
|
||||||
|
# Show an error when a globbing expansion doesn't find any match
|
||||||
|
setopt nomatch
|
||||||
|
# List on ambiguous completion and Insert first match immediately
|
||||||
|
setopt autolist menucomplete
|
||||||
|
# Don't add duplicates nor commands starting with a space to the history
|
||||||
|
setopt histignoredups histignorespace
|
||||||
|
# Use pushd when cd-ing around
|
||||||
|
setopt autopushd pushdminus pushdsilent
|
||||||
|
# Use single quotes in string without the weird escape tricks
|
||||||
|
setopt rcquotes
|
||||||
|
# Single word commands can resume an existing job
|
||||||
|
setopt autoresume
|
||||||
|
# Those options aren't wanted
|
||||||
|
unsetopt autocd beep extendedglob notify
|
||||||
|
|
||||||
|
# Use the emacs keybindings
|
||||||
|
bindkey -e
|
||||||
|
|
||||||
|
# Completion configuration
|
||||||
|
zstyle :compinstall filename '/home/ambroisie/.zshrc'
|
||||||
|
autoload -Uz compinit
|
||||||
|
compinit
|
||||||
|
|
||||||
|
# Import my profile on interactive shells
|
||||||
|
source ~/.profile
|
||||||
|
|
||||||
|
# Import my aliases
|
||||||
|
source ~/.aliases
|
||||||
|
|
||||||
|
# Import some useful functions
|
||||||
|
source ~/.functions
|
||||||
|
|
||||||
|
# Enable Shift-Tab to go backwards in completion list
|
||||||
|
bindkey '^[[Z' reverse-menu-complete
|
||||||
|
|
||||||
|
# Style the completion a bit
|
||||||
|
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
||||||
|
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
|
||||||
|
|
||||||
|
## add colors to processes for kill completion
|
||||||
|
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
||||||
|
|
||||||
|
# match uppercase from lowercase
|
||||||
|
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
|
||||||
|
|
||||||
|
# Filename suffixes to ignore during completion (except after rm command)
|
||||||
|
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' \
|
||||||
|
'*?.old' '*?.pro'
|
||||||
|
|
||||||
|
# command for process lists, the local web server details and host completion
|
||||||
|
# on processes completion complete all user processes
|
||||||
|
zstyle ':completion:*:processes' command 'ps -au$USER'
|
||||||
|
|
||||||
|
# Completion formatting and messages
|
||||||
|
zstyle ':completion:*' verbose yes
|
||||||
|
zstyle ':completion:*:descriptions' format '%B%d%b'
|
||||||
|
zstyle ':completion:*:messages' format '%d'
|
||||||
|
zstyle ':completion:*:warnings' format 'No matches for: %d'
|
||||||
|
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
|
||||||
|
|
||||||
|
# SSH Completion
|
||||||
|
zstyle ':completion:*:scp:*' tag-order \
|
||||||
|
files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
|
||||||
|
zstyle ':completion:*:scp:*' group-order \
|
||||||
|
files all-files users hosts-domain hosts-host hosts-ipaddr
|
||||||
|
zstyle ':completion:*:ssh:*' tag-order \
|
||||||
|
users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
|
||||||
|
zstyle ':completion:*:ssh:*' group-order \
|
||||||
|
hosts-domain hosts-host users hosts-ipaddr
|
||||||
|
|
||||||
|
# Hostname completion
|
||||||
|
# 1. All /etc/hosts hostnames are in autocomplete
|
||||||
|
# 2. If you have a comment in /etc/hosts like #%foobar.domain,
|
||||||
|
# then foobar.domain will show up in autocomplete!
|
||||||
|
zstyle ':completion:*' hosts $(awk '/^[^#]/ {print $2 $3" "$4" "$5}' /etc/hosts \
|
||||||
|
| grep -v ip6- && grep "^#%" /etc/hosts | awk -F% '{print $2}')
|
||||||
|
|
||||||
|
# fish-like syntax high-lighting for interactive commands
|
||||||
|
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||||
|
|
||||||
|
# Display the computer's name in ASCII art
|
||||||
|
cat /etc/issue
|
||||||
|
|
||||||
|
# import my prompt
|
||||||
|
source ~/.zsh_prompt
|
Loading…
Reference in a new issue