Skip to content

Instantly share code, notes, and snippets.

@chklauser
Created April 4, 2016 07:21
Show Gist options
  • Save chklauser/913193931f7ed8add50387eb0b4c10ca to your computer and use it in GitHub Desktop.
Save chklauser/913193931f7ed8add50387eb0b4c10ca to your computer and use it in GitHub Desktop.
Bash lk: call `less` or `ls -l` depending on context
# 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