Skip to content

Instantly share code, notes, and snippets.

@fspot
Created July 9, 2013 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fspot/5955736 to your computer and use it in GitHub Desktop.
Save fspot/5955736 to your computer and use it in GitHub Desktop.
alias l="l.sh" => use simply l instead of ls or less
#!/bin/bash
LSCMD="ls --color=auto -lahF"
LESSCMD="less"
if [ $# -eq 0 ]; then
$LSCMD
exit 0;
fi
# with argument :
if [ ! -e "$1" ]; then
echo "$1 does not exist."
elif [ -f "$1" ]; then
# $1 is a file
$LESSCMD "$1"
elif [ -d "$1" ]; then
# $1 is a directory
$LSCMD "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment