Added user scripts for archiving files and extracting archives

pull/19/head
mananapr 5 years ago
parent cf51d08142
commit aa4ec8c3dc

@ -2075,6 +2075,7 @@ int main(int argc, char* argv[])
pid = fork();
if( pid == 0 )
{
chdir(dir);
execl(temp_dir, scripts[option], buf, (char *)0);
exit(1);
}

@ -3,3 +3,9 @@ This directory contains some example scripts you can use with `cfiles`.
### setwal
Uses [wal](https://github.com/dylanaraps/pywal) on selection to set image as wallpaper and generate a suitable colorscheme
### archive
Creates a zip archive of selected files and stores it as `archive.zip` in the current directory. Requires `zip` to work.
### extract
Extracts an archive of any format using respective utilities

@ -0,0 +1,3 @@
#!/usr/bin/env bash
zip -r archive -@ < ~/.cache/cfiles/clipboard

@ -0,0 +1,20 @@
#!/usr/bin/env bash
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) 7z 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 via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
Loading…
Cancel
Save