The system I'm using has the program vim
named vi
. This isn't an alias, the actual program is named vi. To deal with this, I wanted to add an alias to my .bashrc
file, and put in a little future-proofing. I came up with this:
if [[ -z `which vim 2>/dev/null` ]] ; then #vim doesn't exist
tmp1=`vi -h` 2>/dev/null #grab the help text
#if the help text indicates it's vim, then make the alias
if [[ "${tmp1:0:17}" == 'VIM - Vi IMproved' ]] ; then
alias vim=`vi`
fi
unset tmp1
fi
But, the tmp1=
... line causes my terminal (SSH login via PuTTY) to hang with this message: :
Vim: Warning: Output is not to a terminal
What is causing this, and can it be avoided?
Original question
Putting this line tmp1=`vi -h`
into my .bashrc
file causes login shells (at least via PuTTY) to hang with the message:
Vim: Warning: Output is not to a terminal
What is causing this, and can it be avoided?
Update per Cyris's 2nd comment:
type vi vim
vi is hashed (/usr/bin/vi)
-bash: type: vim: not found
CodePudding user response:
The problem isn't with vi -h
; it's your attempt to define the alias:
alias vim=`vi`
You are trying to assign the output of vi
as the definition of vim
. You want regular quotes (or none at all), not backquotes.
# Pick one
alias vim='vi'
alias vim="vi"
alias vim=vi