Skip to content

Make mvim smarter about remote logins#340

Merged
splhack merged 1 commit intomacvim-dev:masterfrom
yacoob:no-gui-via-ssh
Sep 2, 2016
Merged

Make mvim smarter about remote logins#340
splhack merged 1 commit intomacvim-dev:masterfrom
yacoob:no-gui-via-ssh

Conversation

@yacoob
Copy link
Copy Markdown
Contributor

@yacoob yacoob commented Aug 29, 2016

Every now and then I need to ssh to an osx machine. Given that I have following aliases defined:

$ alias | grep '^vi'
vi=mvim
vim=mvim
vimdiff='mvim -d'

I can't easily launch MacVim in terminal. Instead, a window opens on the remote machine, I smack my forehead, kill it, unalias vi and use that. One workaround is to have vi/vim/vimdiff symlinks in place, that will affect argv0 and make mvim launch in terminal. This solution is suboptimal though - when I'm logged in directly, I actually like having MacVim launch the gui version for vim (muscle memory is a horrible thing to change). The shell I'm using (zsh) allows for argv0 manipulation, but mvim is a shell script, and $0 it is using is unaffected by those kind of manipulations.

This small patch to mvim makes it skip the -g flag if SSH_CONNECTION environment variable is present. Doing it this way has the extra benefit of working seamlessly with tmux, as by default it'll add SSH_CONNECTION flag to newly created windows if you attach a session after sshing in.

Comment thread src/MacVim/mvim Outdated

# Logged in over SSH? No gui.
if [ -n "${SSH_CONNECTION}" ]; then
gui=''
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you fix the indent? and gui= doesn't work (instead of gui='')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you fix the indent? and gui= doesn't work (instead of gui='')

I've switched to tabs instead of spaces, and used an empty value. Please
take another look.

KT.

@splhack
Copy link
Copy Markdown
Contributor

splhack commented Sep 1, 2016

@yacoob could you squash the git commits?

@yacoob
Copy link
Copy Markdown
Contributor Author

yacoob commented Sep 1, 2016 via email

@splhack
Copy link
Copy Markdown
Contributor

splhack commented Sep 2, 2016

thanks!

@splhack splhack merged commit a8c2fa5 into macvim-dev:master Sep 2, 2016
@yacoob yacoob deleted the no-gui-via-ssh branch September 2, 2016 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants