-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_aliases
154 lines (128 loc) · 4.15 KB
/
bash_aliases
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#
# ~/.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 cdflapa=' cd ~/repos/perso/github.com/hcartiaux/ansible'
alias cdflapt=' 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 --noconfirm $* {}
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"
}