# # ~/.bash_aliases # # ---------------------------------------------------------------------- # LS COLORS # ---------------------------------------------------------------------- # we always pass these to ls(1) LS_COMMON="-F -h" if [ "$UNAME" = Darwin ]; then # check if you're using gnu core-utils then use --color if [[ "$(which ls)" == "/opt/local/bin/ls" ]]; then LS_COMMON="$LS_COMMON --group-directories-first --color" else LS_COMMON="$LS_COMMON -G" fi elif [ "$UNAME" = Linux ]; then LS_COMMON="$LS_COMMON --group-directories-first --color" fi # setup the main ls alias if we've established common args test -n "$LS_COMMON" && alias ls="command ls $LS_COMMON" # these use the ls aliases above alias ll="ls -l" alias la="ll -a" alias l.="ls -d .*" alias lh='la -h' # ---------------------------------------------------------------------- # ALL ALIASES # ---------------------------------------------------------------------- if [ "$UNAME" = Linux ]; then alias grep='grep --color=auto' fi alias vi='vim' alias bim='vim' # Mandatory aliases to confirm destructive operations alias cp='cp -iv' alias mv='mv -iv' alias rm='rm -i' # Fast cd op alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias .....='cd ../../../..' alias ......='cd ../../../../..' # Use most instead of less if available [ -x /usr/bin/most ] && alias more='most' && alias less='most' [ -x /usr/bin/htop ] && alias top='htop' # read man with colors man() { env LESS_TERMCAP_mb=$'\E[01;31m' \ LESS_TERMCAP_md=$'\E[01;38;5;74m' \ LESS_TERMCAP_me=$'\E[0m' \ LESS_TERMCAP_se=$'\E[0m' \ LESS_TERMCAP_so=$'\E[38;5;246m' \ LESS_TERMCAP_ue=$'\E[0m' \ LESS_TERMCAP_us=$'\E[04;38;5;146m' \ man "$@" } # print a line as wide as the terminal line() { printf %${COLUMNS}s | tr " " "=" } # make a backup of a file # https://github.com/grml/grml-etc-core/blob/master/etc/zsh/zshrc cpold() { cp -a "$1" "${1}_$(date --iso-8601=seconds)" } # personnal desktop aliases alias ssha="ssh-add" # Git aliases alias cdroot='git rev-parse && cd ./$(git rev-parse --show-cdup)' alias cdnbsdna=' cd ~/repos/perso/github.com/hcartiaux/ansible' alias cdnbsdnt=' cd ~/repos/perso/github.com/hcartiaux/terraform' alias cdudocs=' cd ~/repos/work/github.com/ULHPC/ulhpc-docs' alias cdtut=' cd ~/repos/work/github.com/ULHPC/tutorials' alias cdslurm=' cd ~/repos/work/hpc-git.uni.lu/ULHPC/slurm' alias cdpuppet=' cd ~/repos/work/hpc-git.uni.lu/ULHPC/puppet' alias cdansible='cd ~/repos/work/hpc-git.uni.lu/ULHPC/ansible-aion' alias cdsys=' cd ~/repos/work/hpc-git.uni.lu/ULHPC/sysadmins' alias cdwiki=' cd ~/repos/work/hpc-git.uni.lu/ULHPC/sysadmins.wiki' alias cdtools=' cd ~/repos/work/hpc-git.uni.lu/ULHPC/ulhpc-tools' alias cddocs=' cd ~/repos/work/hpc-git.uni.lu/ULHPC/documents' alias cdstor=' cd ~/repos/work/hpc-git.uni.lu/ULHPC/storage-repo' alias cdpass=' cd ~/repos/work/hpc-git.uni.lu/ULHPC/passwords-repo' alias cdwww=' cd ~/repos/work/gitlab.com/uniluxembourg/hpc/www/ulhpc-2.0' pass() { export PASSWORD_STORE_DIR=~/repos/work/hpc-git.uni.lu/ULHPC/passwords-repo export PASSWORD_STORE_SIGNING_KEY=62C5D78FE715CF7CA974B5AF37183CEF550DF40B /usr/bin/pass $* } g5kpass() { curdir="$(pwd)" cd ~/repos/work/gitlab.inria.fr/grid5000/password5k unset PASSWORD_STORE_SIGNING_KEY source .passrc && /usr/bin/pass $* export GNUPGHOME=~/.gnupg cd "$curdir" } # ---------------------------------------------------------------------- # Archlinux utils # ---------------------------------------------------------------------- sysupd() { reflector --ipv6 -c de,fr,nl,lu -p https -n 30 -l 30 | sudo tee /etc/pacman.d/mirrorlist yay -Syu $* } sysclean() { pacman -Qtdq | xargs -I {} sudo pacman -Rns {} yes | sudo pacman -Scc } pkgbuild_up() { [[ ! -f PKGBUILD ]] && exit 1 version=$1 sed -i "s/^pkgver=.*$/pkgver=$VERSION/" PKGBUILD updpkgsums makepkg --printsrcinfo >! .SRCINFO } pkgbuild_chroot() { [[ ! -f PKGBUILD ]] && exit 1 CHROOT=~/chroot mkdir -p "$CHROOT" mkarchroot "$CHROOT/root" base-devel makechrootpkg -c -r "$CHROOT" } pkgbuild_commit() { [[ ! -f PKGBUILD ]] && exit 1 version=$1 git commit -m "Update to $VERSION" }