Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make mvim smarter about remote logins #340

Merged
merged 1 commit into from Sep 2, 2016
Merged

Make mvim smarter about remote logins #340

merged 1 commit into from Sep 2, 2016

Conversation

yacoob
Copy link
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.

@@ -53,6 +53,11 @@ opts=
# GUI mode, implies forking
case "$name" in m*|g*|rm*|rg*) gui=true ;; esac

# Logged in over SSH? No gui.
if [ -n "${SSH_CONNECTION}" ]; then
gui=''
Copy link
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
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
Contributor

splhack commented Sep 1, 2016

@yacoob could you squash the git commits?

@yacoob
Copy link
Contributor Author

yacoob commented Sep 1, 2016 via email

@splhack
Copy link
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.

None yet

2 participants