Labels

"Igbo Blues" 2006 2008 2010 Acceleration of proceedings Adamosa Osagiede Admissibility of oppositions Africa Musica African Divas African Fiesta Akwé Obiang Amharic Amunataba Dance Band Angèle Revignet Appeals : miscellaneous As I Lay Dying Bella-Bella Benga Bezawork Asfaw Biafra Bikutsi Bob Sir Merenge Bobongo Stars Bring Me The Horizon Bumba Massa Cameroun Canon Star cara mendapatkan uang Central African Republic Centro Mix Chelsea Grin Christy Essien-Igbokwe Claim interpretation Clarity CoC CoC akan Ditutup CoC ditutup Hoax CoC resmi ditutup CoC Tidak jadi ditutup Congo Correction of errors Côte d'Ivoire DDC Mlimani Park Orchestra Deathcore Desolation Of Eden Divisional application Douala Dr. Nico drone Dur Dur Ebenezer Obey Edo Efik Egwu Ekpili Elias Tababbal err errbot Ethiopia Ewi Ezigbo Obiligbo Faadumo Qaasim Fees Framework of appeal Francis Gon Gabon gaming gentoo Ghana golang Hausa Highlife Hilarion Nguema I.K. Dairo Igbo Igbo Traditional Music Info Itsiembu Bi-Mbin Jean-Boniface Asssélé Jerry Hansen Jezu Lokota Jo-Man Anguilet Josky Kiambukuta Juju Julien Nziengui Kenya Kiam Kosmos Moutouari l'ANPAC Presente Lanrewaju Adepoju Lapiro de Mbanga Late filing lego Leonard Dembo Libaaxyada Maaweeliska Banaadir Lingala linux Lipua-Lipua Mack Joss Makossa Mali Marcel Djabioh Marthe Ashagari Mayele Mbalax Mbaye Dieye Faye Melo Divine Metalcore Mike Ejeagha Miriam Makeba Mobanza Ley Musiki Mutuashi Muziki wa Dansi Nigeria Nigerian Female Vocalists Norbert Epandja Novelty Obiang Okane Oral proceedings Orchestra Cavacha Orchestre African Jazz Orchestre Veve Osayomore Joseph Other Blogs Ouaka Stars Partiality Patent Register Patrick Idahosa Personal musings Petit Tchadien Pierre Embony Pierre-Claver Zeng Pop Prior public use python Real Sounds of Africa Reimbursement review Rex Lawson Rigo Star Rock Sahra Dawo Santo Backita Senegal Shona Show Promoter Sierra Leone software development Somalia Soukous South Africa Stay of proceedings Substantial procedural violation Sufficiency of disclosure Suicide Silence Super Stars Swahili Sylvester Odhiambo Talents of Benin Tanzania Technical or not Teshome Asged Tips tmux Togo Toto Guillaume tutorial Verckys Vijana Jazz vim Waaberi Wolof Yoruba Yoruba Percussion Styles Yvon Dawens Z 3.1.01 Z 3.2.04 Z 3.2.07 Z 3.3.02 Z 3.3.03 Z 3.3.10 Z 3.5.01 Zambia Zimbabwe Zokela

Make your dotfiles follow you automatically when you ssh to a server

I finally took a little bit of my time to sort out this stupid problem.
For those who login often on remote servers, how horrible is it to see everything set to their default values once you are logged in ?
bash is your shell instead of zsh, there is no color, no completion, no syntax highlight, vim has none of your plugins available, nada !
The first thing to do is to make your configs as self-contained as possible : for example I use oh-my-ssh for zsh which contains the themes and plugins in its own .oh-my-zsh directory and same idea for vim with pathogen.
Then create a small script like this one that you can alias to your ssh command.
#!/bin/zsh
tar c -C${HOME} .oh-my-zsh .zshrc .vim .vimrc .tmux.conf | ssh $1 'tar mx -C${HOME}'
ssh -t $1 "/bin/zsh"
Edit: OR this cleaner way thanks to mooism2 on hackernews by adding to a specific set of hosts in your .ssh/config
#
# For example for all your server
#
Host *
PermitLocalCommand yes
LocalCommand tar c -C${HOME} .oh-my-zsh .zshrc .vim .vimrc .tmux.conf \
| ssh -o PermitLocalCommand=no %n "tar mx -C${HOME} ; chsh -s /bin/zsh"


What does it do ?
First, it uses a trick to stream by ssh all the required files from your local home dir and decompress them to your remote home dir. I do it like that to avoid to have any special rights set up on sshd to be able to copy files etc ... Of course, depending on what matters for you, you need to modify the list of copied files. Note for the unusual m parameters : it is here to silence a warning you can get due to the time differences between hosts.
Then, it forces an interactive session and gives you the opportunity to select your favorite remote shell.
Another nice trick is to use a oh-my-zsh theme like "agnoster" and set you DEFAULT_USER in your .zshrc
Normal Prompt →
Remote User Prompt →
Remote Root Prompt →
So your prompt will set with you remoteuser@machine if it is a remote shell and a normal prompt if it is a local one.

0 Response to "Make your dotfiles follow you automatically when you ssh to a server"

Post a Comment