Skip to content

Instantly share code, notes, and snippets.

@omar-yassin
Created September 22, 2016 16:31
Show Gist options
  • Save omar-yassin/38be7989fd4acbecca2b7fb5ff380eb2 to your computer and use it in GitHub Desktop.
Save omar-yassin/38be7989fd4acbecca2b7fb5ff380eb2 to your computer and use it in GitHub Desktop.
bash_profile 2016
export PS1='\e[1;35m\u\e[m@\h:\e[1;31m\w\e[m\n\$ '
export PATH="$PATH:~/bin/"
# auto complete hostnames
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
cat ~/.ssh/config | \
grep "^Host " | \
awk '{print $2}'
`
COMPREPLY=( $(compgen -W "${comp_ssh_hosts}" -- $cur))
return 0
}
complete -F _complete_ssh_hosts ssh
complete -F _complete_ssh_hosts i2cssh
# autocomplete in python shell
export PYTHONSTARTUP=~/.pythonrc
# On a separate file
# ~/.pythonrc
# enable syntax completion
try:
import readline
except ImportError:
print("Module readline not available.")
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment