Skip to content

Instantly share code, notes, and snippets.

@rbeer
Created May 3, 2018
Embed
What would you like to do?
Less-ls; ls for directories, less for files - in one single `ls` alias
#!/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