-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsshh
executable file
·56 lines (52 loc) · 1.63 KB
/
sshh
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
#!/bin/sh
# Copyright (C) Alexander Kozhevnikov <[email protected]> 2015-05-06;
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public Licence as published by
# the Free Software Foundation, either version 3 of the licence or,
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for details.
#
# You should've received a copy of the GNU General Public License
# with this program. If not, see <http://www.gnu.org/licences/>,
# or write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330 Boston MA 02111-1307 USA.
case $ZSH_VERSION in ?*) alias -g '${1+"$@"}="$@"'; esac
args=`esceval ${1+"$@"}`
while :
do
case $# in 0) break; esac
case $1 in
--)
shift
id=$1
break
;;
-*)
;;
*)
id=$1
break
esac
shift
done
mkdir -p ~/.ssh_history || return 1
# Windows does not support colons in filenames. ISO8601 allows for time to be
# specified with or without colons, so we drop colons on Windows.
case `uname` in
*_NT*)
timestamp=`date -Is | sed s/://g`
# If you wanted you could use a "look-alike" character for the colon instead,
# but then the timestamps in your log file names would not be ISO8601
# compliant, if you care about that sort of thing. For example:
# timestamp=`date -Is | sed s/:/ː/g`
;;
*)
timestamp=`date -Is`
esac
logfile=`mktemp ~/.ssh_history/"$id"_"$timestamp"_XXXXXX` || return 2
eval exec ssh "$args" | tee "$logfile"