if [[ $host_type == skip ]]; then return; fi
fi
- sshinfo_files=($SL_INFO_DIR/??????????-????-"$remote")
+ ngset
+ sshinfo_files=( $SL_INFO_DIR/??????????-????-"$remote" )
# there should only be one, but just in case, remove all but 1.
if (( ${#sshinfo_files[@]} >= 2 )); then
mq rm ${sshinfo_files[@]::${#sshinfo_files[@]}-1}
- sshinfo_files=($SL_INFO_DIR/??????????-????-"$remote")
+ sshinfo_files=( $SL_INFO_DIR/??????????-????-"$remote" )
fi
+ ngreset
sshinfo="${sshinfo_files[0]}"
# if $verbose; then e "sshinfo: '$sshinfo'"; fi # debug
if [[ $host_type == sync ]] && ! $pre_synced; then
m RSYNC_RSH="ssh ${args[*]}" $sl_rsync_cmd -rptL --delete $SL_FILES_DIR "$remote":
mq rm-maybe "$sshinfo"
+ sshinfo=
+ fi
+
+ if [[ ! $sshinfo ]]; then
sshinfo=$SL_INFO_DIR/$EPOCHSECONDS-$host_type-"$remote"
[[ -e $SL_INFO_DIR ]] || mkdir -p $SL_INFO_DIR
printf "%s\n" "$extra_info" >$sshinfo
# But, since we are doing all this, lets source it because we can.
cat <(echo . $sync_dirname/.bashrc) - | command ssh "${args[@]}" "$remote" LC_USEBASHRC=t bash
else
+ # random deletable note: This ssh corresponds to the one below
+ # with reverse tunnel below, and it would make sense to add it
+ # here too, but I'm mainly interested in collecting history from
+ # skip type hosts,so leaving it out for now.
mq command ssh -t "${args[@]}" "$remote" LC_USEBASHRC=t INPUTRC=$sync_dirname/.inputrc bash --rcfile $sync_dirname/.bashrc
fi
else
if [[ -t 0 ]]; then
- mq LC_USEBASHRC=t command ssh "${args[@]}" "$remote" "$@"
+ mq LC_USEBASHRC=t command ssh -R localhost:36660:localhost:36661 "${args[@]}" "$remote" "$@"
else
mq command ssh "${args[@]}" "$remote" LC_USEBASHRC=t bash
fi
# output if it took longer than 4 seconds or so.
# todo: try running slowdo on verbose ssh
+# Stores some history from remote ssh sessions via sl.
+hist-catcher() {
+ local cmd
+ local cmd_regex='[[:alnum:]]'
+
+ while true; do
+ cmd=$(nc -l 36661) ||:
+ e "cmd:'$cmd'";
+ if [[ ! $cmd =~ $cmd_regex ]]; then
+ continue
+ fi
+ history -s "$cmd" && history -a ||:
+ done
+}
+# dev notes: useful: https://www.baeldung.com/linux/local-data-remote-ssh-session#:~:text=%23%23%23%205.2%5C.%20Netcat,provide%20data%20back%2A%2A.
+# TODO: automate starting/restarting this.
+
slr() {
sl --rsync "$@"
if [[ $HISTFILE ]]; then
# save history. if our filesystem went read-only or something, continue on
- history -a ||:
+ if history -a; then
+ if [[ $SSH_CLIENT && $NOT_MAIL_HOST_P == t ]]; then
+ history 1 | sed -r 's/^([^ ]+ +){4}//' | nc -N localhost 36660 ||:
+ fi
+ fi
# if we aren't in ssh, maybe indicate history file