-
Notifications
You must be signed in to change notification settings - Fork 1
/
foorc
78 lines (63 loc) · 1.55 KB
/
foorc
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
# vim: filetype=bash
alias vim="nvim"
tm() {
# Get the current directory name
session_name=$(basename "$PWD")
# Check if a tmux session with the current directory name exists
if tmux has-session -t "$session_name" 2>/dev/null; then
# If it exists, attach to the session
tmux attach-session -t "$session_name"
else
# If it doesn't exist, create a new session with that name
tmux new-session -s "$session_name"
fi
}
sshz_hosts() {
echo $(cat ~/.ssh/config* | grep 'Host ' | grep -v '*' | sed 's/^Host //' | fzf)
}
sshz() {
endpoint=$(sshz_hosts)
echo $endpoint
ssh $endpoint
}
sshz_install() {
if [ -f $1 ]; then
key=$1
endpoint=$(sshz_hosts)
echo $key
echo $endpoint
ssh-copy-id -i $key $endpoint
else
echo "Please specify a key file as your argument"
return
fi
}
sshz_install() {
if [ -n "$1" ] && [ -f $1 ]; then
key=$1
endpoint=$(sshz_hosts)
echo $key
echo $endpoint
ssh-copy-id -i $key $endpoint
else
echo "Please specify a key file as your argument"
return
fi
}
sshz_remove() {
if [ -n "$1" ] && [ -f $1 ]; then
key=$1
endpoint=$(sshz_hosts)
echo $key
echo $endpoint
KEY_ESCAPED=$(printf "$(cat $key)\n" | sed -e 's/[\/&]/\\&/g')
echo $ESCAPED_REPLACE
echo "BEFORE"
ssh $endpoint "cat .ssh/authorized_keys" | sed "s/$KEY_ESCAPED//g"
echo "HERE WE GO"
ssh $endpoint "cat .ssh/authorized_keys" | sed "s/$KEY_ESCAPED//g"
else
echo "Please specify a key file as your argument"
return
fi
}