Skip to content

Instantly share code, notes, and snippets.

@yankikucuk
Last active September 13, 2019 06:36
Show Gist options
  • Save yankikucuk/eef01f9fb6dd985a7c1fb2a3f6efc86c to your computer and use it in GitHub Desktop.
Save yankikucuk/eef01f9fb6dd985a7c1fb2a3f6efc86c to your computer and use it in GitHub Desktop.
Useful and simple terminal commands
#!/bin/bash
# - steps
# 1. download to dekstop
# 2. for permission denied: chmod u+x ~/Desktop/project.sh
# 3. move to /usr/local/bin
# ... profit ...
# path to desired location for starting new project folder
# this folder contains your default .vscode .github folders
# and maybe example README.md and more.
pathToCopy="/path/to/desired/location/."
# your github name not url
githubName="YOUR_GITHUB_NAME"
if [ -z $1 ]
then
exit
elif [[ "$1" = "new" || "$1" = "-n" ]]
then
read -r -p "What is your new project name? " projectName
prjName=$projectName
read -r -p "Any optional destination? " dest
dstName=$dest
from=$pathToCopy
if [ "$dstName" ]
then
to="$dstName"
else
to="./"
fi
cp -a $from $to$prjName
echo "Your starting project has been created!"
exit
elif [[ "$1" = "push" || "$1" = "-p" ]]
then
read -r -p 'Commit message: ' desc
cMessage=$desc
read -r -p 'Branch name (master): ' branchName
brnchName=$branchName
git add .
git add -u
git commit -m "$cMessage"
if [ "$brnchName" ]
then
bName="master:"$brnchName
else
bName="master"
fi
git push origin $bName
exit
elif [[ "$1" = "clone" || "$1" = "-c" ]]
then
if [ -z $2 ]
then
read -r -p 'What is repo name: ' repoName
rName=$repoName
else
rName=$2
fi
git clone https://github.com/$githubName/$rName.git
exit
elif [[ "$1" = "browse" || "$1" == "-b" ]]
then
if [ -z $2 ]
then
echo "You must type issues or pulls"
exit
else
if [[ "$2" = "issues" || "$2" == "-i" ]]
then
if [ -z $3 ]
then
read -r -p "Repo name for issues? " issueRepoName
if [ -z $issueRepoName ]
then
exit
else
open https://github.com/$githubName/$issueRepoName/issues
exit
fi
else
open https://github.com/$githubName/$3/issues
exit
fi
elif [[ "$2" = "pulls" || "$2" == "-pr" ]]
then
if [ -z $3 ]
then
read -r -p "Repo name for pull requests? " pullRepoName
if [ -z $pullRepoName ]
then
exit
else
open https://github.com/$githubName/$pullRepoName/pulls
exit
fi
else
open https://github.com/$githubName/$3/pulls
exit
fi
else
exit
fi
fi
elif [[ "$1" = "help" || "$1" == "-h" ]]
then
echo "project -n or new"
echo " {project name}"
echo " {optional destination}"
echo " -p or push"
echo " {commit message}"
echo " {branch name}"
echo " -c or clone"
echo " {repo name}"
echo " -b or browse"
echo " -i or issues"
echo " {repo name}"
echo " -pr or pulls"
echo " {repo name}"
echo " -h or help"
echo " "
exit
else
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment