File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,26 @@ fix-kde-hard() {
6767 kwin_wayland --replace &
6868}
6969
70+ mosh () {
71+ local HOST=" ${1:? Usage: $0 HOST [mosh args...]} "
72+ shift || true
73+
74+ # Ask ssh what it would do after config expansion.
75+ # ssh -G prints: "remotecommand <value>" (empty if none; may also be absent on some versions)
76+ local RC=" $( ssh -G -- " $HOST " 2> /dev/null | awk ' tolower($1)=="remotecommand" { $1=""; sub(/^ /,""); print; exit }' ) "
77+
78+ local MOSH_PATH=" $( whence -p mosh) "
79+ # These may also be necessary:
80+ # -T -o ClearAllForwardings=yes
81+ local MOSH_SSH_OPTIONS=" -o ExitOnForwardFailure=no -o ForwardAgent=no"
82+ # If RemoteCommand is non-empty, override it for the SSH that mosh uses.
83+ if [[ -n " ${RC} " ]]; then
84+ " ${MOSH_PATH} " --ssh=" ssh ${MOSH_OPTIONS} -o RemoteCommand=none -o RequestTTY=no" -- " ${HOST} " " $@ "
85+ else
86+ " ${MOSH_PATH} " --ssh=" ssh ${MOSH_OPTIONS} " -- " ${HOST} " " $@ "
87+ fi
88+ }
89+
7090pdfsearch () {
7191 # https://stackoverflow.com/questions/4643438/how-to-search-contents-of-multiple-pdf-files
7292 if [ $# -ne 2 ]; then
@@ -149,8 +169,7 @@ close-chats() {
149169retry_until () {
150170 # From:
151171 # https://gitlab.com/drjaska-projects/configs/zsh/-/blob/master/.zshrc
152- if [ " $2 " = " " ]
153- then
172+ if [ " $2 " = " " ]; then
154173 echo " Usage: $0 sleeptime command"
155174 fi
156175
You can’t perform that action at this time.
0 commit comments