diff --git a/configs/shell/.zsh/functions/helpers.zsh b/configs/shell/.zsh/functions/helpers.zsh new file mode 100644 index 0000000..68b119b --- /dev/null +++ b/configs/shell/.zsh/functions/helpers.zsh @@ -0,0 +1,14 @@ +params_required() { + local param_name="$1" + local param_value="$2" + local error_message="$3" + + if [ -z "$error_message" ]; then + error_message="Parameter '$param_name' is required but not provided." + fi + + if [ -z "$param_value" ]; then + echo "$error_message" >&2 + exit 1 + fi +} diff --git a/configs/shell/.zsh/functions/main.zsh b/configs/shell/.zsh/functions/main.zsh index 7c0e3ff..2e68ddf 100644 --- a/configs/shell/.zsh/functions/main.zsh +++ b/configs/shell/.zsh/functions/main.zsh @@ -7,3 +7,26 @@ convert_video_to_gif() { echo "GIF created: $output_filename" } + +extract() { + params_required "File" "$1" "Usage: extract ." + + case $1 in + *.tar.bz2) tar xvjf $1 ;; + *.tar.gz) tar xvzf $1 ;; + *.tar.xz) tar xvJf $1 ;; + *.lzma) unlzma $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x -ad $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xvf $1 ;; + *.tbz2) tar xvjf $1 ;; + *.tgz) tar xvzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *.xz) unxz $1 ;; + *.exe) cabextract $1 ;; + *) echo "extract: '$1' - unknown archive method" ;; + esac +} diff --git a/configs/shell/.zsh/functions/utils.zsh b/configs/shell/.zsh/functions/utils.zsh deleted file mode 100644 index e69de29..0000000 diff --git a/configs/shell/.zshrc b/configs/shell/.zshrc index 3b98011..9d971a9 100644 --- a/configs/shell/.zshrc +++ b/configs/shell/.zshrc @@ -8,6 +8,11 @@ ZSH_THEME="nebirhos" # zsh-autosuggestions: https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md plugins=(zsh-syntax-highlighting zsh-autosuggestions git themes jsontools) +source $ZSH/oh-my-zsh.sh +source ~/.zsh/functions/helpers.zsh +source ~/.zsh/functions/main.zsh +source ~/.zsh/aliases/main.zsh + if [[ "$OS" = void ]]; then source ~/.zsh/os/void.zsh elif [[ "$OS" = debian ]]; then @@ -16,8 +21,4 @@ else echo "Unsupported operating system: $OS" fi -source $ZSH/oh-my-zsh.sh -source ~/.zsh/functions/main.zsh -source ~/.zsh/aliases/main.zsh - eval "$(atuin init zsh)"