add untar
This commit is contained in:
parent
84bd6ce773
commit
30d2303b3d
@ -39,12 +39,39 @@ alias j='jobs -l'
|
||||
|
||||
|
||||
# utils
|
||||
alias sha='shasum -a 256'
|
||||
alias getpass="openssl rand -base64 12"
|
||||
alias diff='colordiff'
|
||||
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" .'
|
||||
|
||||
# extract tar archive in ./archive_name directory
|
||||
untar() {
|
||||
|
||||
if ! [ -f $1 ]; then
|
||||
echo "\033[0;31merror: file '$1' not found\e[m" >&2
|
||||
return 1 # exit code
|
||||
fi
|
||||
|
||||
dir_name="$(basename $1 | cut -d. -f1)"
|
||||
|
||||
if [ -d $dir_name ]; then
|
||||
echo "\033[0;31merror: directory '$dir_name' exists\e[m" >&2
|
||||
return 1 # exit code
|
||||
fi
|
||||
|
||||
if [ -f $dir_name ]; then
|
||||
echo "\033[0;31merror: file '$dir_name' exists\e[m" >&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"'
|
||||
@ -57,3 +84,10 @@ alias vis='vim "+set si"'
|
||||
|
||||
# net
|
||||
alias ports='netstat -tulanp'
|
||||
alias wget='wget -c'
|
||||
alias ping='ping -c 5'
|
||||
|
||||
# starts web server
|
||||
alias www='python3 -m http.server 8000'
|
||||
|
||||
alias myip='curl ipinfo.io/ip'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user