mirror of
https://github.com/xHyroM/dotfiles.git
synced 2024-12-22 12:11:07 +01:00
feat: extract script
finally i dont need to remember all commands
This commit is contained in:
parent
9bc91aac1b
commit
025de6fc5b
1 changed files with 50 additions and 0 deletions
50
.local/bin/ex
Executable file
50
.local/bin/ex
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/bin/zsh
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo "Please provide a file to extract."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f $1 ]]; then
|
||||
echo "'$1' is not a valid file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z $2 ]]; then
|
||||
extraction_folder="."
|
||||
else
|
||||
extraction_folder="$2"
|
||||
fi
|
||||
|
||||
if [[ ! -d $extraction_folder ]]; then
|
||||
mkdir -p $extraction_folder
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
*.tar.bz2|*.tbz2)
|
||||
tar -xjf $1 -C $extraction_folder;;
|
||||
*.tar.gz|*.tgz)
|
||||
tar -xzf $1 -C $extraction_folder;;
|
||||
*.bz2)
|
||||
bunzip2 $1 -c > $extraction_folder/$(basename $1 .bz2);;
|
||||
*.rar)
|
||||
unrar x $1 $extraction_folder;;
|
||||
*.gz)
|
||||
gunzip $1 -c > $extraction_folder/$(basename $1 .gz);;
|
||||
*.tar)
|
||||
tar -xf $1 -C $extraction_folder;;
|
||||
*.zip)
|
||||
unzip $1 -d $extraction_folder;;
|
||||
*.Z)
|
||||
uncompress $1 -c > $extraction_folder/$(basename $1 .Z);;
|
||||
*.7z)
|
||||
7z x $1 -o$extraction_folder;;
|
||||
*.deb)
|
||||
ar x $1 -C $extraction_folder;;
|
||||
*.tar.xz)
|
||||
tar -xf $1 -C $extraction_folder;;
|
||||
*.tar.zst)
|
||||
unzstd $1 -o $extraction_folder;;
|
||||
*)
|
||||
echo "'$1' cannot be extracted via ex()";;
|
||||
esac
|
Loading…
Reference in a new issue