Clean up code and improve readability
This commit is contained in:
parent
865a49a0b7
commit
384cbfeb3b
2 changed files with 122 additions and 173 deletions
44
functions
44
functions
|
@ -234,7 +234,7 @@ prompt_create () {
|
|||
}
|
||||
|
||||
################################################################################
|
||||
# Mise à jour automatique à partir du repo distant #
|
||||
# Update checking #
|
||||
################################################################################
|
||||
|
||||
check_rc_update () {
|
||||
|
@ -263,20 +263,6 @@ check_rc_update () {
|
|||
cd $CUR_DIR
|
||||
}
|
||||
|
||||
# Do the update
|
||||
uprc () {
|
||||
RC_PATH=$(dirname "$(readlink -f ${(%):-%x})")
|
||||
cd $RC_PATH
|
||||
git pull --rebase --stat origin master
|
||||
$RC_PATH/install.sh
|
||||
cd - &> /dev/null
|
||||
source $HOME/.zshrc
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Check for system updates #
|
||||
################################################################################
|
||||
|
||||
check_sys_update () {
|
||||
case $(lsb_release -a | awk -F ':\t' '/Distributor ID/{print $2}') in
|
||||
Arch)
|
||||
|
@ -288,3 +274,31 @@ check_sys_update () {
|
|||
echo "update_sys $nb_maj" >> /dev/shm/prompt_msg
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Commands #
|
||||
################################################################################
|
||||
|
||||
# Do the update
|
||||
uprc () {
|
||||
RC_PATH=$(dirname "$(readlink -f ${(%):-%x})")
|
||||
cd $RC_PATH
|
||||
git pull --rebase --stat origin master
|
||||
$RC_PATH/install.sh
|
||||
cd - &> /dev/null
|
||||
source $HOME/.zshrc
|
||||
}
|
||||
|
||||
# Syntax coloration for man
|
||||
man() {
|
||||
env \
|
||||
LESS_TERMCAP_mb="$(printf "%s" "$fg_bold[red]")" \
|
||||
LESS_TERMCAP_md="$(printf "%s" "$fg_bold[red]")" \
|
||||
LESS_TERMCAP_me="$(printf "%s" "$reset_color")" \
|
||||
LESS_TERMCAP_se="$(printf "%s" "$reset_color")" \
|
||||
LESS_TERMCAP_so="$(printf "%s" "$bg[black]$fg[yellow]")" \
|
||||
LESS_TERMCAP_ue="$(printf "%s" "$reset_color")" \
|
||||
LESS_TERMCAP_us="$(printf "%s" "$fg_bold[blue]")" \
|
||||
man "$@"
|
||||
}
|
||||
|
||||
|
|
255
zshrc
255
zshrc
|
@ -9,8 +9,10 @@
|
|||
# adapté et amélioré par lhark
|
||||
|
||||
|
||||
# Ajout de */sbin au PATH (pour ifconfig en particulier)
|
||||
export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin:~/bin
|
||||
export EDITOR=/usr/bin/vim
|
||||
# Prevent mime associations by wine
|
||||
export WINEDLLOVERRIDES="winemenubuilder.exe=d"
|
||||
|
||||
|
||||
# Get rc dir path
|
||||
|
@ -21,11 +23,11 @@ RC_PATH=$(dirname "$(readlink -f ${(%):-%x})")
|
|||
. "$RC_PATH/functions"
|
||||
|
||||
|
||||
# Check for rc updates
|
||||
# Check for rc updates in the background
|
||||
(check_rc_update&) 2> /dev/null
|
||||
|
||||
|
||||
# Check for system updates
|
||||
# Check for system updates inthe background
|
||||
(check_sys_update&) 2> /dev/null
|
||||
|
||||
|
||||
|
@ -41,23 +43,10 @@ export PYTHONPATH=/opt/ros/indigo/lib/python2.7/site-packages:$PYTHONPATH
|
|||
export PKG_CONFIG_PATH="/opt/ros/indigo/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
|
||||
|
||||
# Configuration pour wine
|
||||
alias steam-wine='WINEDEBUG=-all wine ~/.wine/drive_c/Program\ Files/Steam/Steam.exe -no-dwrite >/dev/null 2>&1 &'
|
||||
export WINEDLLOVERRIDES="winemenubuilder.exe=d"
|
||||
###########
|
||||
# Aliases #
|
||||
###########
|
||||
|
||||
# Configuration pour steam sur archlinux
|
||||
alias steam="LD_PRELOAD='/usr/\$LIB/libstdc++.so.6 /usr/\$LIB/libgcc_s.so.1 /usr/\$LIB/libxcb.so.1 /usr/\$LIB/libgpg-error.so' /usr/bin/steam"
|
||||
|
||||
|
||||
# Configuration pour minecraft
|
||||
alias minecraft='java -jar $HOME/.minecraft/launcher.jar'
|
||||
|
||||
|
||||
# Easy dwm recompile on arch
|
||||
alias redwm='cd ~/aur/dwm-git; updpkgsums; makepkg -fi --noconfirm; killall dwm'
|
||||
|
||||
|
||||
# Aliases
|
||||
alias acs='apt-cache search'
|
||||
alias ls='ls --classify --tabsize=0 --literal --color=auto --show-control-chars -h'
|
||||
alias ll='ls -lha'
|
||||
|
@ -74,9 +63,6 @@ alias rm='rm -I'
|
|||
alias ipa='ip route && echo && ip address'
|
||||
alias ipr='ip address && echo && ip route'
|
||||
alias which='which -a'
|
||||
# À tester un jour :)
|
||||
# Reference : man zshbuiltins
|
||||
# alias -s ps=gv
|
||||
# Le fameux cd ...etc
|
||||
alias -g ...='../..'
|
||||
alias -g ....='../../..'
|
||||
|
@ -84,6 +70,12 @@ alias -g .....='../../../..'
|
|||
alias -g ......='../../../../..'
|
||||
alias -g .......='../../../../../..'
|
||||
alias -g ........='../../../../../../..'
|
||||
# Hackish tweaks
|
||||
alias steam-wine='WINEDEBUG=-all wine ~/.wine/drive_c/Program\ Files/Steam/Steam.exe -no-dwrite >/dev/null 2>&1 &'
|
||||
alias pacaur='AURDEST=$HOME/aur pacaur'
|
||||
alias redwm='cd ~/aur/dwm-git; updpkgsums; makepkg -fi --noconfirm; killall dwm'
|
||||
alias minecraft='java -jar $HOME/.minecraft/launcher.jar'
|
||||
alias steam="LD_PRELOAD='/usr/\$LIB/libstdc++.so.6 /usr/\$LIB/libgcc_s.so.1 /usr/\$LIB/libxcb.so.1 /usr/\$LIB/libgpg-error.so' /usr/bin/steam"
|
||||
|
||||
|
||||
# Term specific hacks
|
||||
|
@ -103,74 +95,52 @@ case $TERM in
|
|||
esac
|
||||
|
||||
|
||||
# Demande confirmation pour 'rm *' -> ou
|
||||
unsetopt rm_star_silent
|
||||
|
||||
|
||||
# Si on utilise des jokers dans une liste d'arguments, retire les jokers
|
||||
# qui ne correspondent à rien au lieu de donner une erreur
|
||||
setopt null_glob
|
||||
|
||||
|
||||
# Autocomplétion ?
|
||||
unsetopt list_ambiguous
|
||||
|
||||
|
||||
setopt auto_remove_slash
|
||||
unsetopt glob_dots
|
||||
autoload -U compinit promptinit colors
|
||||
compinit
|
||||
promptinit
|
||||
colors
|
||||
autoload -Uz vcs_info
|
||||
zstyle ':vcs_info:*' enable git cvs svn
|
||||
setopt auto_cd
|
||||
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}'
|
||||
zstyle ':completion:*' max-errors 3 numeric
|
||||
zstyle ':completion:*' use-compctl false
|
||||
|
||||
|
||||
# Traite les liens symboliques comme il faut
|
||||
setopt chase_links
|
||||
|
||||
|
||||
# !! n'est pas exécuté directement
|
||||
setopt hist_verify
|
||||
|
||||
|
||||
# Afficher le temps pris pour exécuter les commandes
|
||||
EXPORTTIME=0
|
||||
|
||||
|
||||
# Points rouges pendant l'autocomplétion
|
||||
COMPLETION_WAITING_DOTS="true"
|
||||
|
||||
|
||||
#Heure="%(!,%{%B$fg[red]%}%D{%a %d/%m} %T%{$reset_color%}%b,%D{%a %d/%m} %T)"
|
||||
|
||||
# Pour recalculer les variables du prompt
|
||||
# Il faut que le signe $ soit échappé ou entre guillemets simples
|
||||
setopt promptsubst
|
||||
prompt_create
|
||||
|
||||
# Raccourcis claviers à la VIM
|
||||
bindkey -v
|
||||
# ou à la emacs
|
||||
# bindkey -e
|
||||
|
||||
# Réglages de l'historique
|
||||
HISTSIZE=100000
|
||||
SAVEHIST=100000
|
||||
HISTFILE=~/.history
|
||||
HISTTIMEFORMAT="%d/%m %H:%M:%S "
|
||||
setopt hist_ignore_all_dups sharehistory hist_ignore_space
|
||||
###############
|
||||
# ZSH options #
|
||||
###############
|
||||
|
||||
unsetopt rm_star_silent # Demande confirmation pour 'rm *' -> ou 'rm patth/*'
|
||||
unsetopt glob_dots # (disabled) Do not require a leading `.' in a filename to be matched explicitly.
|
||||
setopt null_glob # Delete pattern when no match found, instead of erroring
|
||||
# (disabled) If there is an unambiguous prefix to insert on
|
||||
# the command line, that is done without a completion list being displayed
|
||||
#setopt list_ambiguous
|
||||
# >| doit être utilisés pour pouvoir écraser un fichier déjà existant ;
|
||||
# # le fichier ne sera pas écrasé avec '>'
|
||||
#unsetopt clobber
|
||||
setopt auto_remove_slash # Auto remove slash at the end of autocomp when appropriate
|
||||
setopt auto_cd # Perform cd if command is directory and can't be executed
|
||||
setopt chase_links # Traite les liens symboliques comme il faut
|
||||
setopt hist_verify # !! n'est pas exécuté directement
|
||||
setopt promptsubst # Enable prompt substitution: vars are recalculated. you need '$foo'
|
||||
setopt hist_ignore_all_dups # Only keep last version of duplicate command
|
||||
setopt sharehistory # Import new cmds from hist file & append typed cmds
|
||||
setopt hist_ignore_space # Ignore cmds with leading space
|
||||
setopt print_exit_value # Afficher «zsh: exit ERREUR» en cas d'erreur ≠ 0
|
||||
setopt autopushd # cd pushes old dir to dir stack
|
||||
setopt pushdsilent # Silent pushd & popd
|
||||
setopt pushdtohome # pushd = pushd $HOME
|
||||
setopt pushdignoredups
|
||||
setopt pushdminus # This reverts the +/- operators for pushd.
|
||||
setopt extendedglob # Treat `#', `~' and `^' chars as part of patterns for filenames, etc.
|
||||
setopt correct # Provide correction to mistyped commands
|
||||
|
||||
# Afficher «zsh: exit ERREUR» en cas d'erreur ≠ 0
|
||||
setopt print_exit_value
|
||||
EXPORTTIME=0 # (Disabled) Display command execution time
|
||||
COMPLETION_WAITING_DOTS="true" # Display red dots while zsh autocompletes
|
||||
HISTSIZE=10000000
|
||||
SAVEHIST=10000000
|
||||
HISTFILE=~/.history
|
||||
HISTTIMEFORMAT="%d/%m %H:%M:%S "
|
||||
|
||||
|
||||
######################
|
||||
# Completion options #
|
||||
######################
|
||||
|
||||
zstyle ':vcs_info:*' enable git cvs svn
|
||||
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}'
|
||||
zstyle ':completion:*' max-errors 3 numeric
|
||||
zstyle ':completion:*' use-compctl false
|
||||
zstyle ':completion:*' auto-description 'specify: %d'
|
||||
zstyle ':completion:*' completer _expand _complete _correct _approximate
|
||||
zstyle ':completion:*' format 'Completing %d'
|
||||
|
@ -185,9 +155,47 @@ zstyle ':completion:*' menu select=long
|
|||
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
|
||||
zstyle ':completion:*' use-compctl false
|
||||
zstyle ':completion:*' verbose true
|
||||
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
||||
# Des couleurs pour la complétion cf kill -9 <tab><tab>
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors "=(#b) #([0-9]#)*=36=31"
|
||||
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
|
||||
zstyle ':mime:*' mailcap /etc/mailcap
|
||||
# video/*; /usr/bin/mplayer '%s';
|
||||
# text/*; less '%s';
|
||||
# audio/*; /usr/bin/mplayer '%s';
|
||||
# Crée un cache des complétion possibles
|
||||
# très utile pour les complétion qui demandent beaucoup de temps
|
||||
# comme la recherche d'un paquet aptitude install moz<tab>
|
||||
zstyle ':completion:*' use-cache on
|
||||
zstyle ':completion:*' cache-path ~/.zs
|
||||
|
||||
|
||||
######################
|
||||
# Load ZSH functions #
|
||||
######################
|
||||
|
||||
zmodload zsh/complist
|
||||
autoload -U compinit promptinit colors
|
||||
compinit
|
||||
promptinit
|
||||
colors
|
||||
autoload -Uz vcs_info
|
||||
autoload -U zsh-mime-setup
|
||||
autoload -U zsh-mime-handler
|
||||
zsh-mime-setup
|
||||
|
||||
|
||||
###################
|
||||
# Prompt creation #
|
||||
###################
|
||||
|
||||
prompt_create
|
||||
|
||||
|
||||
##################
|
||||
# Keyboard setup #
|
||||
##################
|
||||
|
||||
bindkey -v # Vim type keybinds for ZLE (line editing)
|
||||
|
||||
# Gestion des touches spéciales pour mon clavier
|
||||
# Pour connaître le code d'une touche, exécuter «cat»
|
||||
|
@ -218,79 +226,6 @@ bindkey "[3~" delete-char
|
|||
# Shift-Tab
|
||||
bindkey "^[[Z" 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
|
||||
function zle-line-init () {
|
||||
printf '%s' "${terminfo[smkx]}"
|
||||
}
|
||||
function zle-line-finish () {
|
||||
printf '%s' "${terminfo[rmkx]}"
|
||||
}
|
||||
zle -N zle-line-init
|
||||
zle -N zle-line-finish
|
||||
fi
|
||||
|
||||
# # Stockage des dossiers visités (cd -NUM et dir -v)
|
||||
# DIRSTACKFILE="$HOME/.cache/zsh/dirs"
|
||||
# if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
|
||||
# dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
|
||||
# [[ -d $dirstack[1] ]] && cd $dirstack[1]
|
||||
# fi
|
||||
# chpwd() {
|
||||
# print -l $PWD ${(u)dirstack} >>$DIRSTACKFILE
|
||||
# }
|
||||
DIRSTACKSIZE=20
|
||||
|
||||
setopt autopushd pushdsilent pushdtohome
|
||||
|
||||
# Remove duplicate entries
|
||||
setopt pushdignoredups
|
||||
|
||||
# This reverts the +/- operators.
|
||||
setopt pushdminus
|
||||
autoload -U zsh-mime-setup
|
||||
autoload -U zsh-mime-handler
|
||||
zsh-mime-setup
|
||||
zstyle ':mime:*' mailcap /etc/mailcap
|
||||
# video/*; /usr/bin/mplayer '%s';
|
||||
# text/*; less '%s';
|
||||
# audio/*; /usr/bin/mplayer '%s';
|
||||
export EDITOR=/usr/bin/vim
|
||||
|
||||
# Crée un cache des complétion possibles
|
||||
# très utile pour les complétion qui demandent beaucoup de temps
|
||||
# comme la recherche d'un paquet aptitude install moz<tab>
|
||||
zstyle ':completion:*' use-cache on
|
||||
zstyle ':completion:*' cache-path ~/.zs
|
||||
|
||||
# Des couleurs pour la complétion cf kill -9 <tab><tab>
|
||||
zmodload zsh/complist
|
||||
setopt extendedglob
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors "=(#b) #([0-9]#)*=36=31"
|
||||
setopt correct
|
||||
|
||||
# Syntax coloration for man
|
||||
man() {
|
||||
env \
|
||||
LESS_TERMCAP_mb="$(printf "%s" "$fg_bold[red]")" \
|
||||
LESS_TERMCAP_md="$(printf "%s" "$fg_bold[red]")" \
|
||||
LESS_TERMCAP_me="$(printf "%s" "$reset_color")" \
|
||||
LESS_TERMCAP_se="$(printf "%s" "$reset_color")" \
|
||||
LESS_TERMCAP_so="$(printf "%s" "$bg[black]$fg[yellow]")" \
|
||||
LESS_TERMCAP_ue="$(printf "%s" "$reset_color")" \
|
||||
LESS_TERMCAP_us="$(printf "%s" "$fg_bold[blue]")" \
|
||||
man "$@"
|
||||
}
|
||||
# source ~/.zs/zsh-syntax-highlighting.zsh
|
||||
# exec 2>>(while read line; do
|
||||
# print '\e[91m'${(q)line}'\e[0m' > /dev/tty; print -n $'\0'; done &)
|
||||
# Totalement indispensable mais tellemnent chiant que je l'ai viré au bout de 2
|
||||
# heures :)
|
||||
# if [ $HOST != "sinquin" ]; then
|
||||
# (play -q -n synth sine F2 sine C3 remix - fade 0 4 .1 norm -4 bend
|
||||
# 0.5,2399,2 fade 0 4.0 0.5 &)
|
||||
# fi
|
||||
|
||||
# ZSH syntax highlighting : /!\ keep at the bottom !
|
||||
source "${RC_PATH}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
||||
|
|
Loading…
Reference in a new issue