From f91bdcc85d4742254fefc2c9880a0c76dc2a65ed Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 23 Oct 2019 18:14:04 -0400 Subject: [PATCH] fix ssh wrapper --- brc2 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/brc2 b/brc2 index 973da7a..2bfb677 100644 --- a/brc2 +++ b/brc2 @@ -938,13 +938,21 @@ sl() { # Theres a couple ways to do this. im not sure whats best, # but relying on bash 4.4+ escape quoting seems most reliable. command ssh "${args[@]}" "$remote" \ - BRC=t bash -c '"\"\$@\""' bash ${@@Q} + BRC=t bash -c '.\ .iank/.bashrc\;"\"\$@\""' bash ${@@Q} + elif [[ ! -t 0 ]]; then + # This case is when commands are being piped to ssh. + # Normally, no bashrc gets sourced. + # But, since we are doing all this, lets source it because we can. + cat <(echo . .iank/.bashrc) - | command ssh "${args[@]}" "$remote" BRC=t bash else - # -t gives us an interactive shell for normal ssh. -l makes us use the rcfile when piping commands. - command ssh -t "${args[@]}" "$remote" BRC=t INPUTRC=.iank/.inputrc bash --rcfile .iank/.bashrc -l + command ssh -t "${args[@]}" "$remote" BRC=t INPUTRC=.iank/.inputrc bash --rcfile .iank/.bashrc fi else - BRC=t command ssh "$remote" "$@" + if [[ -t 0 ]]; then + BRC=t command ssh "${args[@]}" "$remote" ${@@Q} + else + command ssh "${args[@]}" "$remote" BRC=t bash -l + fi fi } sss() { # ssh solo -- 2.30.2