Skip to content

Commit

Permalink
modified names for better namespace safety
Browse files Browse the repository at this point in the history
  • Loading branch information
egurapha committed Jan 27, 2025
1 parent d26cdc5 commit abad2d2
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 181 deletions.
26 changes: 13 additions & 13 deletions src/add_bookmark.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
#!/bin/bash

# Imports.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR"/colors.sh
source "$SCRIPT_DIR"/functions.sh
SHUNPO_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SHUNPO_SCRIPT_DIR"/colors.sh
source "$SHUNPO_SCRIPT_DIR"/functions.sh

# File to store bookmarks.
MAX_BOOKMARKS=128
SHUNPO_MAX_BOOKMARKS=128

# Ensure the bookmarks file exists and is not empty
if [ ! -f "$BOOKMARKS_FILE" ]; then
touch "$BOOKMARKS_FILE"
if [ ! -f "$SHUNPO_BOOKMARKS_FILE" ]; then
touch "$SHUNPO_BOOKMARKS_FILE"
fi

# Check the number of existing bookmarks.
current_bookmarks=$(wc -l <"$BOOKMARKS_FILE")
current_bookmarks=$(wc -l <"$SHUNPO_BOOKMARKS_FILE")

# If the bookmarks list is full, print a message and do not add the new bookmark.
if [ "$current_bookmarks" -ge "$MAX_BOOKMARKS" ]; then
echo -e "${CYAN}${BOLD}Bookmarks list is full!${RESET} Maximum of $MAX_BOOKMARKS bookmarks allowed."
if [ "$current_bookmarks" -ge "$SHUNPO_MAX_BOOKMARKS" ]; then
echo -e "${SHUNPO_CYAN}${SHUNPO_BOLD}Bookmarks list is full!${SHUNPO_RESET} Maximum of $SHUNPO_MAX_BOOKMARKS bookmarks allowed."
exit 1
fi

# Save the current directory to the bookmarks file.
current_dir=$(realpath "$PWD")
if ! grep -q -x "$(printf '%s\n' "$current_dir")" "$BOOKMARKS_FILE"; then
echo "$current_dir" >>"$BOOKMARKS_FILE"
echo -e "${GREEN}${BOLD}Bookmark added:${RESET} $current_dir"
if ! grep -q -x "$(printf '%s\n' "$current_dir")" "$SHUNPO_BOOKMARKS_FILE"; then
echo "$current_dir" >>"$SHUNPO_BOOKMARKS_FILE"
echo -e "${SHUNPO_GREEN}${SHUNPO_BOLD}Bookmark added:${SHUNPO_RESET} $current_dir"
else
echo -e "${ORANGE}${BOLD}Bookmark exists:${RESET} $current_dir"
echo -e "${SHUNPO_ORANGE}${SHUNPO_BOLD}Bookmark exists:${SHUNPO_RESET} $current_dir"
fi
14 changes: 7 additions & 7 deletions src/clear_bookmarks.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash

# Colors and formatting.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR"/colors.sh
source "$SCRIPT_DIR"/functions.sh
SHUNPO_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SHUNPO_SCRIPT_DIR"/colors.sh
source "$SHUNPO_SCRIPT_DIR"/functions.sh

# Remove the bookmarks file if it exists.
if [ ! -f "$BOOKMARKS_FILE" ] || [ ! -s "$BOOKMARKS_FILE" ]; then
echo -e "${ORANGE}${BOLD}No Bookmarks Found.${RESET}"
if [ ! -f "$SHUNPO_BOOKMARKS_FILE" ] || [ ! -s "$SHUNPO_BOOKMARKS_FILE" ]; then
echo -e "${SHUNPO_ORANGE}${SHUNPO_BOLD}No Bookmarks Found.${SHUNPO_RESET}"
exit 1

else
rm "$BOOKMARKS_FILE"
echo -e "${RED}${BOLD}Cleared Bookmarks.${RESET}"
rm "$SHUNPO_BOOKMARKS_FILE"
echo -e "${SHUNPO_RED}${SHUNPO_BOLD}Cleared Bookmarks.${SHUNPO_RESET}"
fi
12 changes: 6 additions & 6 deletions src/colors.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
CYAN='\033[36m'
ORANGE='\033[38;5;208m'
GREEN='\033[38;5;43m'
RED='\033[38;5;203m'
BOLD='\033[1m'
RESET='\033[0m'
SHUNPO_CYAN='\033[36m'
SHUNPO_ORANGE='\033[38;5;208m'
SHUNPO_GREEN='\033[38;5;43m'
SHUNPO_RED='\033[38;5;203m'
SHUNPO_BOLD='\033[1m'
SHUNPO_RESET='\033[0m'
Loading

0 comments on commit abad2d2

Please sign in to comment.