2012-10-13 00:50:27 +02:00
|
|
|
#!/bin/zsh
|
|
|
|
|
|
|
|
autoload -U colors && colors
|
|
|
|
autoload -Uz vcs_info
|
|
|
|
|
2013-01-31 13:23:07 +01:00
|
|
|
autoload -z edit-command-line
|
|
|
|
zle -N edit-command-line
|
|
|
|
|
2012-10-13 00:50:27 +02:00
|
|
|
#-----------------#
|
|
|
|
# Auto-completion #
|
|
|
|
#-----------------#
|
2013-08-22 18:01:20 +02:00
|
|
|
# https://github.com/zsh-users/zsh-completions
|
2019-04-15 13:57:19 +02:00
|
|
|
[ -d "$HOME/.config/zsh/zsh-completions/src" ] && fpath=($HOME/.config/zsh/zsh-completions/src $fpath)
|
2013-08-22 18:01:20 +02:00
|
|
|
|
2019-04-08 18:26:37 +02:00
|
|
|
autoload -Uz compinit && compinit -d $ZCOMPDUMP
|
2013-08-22 18:01:20 +02:00
|
|
|
|
|
|
|
autoload -U bashcompinit
|
|
|
|
bashcompinit
|
|
|
|
|
2021-10-29 09:30:53 +02:00
|
|
|
[ -f "$HOME/.config/tea/autocomplete.zsh" ] && PROG=tea _CLI_ZSH_AUTOCOMPLETE_HACK=1 source $HOME/.config/tea/autocomplete.zsh
|
|
|
|
|
2012-10-13 00:50:27 +02:00
|
|
|
# Display a message when no match
|
|
|
|
#zstyle ':completion:*:warnings' format 'No matches for: %d'
|
|
|
|
|
2019-04-25 13:10:26 +02:00
|
|
|
# Try first simple completion and, if that generates no matches, case-insensitive completion
|
|
|
|
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
|
|
|
|
|
2012-10-13 00:50:27 +02:00
|
|
|
# Ignore completion functions for commands you don't have:
|
|
|
|
zstyle ':completion:*:functions' ignored-patterns '_*'
|
|
|
|
|
|
|
|
# Use a cache for slow functions (_dpkg, _apt, ...)
|
|
|
|
zstyle ':completion:*' use-cache on
|
2019-04-15 13:58:09 +02:00
|
|
|
zstyle ':completion:*' cache-path $XDG_CACHE_HOME/zsh
|
2012-10-13 00:50:27 +02:00
|
|
|
|
|
|
|
# Ignore filenames already on the command line
|
|
|
|
zstyle ':completion:*:rm:*' ignore-line yes
|
|
|
|
|
|
|
|
# cd will never select the parent directory (e.g.: cd ../<TAB>):
|
|
|
|
zstyle ':completion:*:cd:*' ignore-parents parent pwd
|
|
|
|
# If you end up using a directory as argument, this will remove the trailing slash (usefull in ln)
|
|
|
|
zstyle ':completion:*' squeeze-slashes true
|
|
|
|
|
|
|
|
# Completing process IDs with menu selection
|
|
|
|
zstyle ':completion:*:*:killall:*' menu yes select
|
|
|
|
zstyle ':completion:*:killall:*' force-list always
|
|
|
|
zstyle ':completion:*:*:kill:*' menu yes select
|
|
|
|
zstyle ':completion:*:kill:*' force-list always
|
|
|
|
|
|
|
|
#---------------------#
|
|
|
|
# VCS infos in prompt #
|
|
|
|
#---------------------#
|
|
|
|
zstyle ':vcs_info:*' enable git svn hg
|
|
|
|
zstyle ':vcs_info:git*' formats " (%s.%b) "
|
|
|
|
zstyle ':vcs_info:hg*' formats " (%s.%b) "
|
|
|
|
|
2013-08-16 17:56:51 +02:00
|
|
|
#----------------------------------------------#
|
|
|
|
# Options activation #
|
|
|
|
# http://www.cs.elte.hu/zsh-manual/zsh_16.html #
|
|
|
|
#----------------------------------------------#
|
2012-10-13 00:50:27 +02:00
|
|
|
setopt hist_ignore_all_dups
|
|
|
|
setopt hist_ignore_space
|
2019-05-10 08:48:30 +02:00
|
|
|
setopt INC_APPEND_HISTORY
|
2012-10-13 00:50:27 +02:00
|
|
|
setopt extended_history
|
|
|
|
|
|
|
|
setopt complete_in_word
|
|
|
|
# move cursor to end of line when completing in the middle
|
|
|
|
setopt always_to_end
|
|
|
|
# spelling correction of commands
|
|
|
|
setopt correct
|
|
|
|
setopt hist_verify
|
|
|
|
setopt interactive_comments
|
|
|
|
|
|
|
|
setopt extendedglob
|
|
|
|
setopt autocd
|
|
|
|
setopt nobeep
|
|
|
|
|
|
|
|
setopt prompt_subst
|
|
|
|
|
2013-08-16 17:56:51 +02:00
|
|
|
setopt nullglob
|
|
|
|
setopt autopushd
|
|
|
|
|
2012-10-13 00:50:27 +02:00
|
|
|
#----------#
|
|
|
|
# VIM mode #
|
|
|
|
#----------#
|
|
|
|
bindkey -v
|
2013-01-31 13:23:07 +01:00
|
|
|
bindkey -M vicmd v edit-command-line
|
2012-10-13 00:50:27 +02:00
|
|
|
|
|
|
|
# Affiche le mode (normal ou insert) dans le prompt de droite
|
|
|
|
function zle-line-init zle-keymap-select
|
|
|
|
{
|
|
|
|
RPS1="${${KEYMAP/vicmd/-N-}/(main|viins)/-I-}"
|
|
|
|
RPS2=$RPS1
|
|
|
|
zle reset-prompt
|
|
|
|
}
|
|
|
|
zle -N zle-line-init
|
|
|
|
zle -N zle-keymap-select
|
|
|
|
|
|
|
|
if [ $(whoami) = "root" ]
|
|
|
|
then
|
2019-07-05 14:53:04 +02:00
|
|
|
COLOR="red"
|
2013-02-21 17:16:13 +01:00
|
|
|
else
|
2019-07-05 14:53:04 +02:00
|
|
|
colors=(blue green cyan magenta yellow)
|
|
|
|
color_index=$(($(hostname | sum | cut -f1 -d" ") % $#colors + 1))
|
|
|
|
|
|
|
|
COLOR=$colors[$color_index]
|
2012-10-13 00:50:27 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
export PS1='%m%{$fg[$COLOR]%}:%{$reset_color%}%~${vcs_info_msg_0_}%{$fg[$COLOR]%}%#%{$reset_color%} '
|
|
|
|
export PS2="%_> "
|
|
|
|
|
|
|
|
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
|
|
|
|
export LESS_TERMCAP_md=$'\E[01;31m' # begin bold
|
|
|
|
export LESS_TERMCAP_me=$'\E[0m' # end mode
|
|
|
|
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin standout-mode
|
|
|
|
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
|
|
|
|
export LESS_TERMCAP_us=$'\E[01;32m' # begin underline
|
|
|
|
export LESS_TERMCAP_ue=$'\E[0m' # end underline
|
|
|
|
|
|
|
|
precmd() {
|
|
|
|
vcs_info
|
|
|
|
}
|
|
|
|
preexec() { }
|
|
|
|
|
|
|
|
#-------#
|
|
|
|
# Alias #
|
|
|
|
#-------#
|
|
|
|
alias vi='vim'
|
|
|
|
alias mv='mv -i'
|
2019-04-08 18:27:11 +02:00
|
|
|
alias tmux="tmux -2 -f $XDG_CONFIG_HOME/tmux/tmux.conf"
|
2012-10-13 00:50:27 +02:00
|
|
|
alias mv_p='rsync --progress --remove-source-files -h'
|
2019-04-15 14:01:24 +02:00
|
|
|
alias rsync-to-ntfs='rsync -rltDuv --modify-window=1'
|
2012-10-13 00:50:27 +02:00
|
|
|
alias ls='ls --color=auto'
|
2019-04-15 14:01:24 +02:00
|
|
|
alias poweroff='sudo poweroff'
|
2012-12-21 18:52:23 +01:00
|
|
|
alias xephyr-dualscreen='Xephyr -ac -br -noreset -screen 800x600 -screen 800x600 :1& sleep 3; DISPLAY=:1; setxkbmap fr bepo'
|
|
|
|
alias xephyr-onescreen='Xephyr -ac -br -noreset -screen 800x600 :1& sleep 3; DISPLAY=:1; setxkbmap fr bepo'
|
2013-08-22 18:01:20 +02:00
|
|
|
alias be='bundle exec'
|
2014-07-07 14:46:19 +02:00
|
|
|
alias git-count="gawk '{ add += \$1 ; subs += \$2 ; loc += \$1 - \$2 } END { printf \"added lines: %s, removed lines : %s, total lines : %s\n\", add, subs, loc }\' -"
|
2019-04-15 14:01:24 +02:00
|
|
|
alias subdl="subdl --output={m}.{L}.{S}"
|
2012-10-13 00:50:27 +02:00
|
|
|
|
2018-09-03 10:00:49 +02:00
|
|
|
## Docker ##
|
|
|
|
alias dcb='docker-compose build'
|
|
|
|
alias dcu='docker-compose up'
|
|
|
|
alias dcr='docker-compose run app'
|
|
|
|
alias dcrestart='docker-compose restart app'
|
|
|
|
|
2012-10-13 00:50:27 +02:00
|
|
|
alias -s pdf=zathura
|
|
|
|
alias -s ps=gv
|
|
|
|
alias -s dvi=xdvi
|
2013-11-08 10:52:15 +01:00
|
|
|
alias -s avi=mpv
|
|
|
|
alias -s mkv=mpv
|
|
|
|
alias -s mp4=mpv
|
|
|
|
alias -s webm=mpv
|
|
|
|
alias -s mp3=mpv
|
2012-10-13 00:50:27 +02:00
|
|
|
alias -s png=feh
|
|
|
|
alias -s jpg=feh
|
|
|
|
alias -s gif=feh
|
|
|
|
|
|
|
|
#-----------------#
|
|
|
|
# Other functions #
|
|
|
|
#-----------------#
|
|
|
|
function rpass() {
|
|
|
|
cat /dev/urandom | tr -cd '[:graph:]' | head -c ${1:-12}
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
function utime() {
|
|
|
|
date -d "1970-01-01 GMT $1 seconds";
|
|
|
|
}
|
|
|
|
function confirm() {
|
|
|
|
echo -n "$1 [Yn]? "; read reply;
|
|
|
|
case $reply in
|
|
|
|
N*|n*) false ;;
|
|
|
|
*) true ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
function send_infocmp() {
|
|
|
|
REMOTE=$1
|
|
|
|
infocmp rxvt-unicode-256color | ssh $REMOTE "mkdir -p .terminfo && cat >/tmp/ti && tic /tmp/ti"
|
|
|
|
}
|
2012-11-22 14:13:15 +01:00
|
|
|
|
2017-04-06 14:24:53 +02:00
|
|
|
function fake_git() {
|
|
|
|
TIME=$1; shift
|
|
|
|
DATE=$(date +"%a %b %d $TIME:%S %Y %z")
|
|
|
|
|
|
|
|
GIT_COMMITTER_DATE=$DATE git commit --date=$DATE "$@"
|
|
|
|
}
|
|
|
|
|
2018-06-07 10:55:25 +02:00
|
|
|
source /usr/share/chruby/chruby.sh
|
|
|
|
source /usr/share/chruby/auto.sh
|