-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsshh
executable file
·36 lines (32 loc) · 1.36 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
#!/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
# Create the folder with user-only read+search permissions if it doesn't exist.
mkdir -m 700 -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`
;;
*)
timestamp=`date -Is`
esac
logfile=`mktemp ~/.ssh_history/${1+"$@"}_"$timestamp"_XXXXXX` || return 2
exitcode=`((ssh ${1+"$@"} 1>&3; echo $?) | tee "$logfile")` 3>&1
return $exitcode