Skip to content

Instantly share code, notes, and snippets.

@slumos
Created June 25, 2016 22:40
Show Gist options
  • Save slumos/d9abdb6adfabbfeb6be6375c9fa54527 to your computer and use it in GitHub Desktop.
Save slumos/d9abdb6adfabbfeb6be6375c9fa54527 to your computer and use it in GitHub Desktop.
function l {
if [[ ! -t 0 ]]; then
# stdin is not connected to a tty
pager -
elif [[ $# -eq 1 && -f "$1" ]]; then
# single argument names a file
pager "$1"
else
ls -CFL $*
fi
}
function pager {
case "$1" in
*asc)
gpg -dq "$1" | pager -
clear
;;
*bz|*bz2)
LESSOPEN='|bzip2 -cdq -- %s' "$PAGER" "$1"
;;
*gz)
LESSOPEN='|gzip -cdq -- %s' "$PAGER" "$1"
;;
*pdf|*png|*jpg)
ql "$1"
;;
*xz)
LESSOPEN='|xz -cdq -- %s' "$PAGER" "$1"
;;
*)
"$PAGER" "$1"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment