From 30d2303b3da175d9c12a0cfdf4707b35e86af041 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Wed, 22 Sep 2021 18:07:04 +0300 Subject: [PATCH] add untar --- .bash_aliases | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.bash_aliases b/.bash_aliases index d79f66e..89bf0ff 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -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'