Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

It could by silly question, but I can not find answer anywhere. So, I'd like to use vi (you know set -o vi can do the trick) as default in my shell instead of emacs, but I do not want to put it into bash startup scripts.
Why? Because I work as verification engineer and I am using several user accounts, which are also quite often reinstalled. Changing of default profile is not answer too, because some of software creates its own home directory (independent on default profile).

EDIT: Guys, i know and you gave me several ways how to do it at startup or anytime, but I do want to change it somewhere in system and have it as default, if possible. But currently it looks like it is not possible ...

share|improve this question
    
What program do you use to login to these terminals? –  SLY Jan 3 '11 at 20:36
    
Putty/unix ssh, but only 1st session, than I'm usually working in screen, but I'd like to have it portable .. independent on client side. –  Ency Jan 3 '11 at 21:05
    
What do you envision doing this other than typing set -o vi yourself at your first prompt? –  Dennis Williamson Jan 3 '11 at 21:18
    
Then if I start screen, su or something like that emacs is back. That's why. –  Ency Jan 3 '11 at 21:22
1  
Why don't/can't you just script the generation of these user accounts to include the bash profile you expect? –  jgoldschrafe Jan 3 '11 at 21:41

4 Answers 4

This is actually fairly intuitive when you think about it, although it is not as obvious as it might seem at first. The following command will give you what you want:

ssh -t somehost "bash -i -o vi"

This will launch an interactive shell in vi mode. Lets break it down. ssh -t somehost connects to the host (obviously) and opens up a tty session. "bash -i -o vi" does two things. First, it launches bash in interactive mode, i.e., the shell you typically would receive when you login. This reads in the bash profiles, etc., and brings you to a prompt. The second argument, -o vi, enables shell options, specifically, vi mode.

To use this in a realistic environment, you'll probably want to do something like the following (adapting the path to bash or your shell of choice):

function ssh_vi { ssh -t $1 "bash -i -o vi" }

And called as...

$ ssh_vi mysite.com

Hope this helps!

share|improve this answer
    
I think this solution, combined with something equivalent for when screen is started, is probably the right answer. Otherwise, look into autohotkey or equivalent. –  Jed Daniels Jan 4 '11 at 5:44

bash$ export EDITOR=vi all software that looks for this variable will use vi you can write as is into .bashrc so every time you start screen will use it

share|improve this answer
    
export EDITOR=vi does not work as set -o vi –  Ency Jan 3 '11 at 21:26
    
you need to have the readline mode set to vi ? or you need vi as default editor ? –  silviud Jan 3 '11 at 23:24
    
Well, yes I need vi readline mode as default –  Ency Jan 4 '11 at 9:59

It sounds like you want Putty to run a script for you. Have a look at ExtraPutty. or Kitty's auto-command.

share|improve this answer
up vote 0 down vote accepted

It seems to be impossible to do it only by configuration changes.
One possible solution seems to be change and recompile "readline" library.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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