reverted goto, C version wasn't working and fish script wasn't working
This commit is contained in:
@@ -1,55 +1,41 @@
|
|||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
|
|
||||||
# Define the location of the bookmarks file
|
# Dependencies:
|
||||||
bookmarks_file="$HOME/.bookmarks"
|
# quaxlyqueen/scripts/mark
|
||||||
|
|
||||||
# Function to display usage information
|
BOOKMARKS_FILE="/home/violet/.bookmarks"
|
||||||
help() {
|
|
||||||
echo "\nQuickly navigate to saved bookmarks in the terminal.\n"
|
|
||||||
echo "Usage:"
|
|
||||||
echo " goto downloads"
|
|
||||||
echo " goto school"
|
|
||||||
echo " goto portfolio"
|
|
||||||
echo " goto -h"
|
|
||||||
echo " goto --help"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to validate and change directory
|
# Catch any invalid input.
|
||||||
validate_dir() {
|
if [[ $# -eq 0 || $# -gt 1 ]]; then
|
||||||
local target_dir=$1
|
echo "\nImproper usage. Try:"
|
||||||
|
echo "\ngoto [keyword]"
|
||||||
|
echo " goto downloads"
|
||||||
|
echo " goto school"
|
||||||
|
echo " goto portfolio"
|
||||||
|
echo " goto -h"
|
||||||
|
echo " goto --help"
|
||||||
|
|
||||||
# Check if bookmarks file exists
|
# Display help.
|
||||||
if ! test -f "$bookmarks_file"; then
|
|
||||||
echo "Error accessing bookmarks file: $bookmarks_file"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Read each line in the bookmarks file
|
|
||||||
while IFS= read -r line; do
|
|
||||||
# Check if the line contains the target directory
|
|
||||||
if [[ $line == *$target_dir* ]]; then
|
|
||||||
# Change directory and exit
|
|
||||||
cd "$line"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
done < "$bookmarks_file"
|
|
||||||
|
|
||||||
# Target directory not found in bookmarks
|
|
||||||
echo "Directory '$target_dir' not found in bookmarks."
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check for valid number of arguments
|
|
||||||
if [[ $# -ne 1 ]]; then
|
|
||||||
echo "Invalid usage. See 'goto --help' for details."
|
|
||||||
return
|
|
||||||
elif [[ $1 == "-h" || $1 == "--help" ]]; then
|
elif [[ $1 == "-h" || $1 == "--help" ]]; then
|
||||||
help
|
echo "\nImproper usage. Try:"
|
||||||
return
|
echo "\ngoto [keyword]"
|
||||||
|
echo " goto downloads"
|
||||||
|
echo " goto school"
|
||||||
|
echo " goto portfolio"
|
||||||
|
echo " goto -h"
|
||||||
|
echo " goto --help"
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
# Locate the bookmark.
|
||||||
|
if [ $(grep -c "$1" $BOOKMARKS_FILE) -gt 0 ]; then
|
||||||
|
|
||||||
|
# Go to the bookmark
|
||||||
|
cd $(grep "$1" $BOOKMARKS_FILE | head -n 1)
|
||||||
|
|
||||||
|
# List bookmarks if bookmark was not found.
|
||||||
|
else
|
||||||
|
echo "Bookmark not found. Available bookmarks:"
|
||||||
|
mark -ls
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate and change directory based on argument
|
|
||||||
validate_dir $1
|
|
||||||
|
|
||||||
# Exit script (should be reached after successful directory change)
|
|
||||||
return
|
|
||||||
|
|||||||
+14
-1
@@ -8,7 +8,7 @@
|
|||||||
# quaxlyqueen/scripts/ginit
|
# quaxlyqueen/scripts/ginit
|
||||||
|
|
||||||
# Supported languages.
|
# Supported languages.
|
||||||
TYPES=("c", "rust", "c-sharp", "aspnet", "java", "js", "t3", "python", "flutter", "go")
|
TYPES=("c", "rust", "c-sharp", "aspnet", "java", "js", "t3", "python", "flutter", "go", "php")
|
||||||
|
|
||||||
# Catch case where there are too many arguments.
|
# Catch case where there are too many arguments.
|
||||||
if [[ $# -gt 3 ]]; then
|
if [[ $# -gt 3 ]]; then
|
||||||
@@ -157,6 +157,19 @@ elif [[ $LANG == "flutter" ]]; then
|
|||||||
elif [[ $LANG == "t3" ]]; then
|
elif [[ $LANG == "t3" ]]; then
|
||||||
npm create t3-app@latest
|
npm create t3-app@latest
|
||||||
|
|
||||||
|
elif [[ $LANG == "go" ]]; then
|
||||||
|
mkdir $NAME;
|
||||||
|
cd $NAME;
|
||||||
|
|
||||||
|
go mod init;
|
||||||
|
|
||||||
|
# Create a new Flutter/Dart project.
|
||||||
|
elif [[ $LANG == "php" ]]; then
|
||||||
|
mkdir $NAME
|
||||||
|
cd $NAME
|
||||||
|
cp -r ~/templates/web/php/index.php .
|
||||||
|
mark
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the user indicated the project will be a Git project, then run the ginit script.
|
# If the user indicated the project will be a Git project, then run the ginit script.
|
||||||
|
|||||||
Reference in New Issue
Block a user