-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.aliases
161 lines (130 loc) · 3.67 KB
/
.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
161
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME/'
# vi is shorter to type, actually use the preferred editor (nvim/vim)
if [ -n "$EDITOR" ]; then
alias vi='$EDITOR'
fi
alias vipaste='f=$(mktemp) && vi $f && $EDITOR $f && rm -f $f'
alias sshagent='eval $(ssh-agent) && ssh-add ~/.ssh/id_rsa'
function sharefile {
RHOST="nginx.tre.esav.fi"
RPATH="/var/www/share"
UUID=$(uuidgen)
ssh $RHOST "mkdir $RPATH/$USER/$UUID"
scp $1 $RHOST:$RPATH/$USER/$UUID/
echo "https://share.esav.fi/$USER/$UUID/$(basename $1)"
}
function imgurit {
IMAGES_PATH="Pictures"
file=$(ls -t $IMAGES_PATH/ | head -1)
imgur-uploader "$IMAGES_PATH/$file"
}
temp() {
directory=$(mktemp -d)
cd $directory
rm_cmd="rm -rf $directory"
echo "Running '$rm_cmd' in 7 days"
echo "$rm_cmd" | at "now + 7 days"
}
function eyaml {
if echo $PWD | grep -q "^/home/esav.fi/esa/workspace/puppet/hiera"; then
PUBKEY="/home/esav.fi/esa/workspace/puppet/hiera/keys/public_key.pkcs7.pem"
fi
if echo $PWD | grep -q "^/home/esa/repos/puppet/ppadmin"; then
PUBKEY="/home/esa/repos/puppet/ppadmin/keys/public_key.pkcs7.pem"
fi
if echo $PWD | grep -q "^/home/esa/workspace/puppet/ppadmin"; then
PUBKEY="/home/esa/workspace/puppet/ppadmin/keys/public_key.pkcs7.pem"
fi
if [[ "$1" == "edit" || "$1" == "encrypt" ]]; then
echo "Using pubkey $PUBKEY"
oper=$1; shift
/usr/bin/eyaml $oper --pkcs7-public-key=$PUBKEY "$@"
else
/usr/bin/eyaml "$@"
fi
}
log() {
logfile=~/.worklog
if [ "$1" != "" ]; then
echo "$(date +%s) $@" >> "$logfile"
cat "$logfile" | tail -n 3 | ~/.local/bin/parse_log.py
else
echo "$(date +%s) viewed log" >> "$logfile"
cat "$logfile" | tail -n 15 | ~/.local/bin/parse_log.py
fi
}
alias ssh_no_pubkey='ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no'
alias cal='cal -m'
yaml2jsonnet2() {
yaml2jsonnet "$1" | jsonnetfmt -
}
alias ppnoop='echo puppet agent --test --noop --agent_disabled_lockfile /non/existant'
alias ocadmin='oc --as system:admin'
ssm() {
aws-vault exec $1 -- aws ssm start-session --target $2
}
alias vammassh='ssh -oHostKeyAlgorithms=ssh-rsa'
fcd() {
local results
local count
local target
results="$(find . -name "*$1*")"
if [[ -z "$results" ]]; then
echo "error: no results"
else
count="$(echo "$results" | wc -l)"
if [[ "$count" -gt 1 ]]; then
target="$(echo $results | fzf)"
else
target="$results"
fi
echo "-> $target"
cd "$target"
fi
}
alias sl='exa --git-ignore'
cgkill() {
CG="$(find /sys/fs/cgroup -name "*$1*.scope")"
echo -e "Matched:\n${CG}"
echo "Press enter to kill"; read CONFIRM
echo "$CG" | while read line; do
kill $(cat "${line}/cgroup.procs")
done
}
PATH_prepend() {
local dir
dir="$(mktemp -d)"
if [[ -n "$2" ]]; then
ln -s "$1" "$dir/$2"
else
ln -s "$1" "$dir/${basename $1}"
fi
export PATH=$dir:$PATH
export PROMPT="*$PROMPT"
}
kubeconfig() {
pushd ~/.kube >/dev/null
configs="$(find . -maxdepth 1 -name "*-*" -type f | tr -d './' | sort; echo NONE)"
while [[ "$#" -gt 0 ]]
do
configs="$(echo $configs | grep $1)"
shift
done
if [[ "$(echo $configs | wc -l)" -gt 1 ]]
then
choice="$(echo $configs | fzf)"
if [[ "$choice" == "" ]]
then
echo "Selection canceled"
return 0
fi
else
choice="$configs"
fi
if [[ "$choice" == "NONE" ]]; then
export KUBECONFIG=""
else
export KUBECONFIG="$HOME/.kube/$choice"
fi
popd >/dev/null
}