This commit is contained in:
TheK4n 2021-09-24 00:04:22 +03:00
parent 5e3f5abad1
commit 815ee89b09
3 changed files with 45 additions and 25 deletions

View File

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

View File

@ -1,3 +1,5 @@
. /etc/bash_completion.d/all
if type shopt 2>/dev/null 1>&2; then

View File

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