diff --git a/.bash_aliases b/.bash_aliases index 2ec0393..6e04a6d 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -43,7 +43,7 @@ alias mount='mount | column -t' alias start_bt='sudo systemctl start bluetooth' alias upgrade_all='sudo apt update && sudo apt upgrade' alias tar-it='tar -czf "../${PWD##*/}.tar.gz" .' - +alias gh='history|grep' # time alias now='date +"%T"' @@ -77,42 +77,10 @@ alias psmem='ps auxf | sort -nr -k 4 | less -R' alias music='mplayer -shuffle ~/Music/*' -# extract tar archive in ./archive_name directory -untar() { - - if [ -z $1 ]; then - echo "error: enter filename" >&2 - return 1 # exit code - fi - - if ! [ -f $1 ]; then - echo "error: file '$1' not found" >&2 - return 1 # exit code - fi - - local dir_name - dir_name="$(basename "${1%.*}")_untarred" - - 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 -} +# python +alias ve='python3 -m virtualenv venv' +alias va='. venv/bin/activate' +alias vd='deactivate' -workon() { - if [ -z $1 ]; then - echo "error: enter filename" >&2 - return 1 # exit code - fi - - . /opt/pythonenv/${1}/bin/activate -} diff --git a/.bash_functions b/.bash_functions new file mode 100644 index 0000000..e8d391c --- /dev/null +++ b/.bash_functions @@ -0,0 +1,47 @@ + + +# extract tar archive in ./archive_name directory +untar() { + + if [ -z "$1" ]; then + echo "error: enter filename" >&2 + return 1 # exit code + fi + + if ! [ -f "$1" ]; then + echo "error: file '$1' not found" >&2 + return 1 # exit code + fi + + local dir_name + dir_name="$(basename "${1%.*}")_untarred" + + 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() { + + if [ -z "$1" ]; then + echo "error: enter filename" >&2 + return 1 # exit code + fi + + . /opt/pythonenv/"${1}"/bin/activate +} + + +cl() { + DIR="$*" + cd "${DIR}" && ls -F --color=auto +} diff --git a/.bashrc b/.bashrc index b64e19a..6f1e154 100644 --- a/.bashrc +++ b/.bashrc @@ -1,4 +1,16 @@ -. /etc/bash_completion.d/all + +if [ -f $HOME/.bash_aliases ]; then + source $HOME/.bash_aliases +fi + +if [ -f /etc/bash_completion.d/all ]; then + source /etc/bash_completion.d/all +fi + +if [ -f $HOME/.bash_functions ]; then + source $HOME/.bash_functions +fi + if type shopt 2>/dev/null 1>&2; then @@ -56,10 +68,6 @@ if [ "$EUID" -eq 0 ]; then # Change prompt colors and symbols for root user fi -if [ -f ~/.bash_aliases ]; then - source ~/.bash_aliases -fi - export VIRTUAL_ENV_DISABLE_PROMPT=1 VENV="\$(virtualenv_info)";