From 855c488b13700844aa8054b4da8aefa5aac41bdd Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Wed, 16 May 2018 19:05:55 -0500 Subject: [PATCH] [utility] Use `chmod` and `chown` when in GNU Same for the `lx` alias. Also update the README.md. Replace table by bulleted list so it's possible to use `|` in the text without breaking the Markdown rendering (as it did for the table). --- modules/utility/README.md | 42 ++++++++++++++++----------------------- modules/utility/init.zsh | 33 +++++++++++++----------------- 2 files changed, 31 insertions(+), 44 deletions(-) diff --git a/modules/utility/README.md b/modules/utility/README.md index e5dda67..14ef646 100644 --- a/modules/utility/README.md +++ b/modules/utility/README.md @@ -1,4 +1,4 @@ -Utility +utility ======= Utility aliases and functions. @@ -10,39 +10,31 @@ Aliases ### ls -| alias | command | description | -| ----- | ------- | ----------- | -| `ls` | `ls --group-directories-first --color=auto` | directories first, use color (applies to all ls aliases) | -| `l` | `ls -lAh` | all files, human-readable sizes | -| `lm` | `l | ${PAGER}` | all files, human-readable sizes, use pager | -| `ll` | `ls -lh` | human-readable sizes | -| `lr` | `ll -R` | human-readable sizes, recursive | -| `lx` | `ll -XB` | human-readable sizes, sort by extension (GNU only) | -| `lk` | `ll -Sr` | human-readable sizes, largest last | -| `lt` | `ll -tr` | human-readable sizes, most recent last | -| `lc` | `lt -c` | human-readable sizes, most recent last, change time | + * `ls` lists directories first (GNU only) and with colour (applies to all aliases below). + * `ll` lists with long format and human-readable sizes (applies to all aliases below). + * `l` lists all files. + * `lm` lists all files using pager. + * `lr` lists recursively. + * `lx` lists sorted by extension (GNU only). + * `lk` lists sorted by largest file size last. + * `lt` lists sorted by newest modification time last. + * `lc` lists sorted by newest status change (ctime) last. ### File Downloads -Aliases `get` to ( `aria2c` || `axel` || `wget` || `curl` ). + * `get` is short for ( `aria2c` || `axel` || `wget` || `curl` ). ### Resource Usage -| alias | command | -| ----- | ------- | -| `df` | `df -kh` | -| `du` | `du -kh` | + * `df` reports file system disk usage with human-readable sizes. + * `du` reports file disk usage with human-readable sizes. ### Condoms -| alias | command | -| ----- | ------- | -| `chmod` | `chmod --preserve-root -v` | -| `chown` | `chown --preserve-root -v` | -| `rm` | if available, `safe-rm` | + * `chmod` changes file mode verbosely, not operating from `/` (GNU only). + * `chown` changes file owner verbosely, not operating from `/` (GNU only). + * `rm` uses `safe-rm` if available. ### Misc -| alias | description | -| ----- | ----------- | -| `mkcd` | `mkdir -p` and `cd` | + * `mkcd` creates and changes to the given directory. diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index daf5ba7..55cdde8 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -18,6 +18,11 @@ if (( terminfo[colors] >= 8 )); then [[ -s ${HOME}/.dir_colors ]] && eval "$(dircolors --sh ${HOME}/.dir_colors)" alias ls='ls --group-directories-first --color=auto' + alias lx='ll -X' # long format, sort by extension (GNU only) + + # Always wear a condom (GNU only) + alias chmod='chmod --preserve-root -v' + alias chown='chown --preserve-root -v' else # BSD @@ -62,14 +67,13 @@ fi # ls Aliases # -alias l='ls -lAh' # all files, human-readable sizes -[[ -n ${PAGER} ]] && alias lm="l | ${PAGER}" # all files, human-readable sizes, use pager -alias ll='ls -lh' # human-readable sizes -alias lr='ll -R' # human-readable sizes, recursive -alias lx='ll -XB' # human-readable sizes, sort by extension (GNU only) -alias lk='ll -Sr' # human-readable sizes, largest last -alias lt='ll -tr' # human-readable sizes, most recent last -alias lc='lt -c' # human-readable sizes, most recent last, change time +alias ll='ls -lh' # long format and human-readable sizes +alias l='ll -A' # long format, all files +[[ -n ${PAGER} ]] && alias lm="l | ${PAGER}" # long format, all files, use pager +alias lr='ll -R' # long format, recursive +alias lk='ll -Sr' # long format, largest file size last +alias lt='ll -tr' # long format, newest modification time last +alias lc='lt -c' # long format, newest status change (ctime) last # @@ -92,19 +96,10 @@ fi # Resource Usage # -alias df='df -kh' -alias du='du -kh' +alias df='df -h' +alias du='du -h' -# -# Always wear a condom -# - -if [[ ${OSTYPE} == linux* ]]; then - alias chmod='chmod --preserve-root -v' - alias chown='chown --preserve-root -v' -fi - # not aliasing rm -i, but if safe-rm is available, use condom. # if safe-rmdir is available, the OS is suse which has its own terrible 'safe-rm' which is not what we want if (( ${+commands[safe-rm]} && ! ${+commands[safe-rmdir]} )); then