Add utilities plugin with archive extract command

This commit is contained in:
Kenneth Benzie 2019-01-21 12:46:36 +00:00
parent ce65ae40bc
commit b842fb6437
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,24 @@
# A collection of various shell utilities.
# Detect the type and extract an archive file.
extract() {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.tar.xz) gunzip $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7zr x $1 ;;
*) echo "error: unable to extract '$1'" ;;
esac
else
echo "error: file not found '$1'"
fi
}

3
zshrc
View File

@ -31,6 +31,9 @@ source-plugin build
# Project sandboxing commands
source-plugin sandbox
# Various shell utilities
source-plugin utilities
# Layout tmux window commands
[ "$TMUX" != "" ] && source-plugin layout