ref extract func
This commit is contained in:
parent
1a0beb4999
commit
16947468c4
@ -43,7 +43,6 @@ alias sha='shasum -a 256'
|
|||||||
alias getpass="openssl rand -base64 12"
|
alias getpass="openssl rand -base64 12"
|
||||||
alias diff='colordiff'
|
alias diff='colordiff'
|
||||||
alias mount='mount | column -t'
|
alias mount='mount | column -t'
|
||||||
alias start_bt='sudo systemctl start bluetooth'
|
|
||||||
alias upgrade_all='sudo apt update && sudo apt upgrade'
|
alias upgrade_all='sudo apt update && sudo apt upgrade'
|
||||||
alias tar-it='tar -czf "../${PWD##*/}.tar.gz" .'
|
alias tar-it='tar -czf "../${PWD##*/}.tar.gz" .'
|
||||||
alias gh='history|grep'
|
alias gh='history|grep'
|
||||||
@ -80,8 +79,6 @@ alias wake="echo $'\a'" # command; wake &
|
|||||||
alias music='mplayer -shuffle ~/Music/*'
|
alias music='mplayer -shuffle ~/Music/*'
|
||||||
|
|
||||||
|
|
||||||
# python
|
|
||||||
|
|
||||||
# initializes first ./*/*/activate
|
# initializes first ./*/*/activate
|
||||||
# alias va='source "$(find -P . -maxdepth 3 -type f -name activate | sort | head -n 1)" &>/dev/null || echo "error: virtual env not found, use python3 -m virtualenv venv" >&2'
|
# alias va='source "$(find -P . -maxdepth 3 -type f -name activate | sort | head -n 1)" &>/dev/null || echo "error: virtual env not found, use python3 -m virtualenv venv" >&2'
|
||||||
alias ve='python3 -m virtualenv venv && . venv/bin/activate'
|
alias ve='python3 -m virtualenv venv && . venv/bin/activate'
|
||||||
|
|||||||
@ -77,20 +77,27 @@ extract () {
|
|||||||
if [ -z "$1" ]; then # if string non-zero
|
if [ -z "$1" ]; then # if string non-zero
|
||||||
# display usage if no parameters given
|
# display usage if no parameters given
|
||||||
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
||||||
|
return 100
|
||||||
else
|
else
|
||||||
if [ -f "$1" ] ; then # if file exists
|
if [ -f "$1" ]; then # if file exists
|
||||||
NAME=${1%.*} #
|
NAME=${1%.*}
|
||||||
mkdir "$NAME" && cd "$NAME" || return
|
|
||||||
|
if [ -e "$NAME" ]; then
|
||||||
|
echo "$NAME - exists" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir "$NAME" && cd "$NAME" || return 1
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
*.tar.bz2) tar xvjf ../"$1" ;;
|
*.tar.bz2) tar xvjf ../"$1" ;;
|
||||||
*.tar.gz) tar xvzf - ../"$1" ;;
|
*.tar.gz) tar xvzf ../"$1" ;;
|
||||||
*.tar.xz) tar xvJf ../"$1" ;;
|
*.tar.xz) tar xvJf ../"$1" ;;
|
||||||
*.lzma) unlzma ../"$1" ;;
|
*.lzma) unlzma ../"$1" ;;
|
||||||
*.bz2) bunzip2 ../"$1" ;;
|
*.bz2) bunzip2 ../"$1" ;;
|
||||||
*.rar) unrar x -ad ../"$1" ;;
|
*.rar) unrar x -ad ../"$1" ;;
|
||||||
*.gz) gunzip ../"$1" ;;
|
*.gz) gunzip ../"$1" ;;
|
||||||
*.tar) tar xvf - ../"$1" ;;
|
*.tar) tar xvf ../"$1" ;;
|
||||||
*.tbz2) tar xvjf ../"$1" ;;
|
*.tbz2) tar xvjf ../"$1" ;;
|
||||||
*.tgz) tar xvzf ../"$1" ;;
|
*.tgz) tar xvzf ../"$1" ;;
|
||||||
*.zip) unzip ../"$1" ;;
|
*.zip) unzip ../"$1" ;;
|
||||||
@ -98,10 +105,12 @@ extract () {
|
|||||||
*.7z) 7z x ../"$1" ;;
|
*.7z) 7z x ../"$1" ;;
|
||||||
*.xz) unxz ../"$1" ;;
|
*.xz) unxz ../"$1" ;;
|
||||||
*.exe) cabextract ../"$1" ;;
|
*.exe) cabextract ../"$1" ;;
|
||||||
*) echo "extract: '$1' - unknown archive method" ;;
|
*) echo "extract: '$1' - unknown archive method" >&2;;
|
||||||
esac
|
esac
|
||||||
|
cd ..
|
||||||
else
|
else
|
||||||
echo "$1 - file does not exist"
|
echo "$1 - file does not exist" >&2
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user