1

I work in an LDAP-based user and host network. My user exists on all hosts since it an LDAP user, and my user's home directory exists on all hosts as a mountpoint.

I have ~/.bash_profile set up to source ~/.bashrc if it exists.

Inside ~/.bashrc my final line is set -o emacs.

On local shells this correctly sets the emacs option to enable emacs-style line editing after login.

But when I ssh to another host, despite my ~/.bashrc loading everything else, the set -o emacs is either not applied or applied then overridden.

Therefore at the moment I have to manually set -o emacs each time I ssh to another host.

Is there a fix for this such that I can ssh to another host and have set -o emacs run automatically so immediately upon entering the interactive shell, emacs line-editing is enabled?

  • ssh starts an interactive login shell. bash does not read .bashrc when started as an interactive login shell. – jw013 May 2 '14 at 16:32
  • Maybe the error is in the code in ~/.bash_profile testing whether .bashrc exists? What does that code look like? – celtschk May 2 '14 at 16:36
  • I can tell there's no error in ~/.bash_profile because my prompt is set correctly in the SSH session and if I e.g. add an 'echo Hi There' line after the set -o emacs in my .bashrc the echo appears after SSH login. – user490123 May 7 '14 at 10:04
1

Using some strace commands we discovered that /etc/inputrc was being loaded after my ~/.bashrc and that containing a set editing-mode vi call which overrode my set -o emacs. The /etc/inputrc doesn't exist on my local machine hence why the issue didn't occur on localhost.

This strace also identified that ~/.inputrc is sought before /etc/inputrc is loaded as a fallback.

So we did touch ~/.inputrc to create an empty inputrc and voila, set -o emacs now works on SSH login :)

  • I had a similar problem where set -o emacs takes no effect at .bashrc. The problem was .inputrc. – geckos Jan 2 '18 at 14:17
0

ssh starts a brand new shell on the remote host whose standard input and standard output are forwarded by ssh to your local terminal. As such, you need to execute set -o emacs on the remote host, not your local host. Since emacs-style line editing is the default, the remote file presumably already contains a line like set -o vim, which you should remove.

  • I might have misread your question: the same home directory is mounted on all the machines? – chepner May 2 '14 at 15:43
  • Yes, as mentioned my user exists on all hosts and my user's home directory exists on all hosts, i.e. my "local" .bashrc and .bash_profile exist on every machine and are what's loaded when I ssh into a remote host. – user490123 May 2 '14 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.