Skip to content

Instantly share code, notes, and snippets.

@andyhasit
Last active April 22, 2022 14:44
Show Gist options
  • Save andyhasit/d48de8995598fcfb8c316f1a0d6110e0 to your computer and use it in GitHub Desktop.
Save andyhasit/d48de8995598fcfb8c316f1a0d6110e0 to your computer and use it in GitHub Desktop.
# A shell function you can use to:
# - ls a dir
# - tail a file
# - edit a file
# - remove a file or directoty
lp () {
if [[ -z $1 ]]; then
path=.;
else
path=$1;
fi;
if [[ -z $2 ]]; then
if [[ -d $path ]]; then
ls --color=auto -ahl $path;
else
if [[ -f $path ]]; then
tail -n 100 $path;
else
echo "$path is not a file or directory";
fi;
fi;
else
if [[ $2 == "d" ]]; then
rm -r $path;
else
if [[ $2 == "e" ]]; then
nano $path;
else
echo "$2 is not a valid flag (e, d)";
fi;
fi;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment