mirror of
https://github.com/thilobillerbeck/dotfiles.git
synced 2024-12-22 12:03:05 +01:00
add extract
This commit is contained in:
parent
bf2d1fd2af
commit
1cbab37a97
2 changed files with 25 additions and 0 deletions
|
@ -51,6 +51,7 @@ in {
|
|||
nix-build -E 'with import <nixpkgs> { }; callPackage ./default.nix { }'
|
||||
'')
|
||||
(callPackage ./../pkgs/toggl-time-grouper/package.nix { inherit python3Packages; })
|
||||
(callPackage ./../pkgs/extract.nix { inherit pkgs; })
|
||||
nixpkgs-fmt
|
||||
toolbox
|
||||
distrobox
|
||||
|
|
24
home-manager/pkgs/extract.nix
Normal file
24
home-manager/pkgs/extract.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ pkgs }:
|
||||
|
||||
/* SOURCE: https://ostechnix.com/a-bash-function-to-extract-file-archives-of-various-types/ */
|
||||
|
||||
pkgs.writeShellScriptBin "extract" ''
|
||||
if [ -f $1 ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) ${pkgs.gnutar}/bin/tar xjf $1 ;;
|
||||
*.tar.gz) ${pkgs.gnutar}/bin/tar $1 ;;
|
||||
*.bz2) ${pkgs.bzip2}/bin/bunzip2 $1 ;;
|
||||
*.rar) ${pkgs.rar}/bin/rar x $1 ;;
|
||||
*.gz) ${pkgs.gzip}/bin/gunzip $1 ;;
|
||||
*.tar) ${pkgs.gnutar}/bin/tar xf $1 ;;
|
||||
*.tbz2) ${pkgs.gnutar}/bin/tar xjf $1 ;;
|
||||
*.tgz) ${pkgs.gnutar}/bin/tar xzf $1 ;;
|
||||
*.zip) ${pkgs.unzip}/bin/unzip $1 ;;
|
||||
*.Z) ${pkgs.gzip}/bin/uncompress $1 ;;
|
||||
*.7z) ${pkgs._7zz}/bin/7z x $1 ;;
|
||||
*) echo "'$1' cannot be extracted via extract()" ;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
''
|
Loading…
Reference in a new issue