Situation: Need to login to multiple remote servers with some of them having fish shell
Requirement: Default shell is bash. If I login to a server and fish is present, switch to fish shell, otherwise stay on bash.
Tried .bashrc:
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Source global definitions
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
# Update Path
export PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH:$HOME/.bin
# Open fish shell if present, otherwise stick to bash
if hash fish 2>/dev/null; then
# echo "Fish detected, shifting shell"
fish "$@"; exit
fi
However, scp doesn't seem to be working. When I try to scp a file, verbose output shows it to be stuck here.
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_ADDRESS = en_US.UTF-8
debug1: Sending env LC_IDENTIFICATION = en_US.UTF-8
debug1: Sending env LC_MEASUREMENT = en_US.UTF-8
debug1: Sending env LC_MONETARY = en_US.UTF-8
debug1: Sending env LC_NAME = en_US.UTF-8
debug1: Sending env LC_NUMERIC = en_US.UTF-8
debug1: Sending env LC_PAPER = en_US.UTF-8
debug1: Sending env LC_TELEPHONE = en_US.UTF-8
debug1: Sending env LC_TIME = en_US.UTF-8
debug1: Sending command: scp -v -f test_file
Initially I thought the echo
command was causing it to not work, but it doesn't work without it as well.
.bashrc
should not be sourced by Bash in a non-interactive session, right? Are you sourcing it explicitly from.bash_profile
? – Kusalananda Apr 24 '17 at 14:03.bash_profile
. The.bashrc
is still picked up though, weird. Didn't notice this before. Any idea why this would be happening? – yamatau Apr 24 '17 at 14:29fish
when logging in manually to the remote machine and that's why you added that line to bashrc. However, this has the result of breaking your scp and that's what you want to fix. Is that correct? You don't want/need fish to be run when doingscp
, right? – terdon Apr 24 '17 at 14:30