#!/bin/bash function __available_projects(){ /bin/ls $HOME/src | tr " " "\n" } function __proj_activate_comp(){ cur=${COMP_WORDS[COMP_CWORD]} if [ $COMP_CWORD -eq 1 ] then COMPREPLY=( $( compgen -W "$(__available_projects)" $cur ) ) fi } function __proj_deactivate_reactivate_comp(){ cur=${COMP_WORDS[COMP_CWORD]} if [ -n "$VIRTUAL_ENV" ] then COMPREPLY=( $(basename "$VIRTUAL_ENV") ) return 0 elif [ -n "$PROJ" ] then COMPREPLY=( $(basename "$PROJ") ) return 0 else COMPREPLY=( $cur ) fi } function a(){ source $HOME/.activate_proj "$@" } function d(){ source $HOME/.deactivate_proj "$@" } function r(){ d "$1" a "$1" } complete -F __proj_activate_comp -o default a complete -F __proj_deactivate_reactivate_comp -o default d r # if the command-not-found package is installed, use it if [ -x /usr/lib/command-not-found ]; then command_not_found_handle(){ # check because c-n-f could've been removed in the meantime if [ -x /usr/lib/command-not-found ]; then /usr/bin/python /usr/lib/command-not-found -- $1 return $? else return 127 fi } fi function add_ssh_keys() { if [[ "$1" == "all" ]] then for key in $__SSH_KEYS__ do ssh-add $key done else ssh-add fi } function get_ssh_agent(){ ssh-add -l test $? -eq 2 || return agent_out="$HOME/.ssh/agent.out" source $agent_out ssh-add -l test $? -eq 2 || return ssh-agent > $agent_out source $agent_out ssh-add } function get_gpg_agent(){ readlink -f "$HOME/.gnupg" >/dev/null || return 0 agent_out="$HOME/.gnupg/agent.out" tmp=$(mktemp /tmp/gnupgXXXX) gpg-agent $* > $tmp && mv $tmp $agent_out grep GPG_TTY $agent_out >/dev/null || \ cat >> $agent_out <