[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).
This commit is contained in:
parent
e38b44cd7f
commit
855c488b13
2 changed files with 31 additions and 44 deletions
|
@ -1,4 +1,4 @@
|
||||||
Utility
|
utility
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Utility aliases and functions.
|
Utility aliases and functions.
|
||||||
|
@ -10,39 +10,31 @@ Aliases
|
||||||
|
|
||||||
### ls
|
### ls
|
||||||
|
|
||||||
| alias | command | description |
|
* `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).
|
||||||
| `ls` | `ls --group-directories-first --color=auto` | directories first, use color (applies to all ls aliases) |
|
* `l` lists all files.
|
||||||
| `l` | `ls -lAh` | all files, human-readable sizes |
|
* `lm` lists all files using pager.
|
||||||
| `lm` | `l | ${PAGER}` | all files, human-readable sizes, use pager |
|
* `lr` lists recursively.
|
||||||
| `ll` | `ls -lh` | human-readable sizes |
|
* `lx` lists sorted by extension (GNU only).
|
||||||
| `lr` | `ll -R` | human-readable sizes, recursive |
|
* `lk` lists sorted by largest file size last.
|
||||||
| `lx` | `ll -XB` | human-readable sizes, sort by extension (GNU only) |
|
* `lt` lists sorted by newest modification time last.
|
||||||
| `lk` | `ll -Sr` | human-readable sizes, largest last |
|
* `lc` lists sorted by newest status change (ctime) last.
|
||||||
| `lt` | `ll -tr` | human-readable sizes, most recent last |
|
|
||||||
| `lc` | `lt -c` | human-readable sizes, most recent last, change time |
|
|
||||||
|
|
||||||
### File Downloads
|
### File Downloads
|
||||||
|
|
||||||
Aliases `get` to ( `aria2c` || `axel` || `wget` || `curl` ).
|
* `get` is short for ( `aria2c` || `axel` || `wget` || `curl` ).
|
||||||
|
|
||||||
### Resource Usage
|
### Resource Usage
|
||||||
|
|
||||||
| alias | command |
|
* `df` reports file system disk usage with human-readable sizes.
|
||||||
| ----- | ------- |
|
* `du` reports file disk usage with human-readable sizes.
|
||||||
| `df` | `df -kh` |
|
|
||||||
| `du` | `du -kh` |
|
|
||||||
|
|
||||||
### Condoms
|
### Condoms
|
||||||
|
|
||||||
| alias | command |
|
* `chmod` changes file mode verbosely, not operating from `/` (GNU only).
|
||||||
| ----- | ------- |
|
* `chown` changes file owner verbosely, not operating from `/` (GNU only).
|
||||||
| `chmod` | `chmod --preserve-root -v` |
|
* `rm` uses `safe-rm` if available.
|
||||||
| `chown` | `chown --preserve-root -v` |
|
|
||||||
| `rm` | if available, `safe-rm` |
|
|
||||||
|
|
||||||
### Misc
|
### Misc
|
||||||
|
|
||||||
| alias | description |
|
* `mkcd` creates and changes to the given directory.
|
||||||
| ----- | ----------- |
|
|
||||||
| `mkcd` | `mkdir -p` and `cd` |
|
|
||||||
|
|
|
@ -18,6 +18,11 @@ if (( terminfo[colors] >= 8 )); then
|
||||||
[[ -s ${HOME}/.dir_colors ]] && eval "$(dircolors --sh ${HOME}/.dir_colors)"
|
[[ -s ${HOME}/.dir_colors ]] && eval "$(dircolors --sh ${HOME}/.dir_colors)"
|
||||||
|
|
||||||
alias ls='ls --group-directories-first --color=auto'
|
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
|
else
|
||||||
# BSD
|
# BSD
|
||||||
|
@ -62,14 +67,13 @@ fi
|
||||||
# ls Aliases
|
# ls Aliases
|
||||||
#
|
#
|
||||||
|
|
||||||
alias l='ls -lAh' # all files, human-readable sizes
|
alias ll='ls -lh' # long format and human-readable sizes
|
||||||
[[ -n ${PAGER} ]] && alias lm="l | ${PAGER}" # all files, human-readable sizes, use pager
|
alias l='ll -A' # long format, all files
|
||||||
alias ll='ls -lh' # human-readable sizes
|
[[ -n ${PAGER} ]] && alias lm="l | ${PAGER}" # long format, all files, use pager
|
||||||
alias lr='ll -R' # human-readable sizes, recursive
|
alias lr='ll -R' # long format, recursive
|
||||||
alias lx='ll -XB' # human-readable sizes, sort by extension (GNU only)
|
alias lk='ll -Sr' # long format, largest file size last
|
||||||
alias lk='ll -Sr' # human-readable sizes, largest last
|
alias lt='ll -tr' # long format, newest modification time last
|
||||||
alias lt='ll -tr' # human-readable sizes, most recent last
|
alias lc='lt -c' # long format, newest status change (ctime) last
|
||||||
alias lc='lt -c' # human-readable sizes, most recent last, change time
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -92,19 +96,10 @@ fi
|
||||||
# Resource Usage
|
# Resource Usage
|
||||||
#
|
#
|
||||||
|
|
||||||
alias df='df -kh'
|
alias df='df -h'
|
||||||
alias du='du -kh'
|
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.
|
# 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 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
|
if (( ${+commands[safe-rm]} && ! ${+commands[safe-rmdir]} )); then
|
||||||
|
|
Loading…
Reference in a new issue