-
-
Save Inobtenio/0a8739373ae1ed8786cc9807870de35f to your computer and use it in GitHub Desktop.
saveproj saves the project name and location to a file. goto takes you to the project you are looking for.
This file contains hidden or 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
#!/bin/bash | |
RED='\033[0;31m' | |
PROJECT_NAME=$1 | |
PROJECTS_REPOSITORY_FILE_FULL_PATH="/path/to/saveproj/output/file" | |
PROJECTS_FOLDER_FULL_PATH="/path/to/your/projects/folder" | |
if ! line=$(grep "\<$PROJECT_NAME\>" $PROJECTS_REPOSITORY_FILE_FULL_PATH) | |
then | |
echo -e "${RED}$PROJECT_NAME not found in projects list. You can create one by using the saveproj tool." | |
else | |
directory_name=${line##* } | |
cd "${PROJECTS_FOLDER_FULL_PATH}${directory_name}" | |
fi |
This file contains hidden or 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
#!/bin/bash | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
PROJECTS_REPOSITORY_FILE_FULL_PATH="/path/to/saveproj/output/file" | |
PROJECT_DIRECTORY_NAME=${PWD##*/} | |
PROJECT_NAME=$1 | |
if line=$(grep -e "$PROJECT_NAME\|$PROJECT_DIRECTORY_NAME" $PROJECTS_REPOSITORY_FILE_FULL_PATH) | |
then | |
echo -e "${RED}$PROJECT_NAME project already exists or you current directory is being used by another project." | |
else | |
printf "$PROJECT_NAME $PROJECT_DIRECTORY_NAME\n" >> $PROJECTS_REPOSITORY_FILE_FULL_PATH | |
echo -e "${GREEN}$PROJECT_NAME added to the projects list." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment