Last active
April 22, 2022 14:44
-
-
Save andyhasit/d48de8995598fcfb8c316f1a0d6110e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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