From 0404784f9fe253d37af6d3316e7cbb6a44f237a9 Mon Sep 17 00:00:00 2001 From: Marley Rae Date: Sat, 3 Feb 2024 13:11:08 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20extract()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fish/functions/extract.fish.symlink | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 fish/.config/fish/functions/extract.fish.symlink diff --git a/fish/.config/fish/functions/extract.fish.symlink b/fish/.config/fish/functions/extract.fish.symlink new file mode 100644 index 0000000..3c56e05 --- /dev/null +++ b/fish/.config/fish/functions/extract.fish.symlink @@ -0,0 +1,45 @@ +#!/usr/bin/env fish + +# Extracts archived files / mounts disk images. +# Usage: extract + +function extract -a file + if [ -f "$file" ] + switch file + case "*.tar.bz2" + tar -jxvf $file + case "*.tar.gz" + tar -zxvf $file + case "*.bz2" + bunzip2 $file + case "*.dmg" + if [ "$(uname)" = Darwin ] + hdiutil mount $file + end + case "*.gz" + gunzip $file + case "*.tar" + tar -xvf $file + case "*.tbz2" + tar -jxvf $file + case "*.tgz" + tar -zxvf $file + case "*.zip" + unzip $file + case "*.ZIP" + unzip $file + case "*pax" + cat $file | pax -r + case "*.pax.Z" + uncompress $file --stdout | pax -r + case "*.rar" + unrar x $file + case "*.Z" + uncompress $file + case "*" + echo "'$file' cannot be extracted/mounted via extract()." + end + else + echo "'$file' is not a valid file." + end +end