-
Notifications
You must be signed in to change notification settings - Fork 0
/
alias
88 lines (74 loc) · 2.04 KB
/
alias
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
# -*- mode: sh -*-
# vi:syntax=sh
alias ls="ls -v --color=tty"
alias vi="vim"
alias gwww="gcc -Wall -Wextra -Werror"
alias g+="g++ -Wall -Wextra -Werror"
alias myalias="cat ~/.alias"
alias py="python"
alias rb="ruby"
alias lls="ls"
alias sl="ls"
alias check="grep -rni --exclude-dir='node_modules' --exclude-dir='vendor' --exclude-dir='.terraform' . -e "
alias date="gdate"
alias zen="curl https://api.github.com/zen"
alias pubip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="sudo ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'"
# Same keybinding as on MacOS
# cat file.txt | pbcopy
if [[ "$(uname)" == "Linux" ]]; then
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
fi
loop() {
nb=$1
shift
for ((i = 0; i < $nb; i++)); do $@; done
}
function cdl() {
cd $1
ls $2
}
# Hexadecimal to decimal
h2d() {
echo "ibase=16; $@" | bc
}
# Decimal to Hex
d2h() {
echo "obase=16; $@" | bc
}
##################################
# Docker Aliases #
##################################
alias dck="docker"
alias dckc="docker-compose"
alias dckm="docker-machine"
alias dckdel="docker rm -f \$(docker ps -aq)"
alias dckclr="docker rmi -f \$(docker images -q --filter 'dangling=true')"
dckirssi() {
docker run --rm -it --name dckirssi \
-e TERM \
-u $(id -u):$(id -g) \
--log-driver=none \
-v $HOME/.irssi:/home/user/.irssi:ro \
irssi
}
dckweechat() {
docker run --rm -it --name dckweechat \
-v $DOTFILES/weechat:/home/guest/.weechat \
fstab/weechat-otr
}
###################################
# JWT Parsing #
###################################
_decode_base64_url() {
local len=$((${#1} % 4))
local result="$1"
if [ $len -eq 2 ]; then result="$1"'=='
elif [ $len -eq 3 ]; then result="$1"'='
fi
echo "$result" | tr '_-' '/+' | base64 -d
}
# $1 => JWT to decode
# $2 => either 1 for header or 2 for body (default is 2)
decode_jwt() { _decode_base64_url $(echo -n $1 | cut -d "." -f ${2:-2}) | jq .; }