Skip to content

Instantly share code, notes, and snippets.

@behrouze
Last active February 13, 2024 15:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save behrouze/7474a7baa0b321e1382e6c8aafa94d1b to your computer and use it in GitHub Desktop.
Save behrouze/7474a7baa0b321e1382e6c8aafa94d1b to your computer and use it in GitHub Desktop.
my personnal .bash_aliases
# Env Variables
[ $? -eq 0 ] && export LATEST_ALIASES=https://gist.github.com`curl -s https://gist.github.com/behrouze/7474a7baa0b321e1382e6c8aafa94d1b>/dev/null|grep -i raw|cut -d "\"" -f 2|head -1`
export LOG="/var/log"
export NG="/etc/nginx"
export NGA="$NG/sites-available"
export NGE="$NG/sites-enabled"
export WWW="/var/www"
# Nginx
alias log='cd $LOG/nginx && lr'
alias ng='sudo service nginx '
alias nga='cd $NGA'
alias nge='cd $NGE'
alias ngt='sudo nginx -t'
alias ngT='sudo nginx -T|grep -Ev "(^\s*#|^$)"'
alias ngr='ng restart && ng status'
# Folders & Files
alias dls='if [ -d ~/Downloads ]; then cd ~/Downloads; else cd ~/Téléchargements;fi'
alias etc='cd /etc'
alias rand='head -100 /dev/urandom | sha256sum | cut -d '\'' '\'' -f1'
alias src='cd ~/Sources'
alias tmp='cd ~/Tmp'
alias vm='cd ~/VMs'
alias www='cd $WWW && lt'
alias open='xdg-open '
alias cat='batcat $1'
# Listing
alias l='ls -1F'
alias ll='ls -l'
alias la='ls -la'
alias lt='ls -lt'
alias lta='ls -lta'
alias lr='ls -ltr'
alias lra='ls -ltra'
# Git
alias ga='git add . && git status'
alias gb='git branch'
alias gbd='git checkout main && git branch | grep -v '\''main'\'' | xargs git branch -D'\"''
alias gbg='git branch|grep -i $1'
alias gbr='git fetch origin > /dev/null && gb -r|grep -i $1'
alias gc='git checkout $1'
alias gca='git commit --amend'
alias gcm='git checkout main'
alias gcmp='git checkout main && git pull'
alias gl='git log --oneline -n 15 --author=behrouze'
alias glb='git log --oneline --all --graph --decorate $* --author=behrouze'
alias gpf='git push --force --no-verify'
alias grm='git rebase main'
alias gs='git status'
# Dev
alias chrome='google-chrome --remote-debugging-port=9222 --user-data-dir=/home/behrouze/Tmp/Debug > /dev/null &'
alias jest='npx jest --silent $1'
alias jw='npx jest --silent --watch $1'
alias ys='yarn start'
alias yw='yarn watch'
alias dev='npm run dev'
# Docker from linuxserver
alias dcup='docker-compose up -d'
alias dcdown='docker-compose stop'
alias dcpull='docker-compose pull'
alias dclogs='docker-compose logs -tf --tail="50" '
alias dtail='docker logs -tf --tail="50" "$@"'
# Std
alias grep='grep --color=auto' # utiliser \grep ou /bin/grep pour lancer sans les options
alias egrep='grep --extended-regexp '
alias igrep='grep --ignore-case'
# 1 Letters
alias h='history | grep -i $1'
alias r='source ~/.bashrc'
# Misc
alias chw='sudo chown www-data:www-data '
alias chb='sudo chown behrouze '
alias iploc="ip -4 -o -c addr|grep -v 127.0.0.1| awk '/inet / {print \$4}'"
alias ipad=iploc
alias ipadd=iploc
alias ipext='curl ifconfig.me/ip'
alias kn='sudo killall node'
alias net='sudo netstat -t4pln'
alias updatealiases='cd ~; curl -sOL ${LATEST_ALIASES}; cd -'
alias lsnode="curl -s https://nodejs.org/en/ |grep home-downloadbutton|awk -F\" \" '{print \$5 \$6}'"
# Backups
alias notifyBackupFile='echo Backup terminé de $1 à $(date) && notify-send -i face-kiss "Backup OK de ${1}"'
alias backupVm='if [[ -z ${VM} ]];then echo "export VM=";else backupFile; fi'
alias backupFile='export BCKFILE=${VM}_$(date +"%y%m%d-%H%M").tgz;time tar -cv -C ~/VMs ${VM} | pv | pigz -6 -p4 > $BCKFILE && notifyBackupFile $BCKFILE'
alias backupCheck='tar -tvf $(ls -1tr|tail -1) > /dev/null && notify-send -i face-smile-big "BACKUP OK"'
# Special
alias lisa='echo ❤️'
@behrouze
Copy link
Author

TODO: refresh LATEST_ALIASES if this file has been modified during the same shell session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment