This commit is contained in:
Olivier 2023-12-05 18:08:18 +01:00
parent 49c913fb71
commit 1b85629d5a

View File

@ -0,0 +1,236 @@
{# Updated: 2023-12-05 #}
# master: {{ common_mastering }}
# updated: {{ ansible_date_time.date }}
# -----------------------------------------------------------------------------
# ZSH TWEAKS
# -----------------------------------------------------------------------------
# ------------------------------
# ALIASES
# ------------------------------
# Privileged access
if (( UID != 0 )); then
alias sudo='sudo '
alias scat='sudo cat'
alias svim='sudoedit'
alias root='sudo -i'
alias reboot='sudo systemctl reboot'
alias poweroff='sudo systemctl poweroff'
alias update='sudo apt update'
alias netctl='sudo netctl'
fi
## Safety features
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -I' # 'rm -i' prompts for every file
# btrfs cow
alias cp='cp -i --reflink=auto'
# safer alternative w/ timeout, not stored in history
alias rm=' timeout 3 rm -Iv --one-file-system'
alias ln='ln -i'
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
alias cls=" echo -ne '\033c'" # clear screen for real (it does not work in Terminology)
## Make Bash error tolerant
alias :q=' exit'
alias :Q=' exit'
alias :x=' exit'
alias cd..='cd ..'
# process using web
alias ports='lsof -i -n -P'
# make parent directory if needed
alias mkdir='mkdir -p'
# quit, exit & reboot
alias :q='exit'
alias oust="echo 'bye $USER...'; sleep 2s && systemctl poweroff"
alias comeback="echo 'be back right now...'; sleep 2s && systemctl reboot"
# Modified commands
alias diff='colordiff' # requires colordiff package
alias grep='grep --color=auto'
alias more='less'
alias df='df -h'
alias du='du -c -h'
alias mkdir='mkdir -p -v'
alias nano='nano -w'
alias ping='ping -c 5'
alias dmesg='dmesg -HL'
## New commands
alias da="date '+%A, %B %d, %Y [%T]'"
alias du1='du --max-depth=1'
alias hist='history | grep' # requires an argument
alias openports='ss --all --numeric --processes --ipv4 --ipv6'
alias pgg='ps -Af | grep' # requires an argument
alias ..='cd ..'
alias x=exit
# changes directories
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias .3='...'
alias .4='....'
alias .5='.....'
# handy short cuts
alias h='history'
alias j='jobs -l'
# date /time
alias path='echo -e ${PATH//:/\\n}'
alias now="date +'%T'"
alias nowtime=now
alias nowdate="date +'%d-%m-%Y'"
## pass options to free ##
alias free='free -h'
alias meminfo='free -m -l -t'
## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
## Resume wget by default
alias wget='wget -c'
# better 'top'
alias top='htop'
# screen default resume
alias screen='screen -R'
alias sr='screen'
# listings
alias ll='ls -lha'
alias lo='ls -o'
alias lh='ls -lh'
alias la='ls -la'
alias sl='ls'
alias l='ls'
alias s='ls'
alias lt='ls -laptr' #oldest first sort
alias labc='ls -lap' #alphabetical sort
## ls
alias ls='ls -hFX --color=auto --group-directories-first'
alias lr='ls -RhFX --color=auto --group-directories-first'
alias ll='ls -lhFXa --color=auto --group-directories-first'
alias la='ll -AhFX --color=auto --group-directories-first'
alias lx='ll -BXhFX --color=auto --group-directories-first' # sort by extension
alias lz='ll -rShFX --color=auto --group-directories-first' # sort by size
alias lt='ll -rthFX --color=auto --group-directories-first' # sort by date
alias lm='la | more'
# Git related
alias gs='git status'
alias gc='git commit'
alias ga='git add'
alias gd='git diff'
alias gb='git branch'
alias gl='git log'
alias gsb='git show-branch'
alias gco='git checkout'
alias gg='git grep'
alias gk='gitk --all'
alias gr='git rebase'
alias gri='git rebase --interactive'
alias gcp='git cherry-pick'
alias grm='git rm'
# packages
alias pacman='sudo pacman'
alias remove='pacman -R'
alias update='pacman -Syy'
alias upgrade='pacman -Syu && yay'
alias install='pacman -S --needed'
alias installed='pacman -Q'
#alias update='sudo powerpill -Syy'
#alias upgrade='sudo powerpill -Syu'
#alias install='sudo powerpill -S --needed'
# performances analysis
alias analyze='systemd-analyze'
alias blame='systemd-analyze blame'
alias criticalchain='systemd-analyze critical-chain'
alias plot='systemd-analyze plot > /tmp/boot.analysis.svg && chmod 0777 /tmp/boot.analysis.svg'
# systemctl
alias ssysctl='sudo systemctl'
alias status='ssysctl status'
alias running='ssysctl list-units'
alias failed='ssysctl --failed'
alias units='ssysctl list-unit-files'
alias start='ssysctl start'
alias stop='ssysctl stop'
alias restart='ssysctl restart'
alias reload='ssysctl reload'
alias status='ssysctl status'
alias enable='ssysctl enable'
alias disable='ssysctl disable'
alias activate='enable --now'
alias mask='ssysctl mask'
alias unmask='ssysctl unmask'
alias help='ssysctl help'
alias daemonreload='ssysctl daemon-reload'
alias reboot='ssysctl reboot'
alias poweroff='ssysctl poweroff'
alias suspend='ssysctl suspend'
alias hibernate='ssysctl hibernate'
alias sleep='ssysctl hybrid-sleep'
alias reenable='ssysctl reenable'
alias revert='ssysctl revert'
alias targets='running --type=target'
alias enabled='units |grep enabled'
alias disabled='units |grep disabled'
alias jobs='ssysctl list-jobs'
# journald
alias journal='sudo journalctl'
alias boot='journal -b'
alias pid='journal _PID='
alias follow='journal -f'
alias kernel='journal -k'
alias unit='journal -u'
alias jeca='journal -p err..alert'
alias jreload='reload systemd-journald.service'
alias jauth='journal SYSLOG_FACILITY=10'
alias since='journal --since'
alias today="journalsince 'yesterday'"
alias j1h="journalsince '60 minutes ago'"
alias j15m="journal --since '15 minutes ago'"
alias j30m="journal --since '30 minutes ago'"
alias kernelboot='journal -k -b -1'
alias boots='journal --list-boots'
alias entries20='journal -n 20'
# exports
export EDITOR='nano'
export BROWSER='surf'
export PAGER='most'
export CC="colorgcc"
# path
export PATH="/usr/lib/ccache:$PATH"
export CCACHE_PATH='/usr/bin'
export CCACHE_DIR=/mnt/build
export BUILDDIR=/mnt/build
# vm
NPROC=$(nproc)