Skip to content

Instantly share code, notes, and snippets.

@Inobtenio
Created September 20, 2017 03:22
Show Gist options
  • Save Inobtenio/0a8739373ae1ed8786cc9807870de35f to your computer and use it in GitHub Desktop.
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.
#!/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
#!/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