-
-
Save tachoknight/b57da58a3ddb4f3f52f8480a90757a9f to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| help() { | |
| cat << EOF | |
| Options: | |
| -1 one file per line | |
| -k bytes | |
| -F classify | |
| -R recurse | |
| -r reverse | |
| -d don't list directory contents | |
| -G group directories first * | |
| -I ignore [GLOBS] | |
| -i show inodes | |
| -S sort by file size | |
| -t sort by modified time | |
| -u sort by accessed time | |
| -U sort by created time * | |
| -X sort by extension | |
| -T tree * | |
| -L level [DEPTH] * | |
| -s file system blocks | |
| -g git status of files * | |
| -x list by lines, not columns | |
| -H help | |
| * not used in ls | |
| EOF | |
| exit | |
| } | |
| exa_opts=() | |
| rev=0 | |
| while getopts ':aAt1lFRrdIiTkLsuUSrghxXG' arg; do | |
| case $arg in | |
| a) exa_opts+=(-a -a) ;; | |
| A) exa_opts+=(-a) ;; | |
| t) exa_opts+=(-s modified); ((++rev)) ;; | |
| u) exa_opts+=(-us accessed); ((++rev)) ;; | |
| U) exa_opts+=(-Us created); ((++rev)) ;; | |
| S) exa_opts+=(-s size); ((++rev)) ;; | |
| G) exa_opts+=( --group-directories-first) ;; | |
| r) ((++rev)) ;; | |
| k) exa_opts+=( -B) ;; | |
| g) exa_opts+=(--git) ;; | |
| s) exa_opts+=( -S) ;; | |
| X) exa_opts+=( -s extension) ;; | |
| 1|l|F|R|d|I|i|T|L|x|h) exa_opts+=(-"$arg") ;; | |
| H) help ;; | |
| *) printf 'Error: exa-wrapper\n -H for help\n' >&2; exit 1 | |
| ;; | |
| esac | |
| done | |
| shift "$((OPTIND - 1))" | |
| if (( rev == 1 )); then | |
| exa_opts+=(-r) | |
| fi | |
| if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == true ]]; then | |
| exa --color-scale --color=always --git -gH "${exa_opts[@]}" "$@" | |
| else | |
| exa --color-scale --color=always -gH "${exa_opts[@]}" "$@" | |
| fi |
Ah, I see that the a flag is already showing the size in human readable format. I was trying to replicate the muscle-memory of typing ls -lah so I can see everything in column format with human-readable file sizes.
Yeah, I know what you mean. The whole reason I did this in the first place was that I had years of muscle memory typing ls -Al and exa has no -A switch so came up with an error. Maybe I should modify the script to make it even more identical to ls for those like yourself. I always had an ls -h --colour=auto alias.
Hi, I have updated the wrapper script to include the -h switch for human-readable and added a couple of options.
Hi, I have updated the wrapper script to include the -h switch for human-readable and added a couple of options.
It works great! Thanks for doing that!
Hi. Your modifications aren't going to work as you intend. I'm not exactly sure what you want to do, so I'm not sure how to make the
hswitch work as you want, but you will need to remove theHs from lines 62 and 64 and add it to the letters in line 34. You also need to removehfrom line 48 and make a new line to make it do the thing that you want, as-hadds the header over the columns in exa and-Hadds the links column, so you need to override them. Cheers.