Skip to content

Instantly share code, notes, and snippets.

@donjohnson
Created May 27, 2014 23:50
Show Gist options
  • Save donjohnson/36183f5b87a243ec2249 to your computer and use it in GitHub Desktop.
Save donjohnson/36183f5b87a243ec2249 to your computer and use it in GitHub Desktop.
Change iterm2 (test build) window profile on ssh connect, and ssh bash autocompletion
# SSH CONFIG
PermitLocalCommand yes
############ prod
Host saltmaster
HostName ec2-xx-xx-xxx-x.us-west-1.compute.amazonaws.com
User ec2-user
LocalCommand echo -e "\033]50;SetProfile=Salt Master\a";
# bash autocomplete for ssh config Hosts:
_ssh ()
{
local cur prev opts;
COMPREPLY=();
cur="${COMP_WORDS[COMP_CWORD]}";
prev="${COMP_WORDS[COMP_CWORD-1]}";
opts="`grep "Host " ~/.ssh/config|grep -v "\*"|cut -f2 -d' '`";
if [[ ${cur} == * ]]; then
COMPREPLY=($(compgen -W "${opts}" -- ${cur}));
return 0;
fi
}
@donjohnson
Copy link
Author

I currently am working in a fairly tedious small-scale environment and having a fully populated ssh config file with hostnames is more beneficial than cumbersome for now. Hope someone else can use this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment