Skip to content

An easy way to switch between client based bash profiles and aliases. This may be helpful for freelancers who have multiple clients

License

Notifications You must be signed in to change notification settings

pfwd/terminal-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terminal Setup

This allows switching between client bash profiles.

Each client can have their own SSH config and bash aliases

When switching between clients a symlink named .current_client_aliases is added to the home directory. This is linked to the active client aliases and changed when the client is switched

Clients

Each client should be structured like so

/clients/<client>/.aliases
/clients/<client>/.ssh/keys/
/clients/<client>/.ssh/config

Both bash aliases and ssh folders are optional

Installation

Clone the repository into your home directory

git clone [email protected]:pfwd/terminal-setup.git ~/terminal-setup.git

Please check the following install and uninstall scripts to ensure this won't wipe out existing bash profiles

Make sure the bash scripts are executable

$ chmod u+x ./bin/*

To install new clients or updates run the following:

$ ./bin/install.sh

You must source the new .profile_bash for the below reload command to work

$ source ~/.bash_profile

Switch between clients

To switch between clients run the following:

$ ./bin/client_switch.sh -c <client> && reload

Reloading the bash profile

This only applies if you didn't add the reload command when switching between clients Each time you switch between clients you must reload the bash profile to pick up any changes

$ reload

When the profile is reloaded the default aliases are also included

Tips and tricks

In each client add aliases that match to the clients SSH config

# clients/foo/.aliases
alias ssh-dev-site="ssh -F ~/.ssh/foo/config dev-site"
  
# clients/foo/.ssh/config
Host dev-site
   HostName <IP_ADDRESS>
   User <USERNAME>
   IdentityFile ~/.ssh/foo/keys/id_rsa
       
# clients/bar/.aliases
alias ssh-dev-site="ssh -F ~/.ssh/bar/config dev-site"
   
# clients/bar/.ssh/config
Host dev-site
   HostName <IP_ADDRESS>
   User <USERNAME>
   IdentityFile ~/.ssh/bar/keys/id_rsa
   
$ ./bin/client_switch.sh -c foo && reload
$ ssh-dev-site # This will access foo server
   
$ ./bin/client_switch.sh -c bar && reload
$ ssh-dev-site # This will access bar server

Create an alias in each client that echos the current active client

# clients/foo/.aliases
alias whichclient="echo Client Foo is loaded"
  
# clients/bar/.aliases
alias whichclient="echo Client Bar is loaded"
  
$ ./bin/client_switch.sh -c foo && reload
$ whichclient # Client Foo is loaded
  
$ ./bin/client_switch.sh -c bar && reload
$ whichclient # Client Bar is loaded

About

An easy way to switch between client based bash profiles and aliases. This may be helpful for freelancers who have multiple clients

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages