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.
This commit is contained in:
nevaforget 2026-03-30 17:26:48 +02:00
parent 5947d9af43
commit d1874dca6b

View File

@ -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)"