Use long option name

This commit is contained in:
Jeremy Gardais 2023-07-21 09:55:15 +02:00
parent f6d8dfd620
commit a227d02a2c
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 68 additions and 71 deletions

137
zshrc
View File

@ -28,18 +28,18 @@ if [ ! $(command -v exa) ]; then
## with ls {{{
alias ll='ls -l'
## Show hidden files
alias la='ll -A'
alias la='ll --almost-all'
## Show hidden only
alias lla='la --directory .*'
alias l.='ls -d .*'
alias llh='ll -l | head'
alias llm='ll -l | $PAGER'
alias llw='ls | wc -l'
alias l.='ls --directory .*'
alias llh='ll | head'
alias llp='ll | $PAGER'
alias llw='ll | wc --lines'
## Sort by date
alias lll='ls -l -t -h -r'
alias llll='ls -l -t -h -r'
alias lld='ls -l -d */ -h'
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'''
alias lll='ls -l -t --human-readable --reverse'
alias llll='ls -l -t --human-readable --reverse'
alias lld='ls -l --directory */ --human-readable'
alias lr='ls --recursive | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'''
## }}}
## with exa {{{
else
@ -48,29 +48,29 @@ else
alias la='ll --all --sort .name'
## Show hidden only
alias lla='ll --list-dirs .*'
alias l.='ls -d .*'
alias l.='ls --directory .*'
alias llh='ll | head'
alias llm='ll | less'
alias llw='ls | wc -l'
alias llp='ll | $PAGER'
alias llw='ll | wc --lines'
## Sort by date
alias lll='ll --sort=modified'
alias llll='ll --sort=modified'
## Give a tree of current directory
alias llt='ll --tree'
alias lld='ll --group-directories-first'
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'''
alias lr='ls --recursive | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'''
## }}}
fi
# }}}
# cat with number on output lines
alias ca='cat -n'
alias ca='cat --number'
# docker related
alias d='docker'
# Correct ip command
alias ipa='ip a'
# less with raw character
alias less='less -r'
alias less='less --rawcontrolchars'
#alias less='less --quiet'
# Call last command
alias pp='fc -e -'
@ -101,7 +101,6 @@ if [ ${USER} != "root" ]; then
alias si='sudo iptables -L -vn '
alias sj='sudo journalctl '
alias sn='sudo nft list ruleset'
alias sp='sudo puppet agent -t '
alias sv='sudo vi '
alias sz='sudo zsh'
else
@ -111,7 +110,6 @@ else
alias si='iptables -L -vn '
alias sj='journalctl '
alias sn='nft list ruleset'
alias sp='puppet agent -t '
alias vi='vi -S ~/.vim/vimrc '
alias sv='vi -S ~/.vim/vimrc '
fi
@ -149,23 +147,23 @@ if [ -d /etc/apt ]; then
alias asho='aptitude show'
alias aver='apt-show-versions'
alias awhy='aptitude why'
alias insexperimental='sudo aptitude -t experimental install'
alias insexperimental='sudo aptitude --target-release experimental install'
fi
# }}}
# Grep aliases {{{
alias grep='grep --color=always -i '
alias gerp='grep -i'
alias grep='grep --color=always --ignore-case '
alias gerp='grep --ignore-case'
alias Grep='\grep '
alias gdpkg='dpkg -l | grep -E -- '
alias gmount='mount | grep -E -- '
alias gdf='df | grep -E -- '
alias gdpkg='dpkg --list | grep --extended-regexp -- '
alias gmount='mount | grep --extended-regexp -- '
alias gdf='df | grep --extended-regexp -- '
# }}}
# Espace disque
alias df='df -kTh'
alias dus='du -ch|sort -h'
alias dua='du -ach|sort -h'
alias df='df --block-size=1K --print-type --human-readable'
alias dus='du --total --human-readable | sort --human-numeric-sort'
alias dua='du --all --total --human-readable | sort --human-numeric-sort'
alias ncdu='gdu'
# Gestion des processus:
@ -175,10 +173,10 @@ if [ ! -f "`which htop`" ]; then
fi
# Qu'est-ce qui consomme de la mémoire vive sur le système
alias wotgobblemem='ps -o time,ppid,pid,nice,pcpu,pmem,user,comm -A | sort -n -k 6 | tail -15'
alias wotgobblemem='ps -o time,ppid,pid,nice,pcpu,pmem,user,comm -A | sort --numeric-sort --key=6 | tail -15'
# ps aliases
alias px='ps faux|grep -v grep|grep -iE -e VSZ -e '
alias px='ps faux|grep --inverse-match -- grep|grep --extended-regexp --ignore-case --regexp=VSZ -e '
## ps with fzf
alias fpx="ps -ef | fzf --bind 'ctrl-r:reload(ps -ef)' --header 'Press CTRL-R to reload' --header-lines=1 --color fg:188,bg:233,hl:103,fg+:222,bg+:234,hl+:104"
alias pxf="ps -ef | fzf --bind 'ctrl-r:reload(ps -ef)' --header 'Press CTRL-R to reload' --header-lines=1 --color fg:188,bg:233,hl:103,fg+:222,bg+:234,hl+:104"
@ -187,11 +185,10 @@ alias wps="watch \"ps faux | tail --lines=30 -- | grep --invert-match --extended
alias psw="watch \"ps faux | tail --lines=30 -- | grep --invert-match --extended-regexp '(tail|ps faux|grep)' --\""
# Décompression
alias untargz='tar -zxvf'
alias untarbz2='tar -jxvf'
alias untargz='tar --gzip --extract --verbose -f'
alias untarbz2='tar --bzip2 --extract --verbose -f'
# Terminal multiplexer
alias ci='screen -x ssh || screen -c ~/.screen/scr.ssh_ci'
alias ta='tmux a || tmux'
alias td='tmux detach'
@ -220,8 +217,8 @@ alias ggmv='git mv'
### Cancel changes
alias ggcheckout='git checkout --'
### Print lines matching a pattern
alias ggrep='git grep --color -n -P'
alias gggrep='git grep --color -n -P'
alias ggrep='git grep --color --line-number --perl-regexp'
alias gggrep='git grep --color --line-number --perl-regexp'
### Show commit logs
alias gglog="git log --graph --full-history --all --color --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
### Show last 20 commits with graph
@ -229,7 +226,7 @@ alias gglg="git --no-pager log --graph --pretty=tformat:'%Cred%h%Creset -%C(auto
### Show all commits with graph
alias ggllg="git log --graph --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ar)%Creset'"
### Display all commits/changes of a file
alias ggchanges="git log --follow -p --"
alias ggchanges="git log --follow --perl-regexp --"
### Commands that might require a valid gpg-agent
#### Download any new commits
@ -244,24 +241,24 @@ alias ggpush='load-gpg-agent && git push'
## }}}
# Lister les fichiers de configuration inutiles
alias purge='grep-status -n -sPackage -FStatus config-files'
alias purge='grep-status --no-field-names --show-field=Package --field=Status config-files'
## Piped alias
alias -g H='| head'
alias -g T='tail -f'
alias -g G='| grep -v grep | grep -E'
alias -g T='tail --follow'
alias -g G='| grep --invert-match grep -- | grep --extended-regexp'
alias -g L='| less'
alias -g M="| most"
alias -g S="| sort"
alias -g V="| vimmanpager"
alias -g W="| wc -l"
alias -g W="| wc --lines"
alias -g X="| xclip -selection clipboard"
alias -g TM="| tmux load-buffer -- -"
alias -g B="&|"
alias -g HL="--help"
alias -g MM="2>&1 | most"
alias -g MM="2>&1 | most"
alias -g LL="2>&1 | less"
alias -g CA="2>&1 | cat -A"
alias -g CA="2>&1 | cat --show-all"
alias -g NE="2> /dev/null"
alias -g NUL="> /dev/null 2>&1"
@ -290,7 +287,7 @@ alias uu='cd -'
# Afficher la pile des dossiers:
alias dirs='dirs -v'
# Créer les répertoires précédents si ils n'existent pas
alias mkdir='mkdir -p'
alias mkdir='mkdir --parents'
# Affiche l'arborescence du répertoire courant
#alias tree="find . | sed 's/[^/]*\//| /g;s/| *\([^| ]\)/+--- \1/'"
#La commande tree "basique" fait ça très bien ...
@ -364,9 +361,9 @@ alias ktel='khard phone'
## 2. with recossh alias to load a new ssh-agent
function load-ssh-agent() {
# If a ssh-key is available
if find "${HOME}/.ssh" -maxdepth 1 -type f -iname "id_*" | grep -q -- .; then
if find "${HOME}/.ssh" -maxdepth 1 -type f -iname "id_*" | grep --quiet -- .; then
## If ssh-agent is not already launched
if ! ps -x | grep -v grep | grep -Fq -- "ssh-agent -a ${SSH_AGENT_SOCK}"; then
if ! ps -x | grep --invert-match -- grep | grep --fixed-strings --quiet -- "ssh-agent -a ${SSH_AGENT_SOCK}"; then
### Remove any previous socket and environment files
rm --force -- "${SSH_AGENT_SOCK}" "${SSH_AGENT_ENV}"
### Start ssh-agent with a specified socket path
@ -383,7 +380,7 @@ function load-ssh-ed25519() {
# If a ED25519 ssh-key is available
# AND not already loaded in ssh-agent
if [ -f "${SSH_ED25519_KEY}" ] &&
! ssh-add -l | grep -qi -- "(ed25519)"; then
! ssh-add -l | grep --quiet --ignore-case -- "(ed25519)"; then
ssh-add "${SSH_ED25519_KEY}"
fi
}
@ -393,7 +390,7 @@ function load-ssh-rsa() {
# If a RSA ssh-key is available
# AND not already loaded in ssh-agent
if [ -f "${SSH_RSA_KEY}" ] &&
! ssh-add -l | grep -qi -- "(rsa)"; then
! ssh-add -l | grep --quiet --ignore-case -- "(rsa)"; then
ssh-add "${SSH_RSA_KEY}"
fi
}
@ -498,7 +495,7 @@ function tadel() {
# }}}
# Get task's description
tadel_task_desc=$(task "${tadel_task_id}" | sed -n "s/^Description *\(.*\)/\1/p")
tadel_task_desc=$(task "${tadel_task_id}" | sed --quiet "s/^Description *\(.*\)/\1/p")
printf '%b' "Delete the task \"${MAGENTAB}${tadel_task_id} ${tadel_task_desc}${RESET}\" [Y/n] ? "
read -r tadel_confirmation
@ -545,7 +542,7 @@ function tadone() {
# }}}
# Get task's description
tadone_task_desc=$(task "${tadone_task_id}" | sed -n "s/^Description *\(.*\)/\1/p")
tadone_task_desc=$(task "${tadone_task_id}" | sed --quiet "s/^Description *\(.*\)/\1/p")
printf '%b' "Mark the task \"${MAGENTAB}${tadone_task_id} ${tadone_task_desc}${RESET}\" as done [Y/n] ? "
read -r tadone_confirmation
@ -627,7 +624,7 @@ function tanote() {
# }}}
# Get task's description
tanote_task_desc=$(task "${tanote_task_id}" | sed -n "s/^Description *\(.*\)/\1/p")
tanote_task_desc=$(task "${tanote_task_id}" | sed --quiet "s/^Description *\(.*\)/\1/p")
printf '%b' "Add notes to \"${MAGENTAB}${tanote_task_id} ${tanote_task_desc}${RESET}\" task [Y/n] ? "
read -r tanote_confirmation
@ -757,7 +754,7 @@ function tidouble() {
# }}}
# Get task's description from all task of this year
tidouble_task_desc=$(timew summary :year :ids | sed -n "s/.*@\(${tidouble_task_id} .*\)/\1/p" | sed 's/ */ /g')
tidouble_task_desc=$(timew summary :year :ids | sed --quiet "s/.*@\(${tidouble_task_id} .*\)/\1/p" | sed 's/ */ /g')
printf '%b' "Add ${tidouble_extra_time} to \"${MAGENTAB}${tidouble_task_desc}${RESET}\" [Y/n] ? "
read -r tidouble_confirmation
@ -798,7 +795,7 @@ function tirm() {
# }}}
# Get task's description from all task of this year
tirm_task_desc=$(timew summary :year :ids | sed -n "s/.*@\(${tirm_task_id} .*\)/\1/p" | sed 's/ */ /g')
tirm_task_desc=$(timew summary :year :ids | sed --quiet "s/.*@\(${tirm_task_id} .*\)/\1/p" | sed 's/ */ /g')
printf '%b' "Delete to \"${MAGENTAB}${tirm_task_desc}${RESET}\" [Y/n] ? "
read -r tirm_confirmation
@ -851,10 +848,10 @@ function tistart() {
# }}}
# Get time tracking's description from all time tracking of this year
tistart_time_desc=$(timew summary :year :ids | sed -n "s/.*@\(${tistart_time_id} .*\)/\1/p" | sed 's/ */ /g')
tistart_time_desc=$(timew summary :year :ids | sed --quiet "s/.*@\(${tistart_time_id} .*\)/\1/p" | sed 's/ */ /g')
# Get time tracking's start day from all time tracking
tistart_time_start_day=$(timew export | sed -nE "s/^\{\"id\":${tistart_time_id},\"start\":\"([0-9]{4})([0-9]{2})([0-9]{2})T.*end.*/\1-\2-\3/p")
tistart_time_start_day=$(timew export | sed --quiet --regexp-extended "s/^\{\"id\":${tistart_time_id},\"start\":\"([0-9]{4})([0-9]{2})([0-9]{2})T.*end.*/\1-\2-\3/p")
# Check or ask for new start time {{{
if [ -z "${tistart_time_new_start}" ]; then
@ -921,10 +918,10 @@ function tiend() {
# }}}
# Get time tracking's description from all time tracking of this year
tiend_time_desc=$(timew summary :year :ids | sed -n "s/.*@\(${tiend_time_id} .*\)/\1/p" | sed 's/ */ /g')
tiend_time_desc=$(timew summary :year :ids | sed --quiet "s/.*@\(${tiend_time_id} .*\)/\1/p" | sed 's/ */ /g')
# Get time tracking's start day from all time tracking
tiend_time_start_day=$(timew export | sed -nE "s/^\{\"id\":${tiend_time_id},\"start\":\"([0-9]{4})([0-9]{2})([0-9]{2})T.*end.*/\1-\2-\3/p")
tiend_time_start_day=$(timew export | sed --quiet --regexp-extended "s/^\{\"id\":${tiend_time_id},\"start\":\"([0-9]{4})([0-9]{2})([0-9]{2})T.*end.*/\1-\2-\3/p")
# Check or ask for new end time {{{
if [ -z "${tiend_time_new_end}" ]; then
@ -990,7 +987,7 @@ function tiduration() {
# }}}
# Get time tracking's description from all time tracking of this year
tiduration_time_desc=$(timew summary :year :ids | sed -n "s/.*@\(${tiduration_time_id} .*\)/\1/p" | sed 's/ */ /g')
tiduration_time_desc=$(timew summary :year :ids | sed --quiet "s/.*@\(${tiduration_time_id} .*\)/\1/p" | sed 's/ */ /g')
# Check or ask for new end time {{{
if [ -z "${tiduration_time_new_duration}" ]; then
@ -1051,10 +1048,10 @@ function timove() {
# }}}
# Get task's description from all task of this month
timove_time_desc=$(timew summary :month :ids | sed -n "s/.*@\(${timove_time_id} .*\)/\1/p" | sed 's/ */ /g')
timove_time_desc=$(timew summary :month :ids | sed --quiet "s/.*@\(${timove_time_id} .*\)/\1/p" | sed 's/ */ /g')
# Get time tracking's start day from all time tracking
timove_time_start_day=$(timew export | sed -nE "s/^\{\"id\":${timove_time_id},\"start\":\"([0-9]{4})([0-9]{2})([0-9]{2})T.*end.*/\1-\2-\3/p")
timove_time_start_day=$(timew export | sed --quiet --regexp-extended "s/^\{\"id\":${timove_time_id},\"start\":\"([0-9]{4})([0-9]{2})([0-9]{2})T.*end.*/\1-\2-\3/p")
# Check or ask for new start time {{{
if [ -z "${timove_time_new_start}" ]; then
@ -1199,7 +1196,7 @@ function meteo {
if command -v curl > /dev/null; then
curl http://fr.wttr.in/${*}
elif command -v wget > /dev/null; then
wget -qO- http://wttr.in/${*}
wget --quiet --output-document=- http://wttr.in/${*}
else
printf '%b' "Please ${REDB}install one of this tools :${RESET} curl or wget.\n"
fi
@ -1228,10 +1225,10 @@ alias -s gif='mirage '
alias -s mp4='smplayer '
alias -s avi='smplayer '
alias -s flv='smplayer '
alias -s log='tail -f'
alias -s log='tail --follow'
alias -s conf='vim '
alias -s gz='gunzip '
alias -s bz2='tar -xjvf'
alias -s bz2='bzip2'
#######################################
@ -1257,7 +1254,7 @@ function bonjour() {
if [ $(command -v bash_quote) ] && [ $(command -v cowsay) ]; then
if [ $MODULO_MIN -eq 0 ]; then
#echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +"%H"` h `date +"%M"` | cowsay -f $(/bin/ls /usr/share/cowsay/cows -1 | head -n $(expr $$$(date +%s) % $(ls /usr/share/cowsay/cows | wc -w) + 1) | tail -n 1)
command bash_quote | cowsay -f $(/bin/ls /usr/share/cowsay/cows -1 | head -n $(expr $$$(date +%s) % $(ls /usr/share/cowsay/cows | wc -w) + 1) | tail -n 1)
command bash_quote | cowsay -f $(/bin/ls /usr/share/cowsay/cows -1 | head -n $(expr $$$(date +%s) % $(ls /usr/share/cowsay/cows | wc --words) + 1) | tail --lines=1)
else
#echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +"%H"` h `date +"%M"` | ponythink
command bash_quote | ponythink
@ -1268,7 +1265,7 @@ function bonjour() {
}
##Affiche quelques statistiques à propos de l'ordinateur
alias stat_sys="echo ' ' && uname -a && echo ' '&& uptime &&echo ' '&& df && echo ' '"
alias stat_sys="echo ' ' && uname --all && echo ' '&& uptime &&echo ' '&& df && echo ' '"
#####################################
#####FONCTIONS
@ -1285,7 +1282,7 @@ function mkcd() {
#liste les alias et functions
function listalias(){
cat /etc/zsh/zshrc | egrep "alias|function" | grep -v "^#" | $PAGER
cat /etc/zsh/zshrc | egrep "alias|function" | grep --invert-match "^#" -- | $PAGER
}
# Get real address behind a shorten URL {{{
@ -1361,7 +1358,7 @@ function lowercase()
##Capture d'écran
function printscreen()
{
scrot -s -e 'gimp $f ; rm -rf $f'
scrot --select --exec 'gimp $f ; rm --recursive --force -- $f'
}
@ -1379,7 +1376,7 @@ function pdflatex()
# On supprime le fichier pdf si il est présent
if [ -f "${pdf}" ]; then
rm -rf "${pdf}"
rm --recursive --force -- "${pdf}"
fi
# Si le répertoire temporaire n'existe pas, on le crée
@ -1392,7 +1389,7 @@ function pdflatex()
/usr/bin/pdflatex -output-directory ${temp_dir} $1
# On place le fichier pdf qui est dans le répertoire temporaire dans le répertoire courant
mv -f "${temp_dir}"/*.pdf .
mv --force -- "${temp_dir}"/*.pdf .
}
#Éteint un pc sous windows à distance
@ -1415,7 +1412,7 @@ function calc()
# Afficher le code retour de la commande précédente
function cmd_status {
local exit_code=$? # exit code of command
local count=$(jobs | wc -l) # no. of background jobs
local count=$(jobs | wc --lines) # no. of background jobs
# Report no. of background jobs if >0
if [ $count -gt 0 ]; then
@ -1603,7 +1600,7 @@ function decrypt()
# Traduire en français avec Gogole:
function tradfr()
{
wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=${*}&sl=auto&tl=fr" | sed 's/\[\[\[\"//' | cut -d \" -f 1
wget --user-agent="Mozilla/5.0" --quiet --output-document=- "http://translate.google.com/translate_a/t?client=t&text=${*}&sl=auto&tl=fr" | sed 's/\[\[\[\"//' | cut --delimiter=\" --fields=1
}
# Traduire du français à l'anglais avec Gogole:
@ -1979,7 +1976,7 @@ zstyle ':completion:*:*:cd:*' tag-order local-directories path-directories
## Complétion des commandes ssh avec le contenu du fichier ~/.ssh/config et le contenu de host
#local HOSTS
#[[ -f ~/.ssh/config ]] && HOSTS=(`sed -n \'s/^Host \(.*\)/\1/p\' ~/.ssh/config`)
#[[ -f ~/.ssh/config ]] && HOSTS=(`sed --quiet \'s/^Host \(.*\)/\1/p\' ~/.ssh/config`)
#if [ -f ~/.ssh/config ]; then
#HOSTS=(`grep ^Host ~/.ssh/config | sed s/Host\ // | egrep -v ^\*$`)
#fi
@ -2494,7 +2491,7 @@ dexec() {
container_id=$(docker container ls --quiet --filter=name="${container_name}")
printf "%b\n" "Try to enter to Docker container (named : ${container_name})"
docker exec -it "${container_id:-/dev/null}" "${1:-bash}"
docker exec --interactive --tty -- "${container_id:-/dev/null}" "${1:-bash}"
}
# }}}