From d1874dca6bba7680efe19182f56c14dada299db3 Mon Sep 17 00:00:00 2001 From: nevaforget Date: Mon, 30 Mar 2026 17:26:48 +0200 Subject: [PATCH] Add cd auto-listing and extract helper to default zshrc Port cd() wrapper (auto eza listing on directory change) and extract() function (universal archive extraction) from active user config into moonarch defaults. --- defaults/shell/zshrc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/defaults/shell/zshrc b/defaults/shell/zshrc index 6427dac..86058d1 100644 --- a/defaults/shell/zshrc +++ b/defaults/shell/zshrc @@ -65,6 +65,15 @@ if [ -d "$HOME/.local/bin" ]; then PATH="$HOME/.local/bin:$PATH" fi +# --- cd with auto-listing --- +function cd() { + new_directory="$*"; + if [ $# -eq 0 ]; then + new_directory=${HOME}; + fi; + builtin cd "${new_directory}" && eza -lF --icons --color=always --group-directories-first +} + # --- Key bindings --- bindkey "^[[3~" delete-char bindkey "^[[H" beginning-of-line @@ -82,6 +91,30 @@ alias l='eza -F --icons --color=always --group-directories-first' alias vim='nvim' alias uninstall='sudo pacman -Rsn' +# --- Extract archives --- +function extract() { + if [ -f "$1" ]; then + case "$1" in + *.tar.bz2) tar xjvf "$1" ;; + *.tar.gz) tar xzvf "$1" ;; + *.tar.xz) tar xvf "$1" ;; + *.bz2) bzip2 -d "$1" ;; + *.rar) unrar2dir "$1" ;; + *.gz) gunzip "$1" ;; + *.tar) tar xf "$1" ;; + *.tbz2) tar xjf "$1" ;; + *.tgz) tar xzf "$1" ;; + *.zip) unzip2dir "$1" ;; + *.Z) uncompress "$1" ;; + *.7z) 7z x "$1" ;; + *.ace) unace x "$1" ;; + *) echo "'$1' cannot be extracted via extract()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + # --- FZF --- if command -v fzf &>/dev/null; then eval "$(fzf --zsh)"