-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathservers
More file actions
29 lines (23 loc) · 845 Bytes
/
servers
File metadata and controls
29 lines (23 loc) · 845 Bytes
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
servers_conf="${HOME}/etc/servers.conf"
# format is - alias:user:host:[protocol]:[port]:[shell]
load_servers()
{
debug_sh=""
rm -f /tmp/servers.$$
rm -f /tmp/ls.$$
sed 's/^[ \t]*//' "${servers_conf}" | grep -v -e "^$" -e "^#" > /tmp/ls.$$
cat "/tmp/ls.$$" | while read -r _line; do
test -n "$debug_sh" && echo "l = $_line"
echo "$_line" | awk -F: '{
if (length($1) && length($2) && length($3) && length($4)) {
printf("alias %s=\"%s %s@%s", $1, $4, $2, $3) ;
if (length($6)) { printf(" -c \\\"%s\\\"\"\n", $6); } else {
printf("\"\n");
}
} }' >> /tmp/servers.$$
done
rm -f /tmp/ls.$$
source /tmp/servers.$$ && rm -f /tmp/servers.$$
}
load_servers
# vim:ft=sh:ts=4:sts=4:et:ai:syntax=bash