1
0
Fork 0
mirror of https://github.com/hcartiaux/dotfiles.git synced 2024-10-18 17:25:23 +02:00
dotfiles/bash/bash_aliases
2021-11-11 11:52:28 +01:00

111 lines
3 KiB
Bash

#
# ~/.bash_aliases
#
# ----------------------------------------------------------------------
# LS COLORS
# ----------------------------------------------------------------------
# we always pass these to ls(1)
LS_COMMON="-F --group-directories-first -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 --color"
else
LS_COMMON="$LS_COMMON -G"
fi
elif [ "$UNAME" = Linux ]; then
LS_COMMON="$LS_COMMON --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 cdansible='~/repos/work/gitlab.uni.lu/Ansible/control-repo'
alias cdpuppet=' ~/repos/work/gitlab.uni.lu/Puppet/control-repo'
alias cdstor=' ~/repos/work/gitolite.hpc/storage-repo'
alias cdsys=' ~/repos/work/gitlab.uni.lu/ULHPC/sysadmins'
alias cdwww=' ~/repos/work/gitlab.uni.lu/www/ulhpc'
alias cdtools=' ~/repos/work/gitlab.uni.lu/ULHPC/ulhpc-tools'
alias cdslurm=' ~/repos/work/gitlab.uni.lu/ULHPC/slurm'
alias cddocs=' ~/repos/work/gitlab.uni.lu/ULHPC/documents'
alias cdslides=' ~/repos/work/gitlab.uni.lu/ULHPC/slides'
alias cdreport=' ~/repos/work/gitlab.uni.lu/ULHPC/reporting'
alias cdtut=' ~/repos/work/github.com/ULHPC/tutorials'
alias cdpass=' ~/repos/work/gitolite.hpc/passwords-repo'
export PASSWORD_STORE_DIR=~/repos/work/gitolite.hpc/passwords-repo
export PASSWORD_STORE_SIGNING_KEY=1A53FD6E09A44DBA7A9FD72B5D08BCDD4F156AD7
g5kpass() {
curdir="$(pwd)"
cd ~/repos/work/gitlab.inria.fr/grid5000/password5k
source .passrc && /usr/bin/pass $*
cd "$curdir"
}