DWIM List/Viewer
Came up with this a few years ago and later refactored and added QuickLook. I love it for exploring a directory tree. I think of it as "show me thing" and don't make me think too much about what thing is.
Usage:
- List a directory:
l dirname
- List some files:
l **/*rb
- Page a file:
l filename
- Uncompress and page:
l filename.(gz|bz2)
- View with quicklook:
l filename.(pdf|png|jpg)
function l {
if [[ $# -eq 1 && -f "$1" ]]; then
pager "$1"
else
ls -CFL $*
fi
}
function pager {
case "$1" in
*gz)
LESSOPEN='|gzip -cdfq -- %s' "$PAGER" "$1"
;;
*bz|*bz2)
LESSOPEN='|bzip2 -cdfq -- %s' "$PAGER" "$1"
;;
*pdf|*png|*jpg)
ql "$1"
;;
*)
"$PAGER" "$1"
;;
esac
}
function ql {
# Open QuickLook on file (OSX)
qlmanage -p $*
}
Written by Steven Lumos
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Related Tags
#shell
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#