use /tmp if $HOME is not set
[travelrc.git] / README.md
index dde0adeff7ccaf43404f75ea7b0045a7e5de1599..e04b3204bb7dc4bf223f2ea2c14600359959d20b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -66,17 +66,17 @@ minify-trc() {
 trccmd() {
     # echo all the commands to travel with rc files, arguments act as additional arguments to tar
     local trc_min_dir="$(minify-trc)"
-    echo -n "packing trcdir... " >&2
+    echo -n "packing trcdir with '$*'... " >&2
+    [ -n "$1" ] || set -- "--gzip" # default compression is gzip (when no argument is set), can be disabled with "-a" which leads to no compression
     local trcvar="$(tar --create --file=- "$@" --directory="$trc_min_dir" --dereference ./ | base64 --wrap=0)" # this writes the compressed contents of $trc_min_dir base64-encoded to $trcvar
     rm -rf "$trc_min_dir" # delete the temporal directory generated by minify-trc
     echo "to ${#trcvar} bytes... " >&2
-    [ ${#trcvar} -lt 65536 ] || { echo "content of trcdir \"$trcdir\" is too big, even after minifying" >&2; return 1; }
+    [ ${#trcvar} -lt 65536 ] || { echo "ERROR: content of trcdir '$trcdir' is too big, even after minifying and compressing with '$*'" >&2; return 1; }
     # export $TRAVELRCDIR and create this directory, it could also be created in /tmp
     echo '
-export TRAVELRCDIR=$HOME/.travelrc.travelled
+export TRAVELRCDIR=${HOME:-/tmp}/.travelrc.travelled
 readonly TRAVELRCDIR
-mkdir --parents $TRAVELRCDIR
-'
+mkdir --parents $TRAVELRCDIR'
     # SSH_TTY should still be set to figure out whether this is a ssh session
     [ -z "$SSH_TTY" ] || echo "export SSH_TTY=$SSH_TTY"
     # decompress the files saved to $trcvar; start a bash with the travelled rc-file; only remove $TRAVELRCDIR if there is no screen or tmux session (which can still use the files); last command is true so that the returncode is always 0
@@ -101,9 +101,14 @@ tssh() {
     ssh -t "$@" "$(trccmd --xz)"
 }
 _tssh_completion() {
-    # when completion is requested, it will be redefined to use _ssh and then load the completion function for ssh, see https://stackoverflow.com/questions/61539494/how-does-bash-do-ssh-autocompletion
-    complete -F _ssh tssh
-    __load_completion "ssh" && return 124 || complete -r tssh # if loading completion is successful then return, otherwise disable completion for tssh
+    # when completion is requested, load completion for ssh and use it for tssh, otherwise disable completion for tssh
+    # see https://stackoverflow.com/questions/61539494/how-does-bash-do-ssh-autocompletion
+    if __load_completion "ssh"; then
+        complete -F _ssh tssh
+        return 124
+    else
+        complete -r tssh
+    fi
 }
 complete -F _tssh_completion tssh # this just loads the correct completion function