Created
May 3, 2018 09:00
-
-
Save rbeer/c2ba68608fb1de956c8f5b834320ac34 to your computer and use it in GitHub Desktop.
Less-ls; ls for directories, less for files - in one single `ls` alias
This file contains 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
#!/bin/bash | |
LS_PATH=$1 | |
function lsFallback() { | |
/bin/ls -alh --color=auto $LS_PATH | |
exit $? | |
} | |
if [ "$LS_PATH" == "" ]; then lsFallback; fi | |
file $LS_PATH 2> /dev/null | grep -o text &> /dev/null | |
if [ $? -gt 0 ]; then | |
lsFallback | |
else | |
more $LS_PATH | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment