Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General > Member Success Stories
User Name
Password Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.


  Search this Thread
Old 01-18-2015, 01:36 PM   #1
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 926

Rep: Reputation: 255Reputation: 255Reputation: 255
Vim colorscheme based on source of SSH connection

I gotta post this: Just changed the overall theming on one of my machines. The console now has white background rather then black, as opposed to all my other machines.
As a result I also need a different vim colorscheme.

Now, if I ssh onto my homeserver, I want that theme to still be applied to vim, without changing it for connections from other clients in the process. Here is how I solved it:

In the server's .bashrc:

export SSH_SOURCE_IP=$(echo $SSH_CONNECTION | cut -d' ' -f 1)
export VIM_COLOR_SCHEME="elflord"  # my default scheme
if [ "$SSH_SOURCE_IP" == "" ]; then
        export VIM_COLOR_SCHEME="delek"   # white background suitable
And in /etc/vim/vimrc
colorscheme $VIM_COLOR_SCHEME
Amazingly, this does exactly what you'd think it does. When I log in from that one machine, I get delek. In all other cases, I get elflord. How cool ist this?


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] vim - solarized colorscheme StevenXL Linux - Software 2 02-02-2014 04:25 PM
gvim colorscheme in vim RudraB Linux - General 4 01-08-2013 10:37 AM
Vim colorscheme search path? alke Linux - Software 1 03-05-2007 12:56 PM
Script to start vim with a random colorscheme daihard Programming 1 05-12-2006 04:46 AM
VIM via remote SSH connection causes seg fault nkendrick Linux - Software 1 11-08-2003 07:57 AM > Forums > Linux Forums > Linux - General > Member Success Stories

All times are GMT -5. The time now is 07:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration