Last active
January 27, 2025 19:37
-
-
Save sampersand/f6764cc0174cc5771d6fed0986be5d37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
# Option 1: Just repeat the defaults | |
################################################################################ | |
alias ls="ls -ACFPq" | |
## ... other config ... | |
# macOS config | |
if [ "$(uname)" = Darwin ]; then | |
alias ls="ls -ACFPqGhbx" | |
# ... | |
fi | |
################################################################################ | |
# Option 2: Use a function, and an alias | |
################################################################################ | |
unalias ls >/dev/null 2>&1 # in case it was aliased already | |
ls () { command ls -ACFPq "$@" } | |
## ... other config ... | |
# macOS config | |
if [ "$(uname)" = Darwin ]; then | |
alias ls='ls -Ghbx' | |
# ... | |
fi | |
################################################################################ | |
# Option 3: Use `eval` | |
################################################################################ | |
alias ls='ls -ACFPq' | |
## ... other config ... | |
# macOS config | |
if [ "$(uname)" = Darwin ]; then | |
POSIXLY_CORRECT=1 # For Bash | |
alias "$(alias ls)Ghbx" | |
unset -v POSIXLY_CORRECT | |
# ... | |
fi | |
################################################################################ | |
# Option 4: Use a variable and unset it | |
################################################################################ | |
__scratch= | |
[ "$(uname)" = Darwin ] && __scratch=Ghbx | |
alias ls="ls -ACFPq$__scratch" | |
unset -v __scratch | |
# (Not a huge fan of this one, as it breaks apart my "macos-specific" config.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment