about summary refs log tree commit diff stats
path: root/home-manager/config/lf/commands
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/config/lf/commands')
-rw-r--r--home-manager/config/lf/commands/default.nix207
-rwxr-xr-xhome-manager/config/lf/commands/scripts/archive39
-rwxr-xr-xhome-manager/config/lf/commands/scripts/broot_jump17
-rwxr-xr-xhome-manager/config/lf/commands/scripts/chmod14
-rwxr-xr-xhome-manager/config/lf/commands/scripts/clear_trash9
-rwxr-xr-xhome-manager/config/lf/commands/scripts/dl_file34
-rwxr-xr-xhome-manager/config/lf/commands/scripts/dragon8
-rwxr-xr-xhome-manager/config/lf/commands/scripts/dragon_individual8
-rwxr-xr-xhome-manager/config/lf/commands/scripts/dragon_stay8
-rwxr-xr-xhome-manager/config/lf/commands/scripts/fzf_jump14
-rwxr-xr-xhome-manager/config/lf/commands/scripts/help8
-rwxr-xr-xhome-manager/config/lf/commands/scripts/mk_dir9
-rwxr-xr-xhome-manager/config/lf/commands/scripts/mk_file9
-rwxr-xr-xhome-manager/config/lf/commands/scripts/mk_ln37
-rwxr-xr-xhome-manager/config/lf/commands/scripts/mk_scr31
-rwxr-xr-xhome-manager/config/lf/commands/scripts/open12
-rwxr-xr-xhome-manager/config/lf/commands/scripts/open_config8
-rwxr-xr-xhome-manager/config/lf/commands/scripts/restore_trash8
-rwxr-xr-xhome-manager/config/lf/commands/scripts/set_wall_paper11
-rwxr-xr-xhome-manager/config/lf/commands/scripts/stripspace32
-rwxr-xr-xhome-manager/config/lf/commands/scripts/trash22
-rwxr-xr-xhome-manager/config/lf/commands/scripts/unarchive22
22 files changed, 567 insertions, 0 deletions
diff --git a/home-manager/config/lf/commands/default.nix b/home-manager/config/lf/commands/default.nix
new file mode 100644
index 00000000..446466be
--- /dev/null
+++ b/home-manager/config/lf/commands/default.nix
@@ -0,0 +1,207 @@
+{
+  pkgs,
+  sysLib,
+  ...
+}: let
+  functionCall = {
+    file,
+    dependencies,
+    ...
+  }:
+    sysLib.makeShellScriptWithLibraryAndKeepPath {
+      name = "${builtins.baseNameOf file}";
+      script = file;
+      dependencies = dependencies ++ (builtins.attrValues {inherit (pkgs) dash coreutils;});
+    }
+    + "/bin/${builtins.baseNameOf file}";
+  shell = {
+    file,
+    dependencies,
+    ...
+  }: ''
+    ''${{
+      ${functionCall {inherit file dependencies;}}
+    }}
+  ''; # closes the lf tui
+  pipe = {
+    file,
+    dependencies,
+    ...
+  }: ''
+    %{{
+      ${functionCall {inherit file dependencies;}}
+    }}
+  ''; # runs the command in the ui/term bar
+  async = {
+    file,
+    dependencies,
+    ...
+  }: ''
+    &{{
+      ${functionCall {inherit file dependencies;}}
+    }}
+  ''; # runs the command in the background
+  wait = {
+    file,
+    dependencies,
+    ...
+  }: ''
+    !{{
+      ${functionCall {inherit file dependencies;}}
+    }}
+  ''; # adds a prompt after the command has run
+in {
+  archive = shell {
+    file = ./scripts/archive;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        fzf
+        gnutar
+        xz
+        p7zip
+        zip
+        ;
+    };
+  };
+  broot_jump = shell {
+    file = ./scripts/broot_jump;
+    dependencies = builtins.attrValues {
+      inherit (pkgs) broot;
+    };
+  };
+  chmod = pipe {
+    file = ./scripts/chmod;
+    dependencies = [];
+  };
+  clear_trash = shell {
+    file = ./scripts/clear_trash;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        fzf
+        trashy
+        ;
+    };
+  };
+  dl_file = pipe {
+    file = ./scripts/dl_file;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        xdragon
+        curl
+        ;
+    };
+  };
+  dragon = pipe {
+    file = ./scripts/dragon;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        xdragon
+        ;
+    };
+  };
+  dragon_individual = pipe {
+    file = ./scripts/dragon_individual;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        xdragon
+        ;
+    };
+  };
+  dragon_stay = pipe {
+    file = ./scripts/dragon_stay;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        xdragon
+        ;
+    };
+  };
+  fzf_jump = shell {
+    file = ./scripts/fzf_jump;
+    dependencies = builtins.attrValues {
+      inherit (pkgs) fzf lf gnused;
+    };
+  };
+  help = shell {
+    file = ./scripts/help;
+    dependencies = [];
+  };
+  mk_dir = pipe {
+    file = ./scripts/mk_dir;
+    dependencies = [];
+  };
+  mk_file = shell {
+    file = ./scripts/mk_file;
+    dependencies = [];
+  };
+  mk_ln = pipe {
+    file = ./scripts/mk_ln;
+    dependencies = [];
+  };
+  mk_scr = shell {
+    file = ./scripts/mk_scr;
+    dependencies = builtins.attrValues {inherit (pkgs) neovim;};
+  };
+  open = shell {
+    file = ./scripts/open;
+    dependencies = builtins.attrValues {inherit (pkgs) file xdg-utils neovim git;};
+  };
+  open_config = shell {
+    file = ./scripts/open_config;
+    dependencies = builtins.attrValues {
+      #inherit
+      #(pkgs)
+      ## TODO rewrite this:  bookmenu, https://github.com/jarun/buku
+      #
+      #buku
+      #;
+    };
+  };
+  restore_trash = shell {
+    file = ./scripts/restore_trash;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        fzf
+        trashy
+        ;
+    };
+  };
+  set_wall_paper = pipe {
+    file = ./scripts/set_wall_paper;
+    dependencies = [];
+  };
+  stripspace = pipe {
+    file = ./scripts/stripspace;
+    dependencies = [];
+  };
+  trash = pipe {
+    file = ./scripts/trash;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        trashy
+        trash-cli
+        findutils
+        ;
+    };
+  };
+  unarchive = pipe {
+    file = ./scripts/unarchive;
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        gnutar
+        unzip
+        # TODO this is unfree! unrar
+        
+        p7zip
+        ;
+    };
+  };
+}
diff --git a/home-manager/config/lf/commands/scripts/archive b/home-manager/config/lf/commands/scripts/archive
new file mode 100755
index 00000000..fd032dd4
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/archive
@@ -0,0 +1,39 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+# Option '-f' disables pathname expansion which can be useful when $f, $fs, and
+# $fx variables contain names with '*' or '?' characters. However, this option
+# is used selectively within individual commands as it can be limiting at
+# times.
+set -f
+
+archivers=$(tmp 'echo "gzip xz 7z zip"');
+
+readp "File Name: " name;
+
+FX="$(awk -v Root="$(if [ "$(pwd)" = "/" ]; then pwd; else echo "$(pwd)/";fi)" '{
+for (i=1; i<=NF; i++) {
+    gsub(Root, "", $i);
+    print $i;
+}
+}' "$(tmp "echo \"$fx\" | tr '\n' ' '")")";
+
+case $(awk '{for (i=1; i<=NF; i++) print $i}' $archivers | fzf) in
+    "gzip")
+        tar -czf "$name".tar.gz $FX
+        ;;
+    "xz")
+        tar -cf "$name".tar $FX
+        xz -z -9 -e -T0 "$name".tar
+        ;;
+    "7z")
+        7z a "$name".7z $FX
+        ;;
+    "zip")
+        zip --symlinks -r "$name".zip $FX
+        ;;
+esac
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/broot_jump b/home-manager/config/lf/commands/scripts/broot_jump
new file mode 100755
index 00000000..ff62ec90
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/broot_jump
@@ -0,0 +1,17 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+tmp=$(mktmp)
+res="$(broot --outcmd $tmp && cat $tmp | sed 's/cd //')"
+
+if [ -f "$res" ]; then
+    cmd="select"
+elif [ -d "$res" ]; then
+    cmd="cd"
+fi
+
+lf -remote "send $id $cmd \"$res\""
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/chmod b/home-manager/config/lf/commands/scripts/chmod
new file mode 100755
index 00000000..b1682090
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/chmod
@@ -0,0 +1,14 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+readp "Mode Bits: " bits
+
+while read -r file; do
+    chmod "$bits" "$file"
+done < "$(tmp "echo $fx")"
+
+lf -remote 'send reload'
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/clear_trash b/home-manager/config/lf/commands/scripts/clear_trash
new file mode 100755
index 00000000..e1ee3d1e
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/clear_trash
@@ -0,0 +1,9 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+# could also use --force, for instand removal
+trash list | fzf --multi | awk '{print $NF}' | xargs trash empty --match=exact
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/dl_file b/home-manager/config/lf/commands/scripts/dl_file
new file mode 100755
index 00000000..373386f8
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/dl_file
@@ -0,0 +1,34 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+# Provides the ability to download a file by dropping it into a window
+
+url=$(dragon -t -x)
+
+if [ -n "$url" ]; then
+  prompt "File Name: "
+  name=""
+  while [ -z $name ] || [ -e $name ]
+  do
+    read -r name
+    if [ -e "$name" ]; then
+      prompt "File already exists, overwrite [y|N]: "
+      read -r ans
+
+      if [ "$ans" = "y" ]; then
+        break
+      else
+        prompt "File Name: "
+      fi
+    fi
+  done
+
+  # Download the file with curl
+  [ -n "$name" ] && curl -o "$name" "$url" || die "curl failed"
+else
+  die "Url is null!"
+fi
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/dragon b/home-manager/config/lf/commands/scripts/dragon
new file mode 100755
index 00000000..fce161be
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/dragon
@@ -0,0 +1,8 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+dragon -a -x "$fx"
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/dragon_individual b/home-manager/config/lf/commands/scripts/dragon_individual
new file mode 100755
index 00000000..7adf6924
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/dragon_individual
@@ -0,0 +1,8 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+dragon "$fx"
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/dragon_stay b/home-manager/config/lf/commands/scripts/dragon_stay
new file mode 100755
index 00000000..aff9d01d
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/dragon_stay
@@ -0,0 +1,8 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+dragon -a "$fx"
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/fzf_jump b/home-manager/config/lf/commands/scripts/fzf_jump
new file mode 100755
index 00000000..e0995761
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/fzf_jump
@@ -0,0 +1,14 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+res="$(fd . --maxdepth 3 | fzf --header='Jump to location')"
+if [ -f "$res" ]; then
+    cmd="select"
+elif [ -d "$res" ]; then
+    cmd="cd"
+fi
+lf -remote "send $id $cmd \"$res\""
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/help b/home-manager/config/lf/commands/scripts/help
new file mode 100755
index 00000000..4ec06648
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/help
@@ -0,0 +1,8 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+cat ~/.config/lf/lfrc | less # TODO make this better
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/mk_dir b/home-manager/config/lf/commands/scripts/mk_dir
new file mode 100755
index 00000000..fb69cf92
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/mk_dir
@@ -0,0 +1,9 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+readp "Directory Name: " dir
+mkdir "$dir"
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/mk_file b/home-manager/config/lf/commands/scripts/mk_file
new file mode 100755
index 00000000..eef8df4b
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/mk_file
@@ -0,0 +1,9 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+readp "File Name: " name
+"$EDITOR" "$name"
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/mk_ln b/home-manager/config/lf/commands/scripts/mk_ln
new file mode 100755
index 00000000..066150bd
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/mk_ln
@@ -0,0 +1,37 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+while IFS= read -r i;do
+    set -- "$@" "$i"
+done < "$(tmp 'cat ~/.local/share/lf/files')"
+
+mode="$1"
+shift
+
+if [ "$#" -lt 1 ]; then
+    msg "no files to link"
+    exit 0
+fi
+
+case "$mode" in
+    copy)
+        while [ "$#" -gt 0 ]; do
+            file="$1"
+            ans="$(basename "$file")"
+
+            while [ -e "$ans" ];do
+                prompt "$ans already exists, new name for link: "
+                read -r ans
+            done
+
+            ln -s "$file" "$(pwd)/$ans"
+            shift
+        done
+        ;;
+esac
+rm ~/.local/share/lf/files
+# lf -remote "send clear"
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/mk_scr b/home-manager/config/lf/commands/scripts/mk_scr
new file mode 100755
index 00000000..6857e8f6
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/mk_scr
@@ -0,0 +1,31 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+script=$(mktmp)
+cat << EOF > $script
+#!/usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+. %SHELL_LIBRARY_PATH
+
+
+
+EOF
+
+readp "Script Name: " script_name
+scr="$(pwd)"/"$script_name"
+
+while [ -e "$scr" ];do
+    readp "$script_name already exists, new name for script: " script_name
+    scr="$(pwd)"/"$script_name"
+done
+
+cat "$script" > "$scr"
+chmod +x "$scr"
+
+
+"$VISUAL" "$scr"
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/open b/home-manager/config/lf/commands/scripts/open
new file mode 100755
index 00000000..2065eee3
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/open
@@ -0,0 +1,12 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+case $(file --mime-type "$f" -bL) in
+    text/*|application/json) "$EDITOR" "$f";;
+    image/*) "$IVIEWER" "$f";;
+    *) xdg-open "$f";;
+esac
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/open_config b/home-manager/config/lf/commands/scripts/open_config
new file mode 100755
index 00000000..55ae68cb
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/open_config
@@ -0,0 +1,8 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+"$EDITOR" "$(bookmenu -b ~/.config/bookmenu/configs -f fzf -o)" # TODO implement this
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/restore_trash b/home-manager/config/lf/commands/scripts/restore_trash
new file mode 100755
index 00000000..22c16888
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/restore_trash
@@ -0,0 +1,8 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+trash list | fzf --multi | awk '{print $NF}' | xargs trash restore --match=exact
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/set_wall_paper b/home-manager/config/lf/commands/scripts/set_wall_paper
new file mode 100755
index 00000000..50cc9656
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/set_wall_paper
@@ -0,0 +1,11 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+die "No yet implemented" # TODO do what the 'die' says
+#sed -i "s,export AWMWALLPAPER='.*',export AWMWALLPAPER='${f}'," ${ZDOTDIR}/.zshenv
+#swaybg -i "$f" &
+#feh --bg-max --no-fehbg "$f"
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/stripspace b/home-manager/config/lf/commands/scripts/stripspace
new file mode 100755
index 00000000..65dabc4c
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/stripspace
@@ -0,0 +1,32 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+files=$(mktmp);
+echo "$fx" > $files;
+
+awk_source=$(mktmp);
+cat << OFT > $awk_source
+BEGIN {FS=" "}
+{for (i=1; i != NF + 1; i++)
+    if (i == NF) {
+        parts[i]=tolower(\$i);
+    } else {
+        parts[i]=tolower(\$i"_");
+    }
+}
+END {for (i in parts) printf parts[i]}
+OFT
+
+while read -r file; do
+    dirty_name=$(mktmp)
+    basename "$file" > $dirty_name;
+    clean_name=$(awk -f "$awk_source" "$dirty_name");
+
+    [ -e "$clean_name" ] && die "file \"$clean_name\" already exists!";
+    mv "$(cat $dirty_name)" "$clean_name" || die "Move failed";
+    lf -remote 'send reload'
+done < "$files";
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/trash b/home-manager/config/lf/commands/scripts/trash
new file mode 100755
index 00000000..9e2e6aa4
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/trash
@@ -0,0 +1,22 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+trash_output=$(mktmp);
+expected_error_output=$(mktmp);
+
+# try trashy first
+nix run nixpkgs#trashy -- put "$fx" 2> $trash_output;
+
+cat << EOF > $expected_error_output;
+error: Error during a \`trash\` operation: Unknown { description: "Path: '\"/.Trash-1000\"'. Message: Permission denied (os error 13)" }
+EOF
+
+if [ "$(cat $expected_error_output)" = "$(cat $trash_output)" ];then
+    warning "Deleting with trash-cli to the /.Trash folder";
+    # this file could not be trashed because it is on the tempfs volume, trash-cli can do this this
+    printf "%s" "$fx" | tr '\n' ' ' | xargs trash-put;
+fi
+# vim: ft=sh
diff --git a/home-manager/config/lf/commands/scripts/unarchive b/home-manager/config/lf/commands/scripts/unarchive
new file mode 100755
index 00000000..dfa82c9a
--- /dev/null
+++ b/home-manager/config/lf/commands/scripts/unarchive
@@ -0,0 +1,22 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+# extract the current file with the right command
+# (xkcd link: https://xkcd.com/1168/)
+set -f
+case "$f" in
+    *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
+    *.tar.gz|*.tgz) tar xzvf $f;;
+    *.tar.xz|*.txz) tar xJvf $f;;
+    *.zip) unzip $f;;
+    *.rar)
+        die "rar is a unfree format!"
+        #unrar x $f
+        ;;
+    *.7z) 7z x $f;;
+    *) die "Unsupported format" ;;
+esac
+# vim: ft=sh