extract compressed files function

This commit is contained in:
array-in-a-matrix 2022-10-23 21:14:31 -04:00
parent 2f8773f46c
commit 482fc8721f
2 changed files with 23 additions and 1 deletions

View file

@ -1,3 +1,4 @@
#!/bin/zsh
# If using sway then use pywal theme
if [[ $XDG_SESSION_DESKTOP == "sway" ]]; then
cat ~/.cache/wal/sequences
@ -53,4 +54,4 @@ bindkey -s '^o' 'lfcd\n'
eval "$(zoxide init zsh --cmd cd)"
# bun completions
[ -s "/home/linux/.bun/_bun" ] && source "/home/linux/.bun/_bun"
[ -s "/home/linux/.bun/_bun" ] && source "/home/linux/.bun/_bun"

View file

@ -22,3 +22,24 @@ lfcd() {
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
fi
}
extract() {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*,tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted." ;;
esac
else
echo "'$1' is mot a valid file."
fi
}