Created
April 4, 2016 07:21
-
-
Save chklauser/913193931f7ed8add50387eb0b4c10ca to your computer and use it in GitHub Desktop.
Bash lk: call `less` or `ls -l` depending on context
This file contains hidden or 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
# Bash function that calls `less` and `ls -l` depending on whether | |
# the target is a file or a directory. Surprisingly pleasant to use. | |
function lk { | |
local p | |
if [[ $# -lt 1 ]] ; then | |
p='.' | |
else | |
p="$1" | |
fi | |
if [[ -d $p ]] ; then | |
ls -l -h "$p" | |
else | |
less "$p" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment