To achieve this, I took advantage of openssh's environment support (which required enabling
PermitUserEnvironment yes
in /etc/ssh/sshd_config) to set a variable when I log into the server with my key pair:environment="VUSER=sapphirepaw" ssh-rsa ...
Next, a one-line change to ~/.bashrc:
[ -n "$VUSER" -a -r "$HOME/.$VUSER/bashrc" ] && . "$HOME/.$VUSER/bashrc"
That newly-sourced bashrc then takes care of setting up the rest of the world, with code like:
mydir="$HOME/.$VUSER"
export SCREENRC="$mydir/screenrc"
export VIMINIT="source $mydir/ec2init.vim"
alias st="svn status -q"
Notice that vim doesn't support any sort of "find the vimrc here" environment variable, but it does allow for arbitrary Ex commands to run, so I used that instead. (Hat tip to this helpful message.) ec2init.vim then reads:
let s:rdir="/home/ec2-user/.sapphirepaw"
let &rtp=s:rdir . "/vimfiles," . &rtp . "," . s:rdir . "/vimfiles/after"
exec "source " . s:rdir . "/vimrc"
This expands all the variables soon enough to be useful, and also means that if I ever move/reconfigure the root directory name, I will have only one place to change it in vim. And from there, all my settings are loaded. Life is good again.
No comments:
Post a Comment