瀏覽代碼

[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).
Eric Nielsen 6 年之前
父節點
當前提交
855c488b13
共有 2 個文件被更改,包括 31 次插入44 次删除
  1. 17 25
      modules/utility/README.md
  2. 14 19
      modules/utility/init.zsh

+ 17 - 25
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.

+ 14 - 19
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,18 +96,9 @@ fi
 # Resource Usage
 #
 
-alias df='df -kh'
-alias du='du -kh'
-
-
-#
-# Always wear a condom
-#
+alias df='df -h'
+alias du='du -h'
 
-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