diff --git a/.bash_aliases b/.bash_aliases index 7746a57..0537728 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,4 +1,5 @@ + # colors if [ -x "$(which dircolors)" ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" @@ -46,31 +47,6 @@ alias upgrade_all='sudo apt update && sudo apt upgrade' alias tar-it='tar -czf "../${PWD##*/}.tar.gz" .' -# extract tar archive in ./archive_name directory -untar() { - - if ! [ -f $1 ]; then - echo "error: file '$1' not found" >&2 - return 1 # exit code - fi - local dir_name - dir_name="$(basename $1 | cut -d. -f1)" - - if [ -d $dir_name ]; then - echo "error: directory '$dir_name' exists" >&2 - return 1 # exit code - fi - - if [ -f $dir_name ]; then - echo "error: file '$dir_name' exists" >&2 - return 1 # exit code - fi - - mkdir $dir_name 1>/dev/null && tar -C $dir_name -xf $1 && return 0 -} - - - # time alias now='date +"%T"' alias nowdate='date +"%d-%m-%Y"' @@ -101,3 +77,32 @@ alias psmem='ps auxf | sort -nr -k 4 | less -R' alias music='mplayer -shuffle ~/Music/*' + + +# extract tar archive in ./archive_name directory +untar() { + + if ! [ -f $1 ]; then + echo "error: file '$1' not found" >&2 + return 1 # exit code + fi + local dir_name + dir_name="$(basename $1 | cut -d. -f1)" + + if [ -d $dir_name ]; then + echo "error: directory '$dir_name' exists" >&2 + return 1 # exit code + fi + + if [ -f $dir_name ]; then + echo "error: file '$dir_name' exists" >&2 + return 1 # exit code + fi + + mkdir $dir_name 1>/dev/null && tar -C $dir_name -xf $1 && return 0 +} + + +workon() { + . /opt/pythonenv/${1}/bin/activate +} diff --git a/.bashrc b/.bashrc index 1839b62..92bda73 100644 --- a/.bashrc +++ b/.bashrc @@ -1,3 +1,5 @@ +. /etc/bash_completion.d/all + if type shopt 2>/dev/null 1>&2; then diff --git a/etc/bash_completion.d/ssh b/etc/bash_completion.d/all similarity index 50% rename from etc/bash_completion.d/ssh rename to etc/bash_completion.d/all index 8fe2e09..0275369 100644 --- a/etc/bash_completion.d/ssh +++ b/etc/bash_completion.d/all @@ -7,4 +7,17 @@ _ssh() { return 0 } +_workon() +{ + local cur prev envs + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + envs=`ls /opt/pythonenv/` + + COMPREPLY=( $(compgen -W "${envs}" -- ${cur}) ) +} + +complete -F _workon workon complete -F _ssh ssh +complete -F _ssh sftp