rewrote mark in c.

This commit is contained in:
Josh Ashton
2023-06-25 01:29:45 -06:00
parent 3206768096
commit b328da905f
2 changed files with 86 additions and 54 deletions
-54
View File
@@ -1,54 +0,0 @@
#!/bin/bash
BOOKMARKS_FILE=~/.bookmarks
# Catch any invalid input.
if [[ $# -gt 1 ]]; then
echo "Improper usage: mark { -ls | -rm [ keyword ] }"
echo " eg. mark"
echo " eg. mark -ls"
echo " eg. mark -rm portfolio"
echo " eg. mark -h"
echo " eg. mark --help"
exit
# Help page
elif [[ $1 == "-h" || $1 == "--help" ]]; then
echo "\nCreate and manage persistent bookmarks inside of terminal sessions.\n"
echo "Usage:"
echo " mark"
echo " mark -ls"
echo " eg. run main"
echo " mark -rm [ keyword ]"
echo " eg. mark -rm portfolio"
echo " mark -h"
echo " mark --help"
exit
# Add a bookmark to the bookmarks file.
elif [ $# == 0 ]; then
echo $(pwd) >> $BOOKMARKS_FILE
# List bookmarks stored in the bookmarks file.
elif [ "$1" == "-ls" ]; then
echo "Bookmarks:"
cat $BOOKMARKS_FILE
# Remove a bookmark stored in the bookmarks file.
elif [ "$1" == "-rm" ]; then
# The user is trying to remove a single bookmark
# Check if the bookmark exists
if [ $(grep -c "$2" $BOOKMARKS_FILE) -gt 0 ]; then
# Remove the bookmark
sed -i .bak $2d $BOOKMARKS_FILE
else
echo "Bookmark not found"
fi
# Invalid argument, display an error message
else
echo "Usage: mark [-ls] [-rm [number | number TO number]]"
fi