zsh: fix aliases/functions such that they can refer to eachother

This commit is contained in:
2025-07-08 19:26:43 +00:00
parent fdbdf826d3
commit 1f3957bcc4

View File

@@ -180,8 +180,29 @@ in
HISTORY_IGNORE='(sane-shutdown *|sane-reboot *|rm *|nixos-rebuild.* switch|switch)'
# user-facing helpers.
# could be aliases, but then they wouldn't be able to call into eachother.
### aliases
# aliases can be defined in any order, regardless of how they reference eachother.
# but they must be defined before any functions which use them.
#
# ls helpers (eza is a nicer `ls`)
# l: list directory, one entry per line
alias l="eza --time-style=long-iso --bytes --oneline"
# la: like `ls -a`
alias la="eza --time-style=long-iso --bytes --oneline --all"
# lal: like `ls -al`
alias lal="eza --time-style=long-iso --bytes --long --all"
# ll: like `ls -l`
alias ll="eza --time-style=long-iso --bytes --long"
# lla: like `ls -al`
alias lla="eza --time-style=long-iso --bytes --long --all"
alias ls="eza --time-style=long-iso --bytes"
# escape to use the original (coreutils) `ls`
alias _ls="env ls"
### functions
# N.B. functions must be defined _after_ any aliases they reference;
# alias expansion appears to happen at definition time, not call time.
function c() {
# list a dir after entering it
cd "$@"
@@ -196,35 +217,6 @@ in
chmod u+w "$1"
}
# ls helpers (eza is a nicer `ls`)
# l: list directory, one entry per line
function l() {
eza --time-style=long-iso --bytes --oneline "$@"
}
# la: like `ls -a`
function la() {
eza --time-style=long-iso --bytes --oneline --all "$@"
}
# lal: like `ls -al`
function lal() {
eza --time-style=long-iso --bytes --long --all "$@"
}
# ll: like `ls -l`
function ll() {
eza --time-style=long-iso --bytes --long "$@"
}
# lla: like `ls -al`
function lla() {
eza --time-style=long-iso --bytes --long --all "$@"
}
function ls() {
eza --time-style=long-iso --bytes "$@"
}
# escape to use the original (coreutils) `ls`
function _ls() {
env ls "$@"
}
function nd() {
# enter a directory, creating it if necessary
mkdir -p "$1"