This commit is contained in:
TheK4n 2021-09-24 20:58:39 +03:00
parent 96fd470e5b
commit 74847aad5f
3 changed files with 65 additions and 42 deletions

View File

@ -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
}

47
.bash_functions Normal file
View File

@ -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
}

18
.bashrc
View File

@ -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)";