From 482fc8721fa82eeeec54838e42d4bd5c04f69e5a Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Sun, 23 Oct 2022 21:14:31 -0400 Subject: [PATCH] extract compressed files function --- private_dot_config/zsh/executable_dot_zshrc | 3 ++- private_dot_config/zsh/func | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/private_dot_config/zsh/executable_dot_zshrc b/private_dot_config/zsh/executable_dot_zshrc index c86cf01..ddf8fb7 100644 --- a/private_dot_config/zsh/executable_dot_zshrc +++ b/private_dot_config/zsh/executable_dot_zshrc @@ -1,3 +1,4 @@ +#!/bin/zsh # If using sway then use pywal theme if [[ $XDG_SESSION_DESKTOP == "sway" ]]; then cat ~/.cache/wal/sequences @@ -53,4 +54,4 @@ bindkey -s '^o' 'lfcd\n' eval "$(zoxide init zsh --cmd cd)" # bun completions -[ -s "/home/linux/.bun/_bun" ] && source "/home/linux/.bun/_bun" \ No newline at end of file +[ -s "/home/linux/.bun/_bun" ] && source "/home/linux/.bun/_bun" diff --git a/private_dot_config/zsh/func b/private_dot_config/zsh/func index 2c1771b..9c52e6c 100644 --- a/private_dot_config/zsh/func +++ b/private_dot_config/zsh/func @@ -22,3 +22,24 @@ lfcd() { [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" fi } + +extract() { + if [ -f $1 ]; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar 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." ;; + esac + else + echo "'$1' is mot a valid file." + fi +}