-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_aliases
160 lines (135 loc) · 4.55 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
155
156
157
158
159
160
alias ls='ls --color=auto --group-directories-first'
alias l="ls -l"
alias ll="ls -l"
alias svim="sudo -E vim"
alias g='git'
alias s='/usr/bin/subl3'
alias sfab='fab --skip-bad-hosts --hide=status,running'
alias pfab='fab --skip-bad-hosts --hide=status,running --set=output_prefix=""'
alias vpnup='nmcli con up id globalundo.com'
alias vpndown='nmcli con down id globalundo.com'
alias takeover='tmux detach -a'
alias i='ipython'
alias ipython='ipython --no-confirm-exit --pprint --no-banner'
alias p='puppet'
alias pat='puppet agent --test'
#alias patn='puppet agent --test --noop'
alias r='ranger'
alias b='xbacklight -set '
alias idk='echo "¯\_(ツ)_/¯"'
alias shrug='echo "¯\_(ツ)_/¯"'
alias fp='echo "(ლ‸-)"'
alias bman='man --html=x-www-browser'
function rsync_link {
echo $(hostname -f):$(readlink -m $1)
}
function whatthediff {
grep -E '^[<>]' /tmp/jenkins-diffs/* | python -c "from sys import stdin; print '\n'.join([ ''.join( _.split(':')[1:]).strip() for _ in stdin.readlines() ])" | sort -n | uniq
}
# Populate remote server with dotfiles
function dotfiles-sync {
if [ ! -z "$1" ]; then
builtin cd > /dev/null
rsync -az -R $(sed 's/^/--exclude /g' .dotfiles-exclude | tr '\n' ' ') --no-implied-dirs $(cat .dotfiles-sync | tr '\n' ' ') .dotfiles-sync $1:
builtin cd - > /dev/null
fi
}
function lcpaperssh {
#let's abuse LC_PAPER
LC_PAPER=$(cat ~/.dotfiles-etag 2>/dev/null || echo "") /usr/bin/ssh $@
}
if [ -z "$SSH_CONNECTION" ];
then
function ssh {
dotfiles-sync $@ >/dev/null 2>&1; lcpaperssh $@
}
fi
function sn {
case "$1" in
git)
X=$(git show --pretty="format:" --name-only $2)
[ $? -eq 0 ] && /usr/bin/subl3 -n $X
;;
*)
/usr/bin/subl3 -n "$@"
;;
esac
}
function man {
if [ "$TERM" = 'linux' ]; then
env \
LESS_TERMCAP_mb=$(printf "\e[34m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[30;43m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[32m") \
/usr/bin/man "$@"
else
env \
LESS_TERMCAP_mb=$(printf "\e[1;34m") \
LESS_TERMCAP_md=$(printf "\e[38;5;9m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[30;43m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[38;5;10m") \
/usr/bin/man "$@"
fi
}
function cd {
if builtin cd "$@" 2>/dev/null; then
ll -a
else
builtin cd $( echo "$@" | sed 's/\([^\/]\)/\1*/g' ) && ll -a
fi
}
function party {
# http://rcr.io/words/gdynamic-xterm-colors.html
type -p bc > /dev/null
if [ $? -ne 0 ]; then
echo 'no bc = no party'
else
A=0; F="0.1"
while true; do
[ $A == 628318 ] && A=0 || A=$((A + 1))
R=$(echo "s ($F*$A + 0)*127 + 128" | bc -l | cut -d'.' -f1)
B=$(echo "s ($F*$A + 2)*127 + 128" | bc -l | cut -d'.' -f1)
G=$(echo "s ($F*$A + 4)*127 + 128" | bc -l | cut -d'.' -f1)
printf "\033]10;#%02x%02x%02x\007" $R $B $G
sleep 0.01
done
fi
}
function git_remove_biggest_files {
# fetch the list of sha of git blobs which are not present in the HEAD patchset (top 100)
for big_object_sha in $(git verify-pack -v .git/objects/pack/pack-*.idx | egrep "^\w+ blob\W+[0-9]+ [0-9]+ [0-9]+$" | sort -k 3 -n -r | head -n 100 | awk '{print $1}');
do
# translate blob sha into filepath
for big_file in $(
git log "$@" --pretty=format:'%T %h %s' \
| while read tree commit subject ; do
git ls-tree -r $tree | grep "$big_object_sha" | awk '{print $NF}';
done | sort -n | uniq
);
do
# remove file from git history
git filter-branch --index-filter "git rm --cached --ignore-unmatch -- --all $big_file" -f -- --all $(git rev-list --max-parents=0 HEAD)..HEAD;
done
done
# cleanup reflog
git reflog expire --expire=now --all
git gc --prune=now --aggressive
echo 'You might want to run "git push --all -f", but beware of dragons!'
}
function ptmux {
tmux new "parallel_ssh"
}
function patn {
if [ ! -z "$1" ]; then
puppet agent --test --noop --environment "$1"
else
puppet agent --test --noop
fi
}