A bunch of helpful aliases for a fast, efficient workflow. Most of the important functions are listed below. Take a look!
You will first need to make sure you have a ~/.profile file. To ensure you do, run the command:
touch ~/.profileIn your .zshrc, or .bashrc depending on which you see in your User directory or are currently using, open it by running open ~/.zshrc or open ~/.bashrc.
Note: If you don't know which one you are using, run
echo $0. This should display "-zsh" or "-bash". Use whichever one displays or install and choose your own. You can follow these steps to install zsh.
Then, add in the following line to the end of that file:
source ~/.profileThis ensures the aliases are loaded for every terminal session.
To get started, you will need to add the code in this .profile file to your .profile file in your User directory ( ~/ ) ( ~/ ).
open ~/.profileReplace all, if any, content with this .profile file in this repo.
After you put the latest code in your .profile, make sure you update the configuration variables.
Example: If your CWS folder is in your User Directory (
~/), you would makeJVPATHequal~/CWS/.
source ~/.profileconfigto open up your .profile, and replace what you have with the code in the .profile in this repo.
After you put the latest code in your .profile, make sure you update the JVPATH variable to reflect the path to your CWS folder.
If your CWS folder is in your User Directory ( ~/ ), for example, you would make JVPATH equal ~/CWS/.
reloadaddStyles()
Add Styles
Using this function will allow you to get the latest Kickoff code into any project.
You can specify where you would like to put it by adding in the path after addStyles, or you can go to that location in your terminal and run addStyles.
Arguments:
| Name | Function | Optional |
|---|---|---|
| branch_name | Name of directory to store kickoff. If empty, uses current directory. | ✓ |
Examples:
git:(<branch_name>) $ addStyles
git:(<branch_name>) $ addStyles ./myfoldercamp()
Commit. Add. Message. Push.
This function combines the steps of adding, committing and pushing. It also allows for tagging, if you feel so inclined. You can specify which branch you want to push, or cd into that branch and use the function without specifying.
Caution: This will add all unstaged files. If you want to add only specific files, do a manual git add of the files you want, and then use the cmp function or cam alias
Arguments:
| Name | Function | Optional |
|---|---|---|
| commit_msg | Message for commit. Technically optional, but not recommended to exclude | x |
| -t | Flag for adding a tag | ✓ |
| tag | Value for tag (i.e., v1.0) | ✓ |
| tag_msg | Message for tag | ✓ |
| branch_name | Name of project. If empty, uses current directory. | ✓ |
| -f | Flag for a force push | ✓ |
Examples:
git:(<branch_name>) $ camp <commit_msg>
git:(<branch_name>) $ camp <commit_msg> -f
git:(<branch_name>) $ camp <commit_msg> <branch_name>
git:(<branch_name>) $ camp -t <tag>
git:(<branch_name>) $ camp -t <tag> <commit_msg>
git:(<branch_name>) $ camp -t <tag> -m <tag_msg>
git:(<branch_name>) $ camp -t <tag> -m <tag_msg> <commit_msg>cmp()
Commit. Message. Push.
Use this function to commit and push already staged files. If no files are staged, git add the files you want to commit. If you want to commit all files, use the camp function
Arguments:
| Name | Function | Optional |
|---|---|---|
| commit_msg | Message for commit. | x |
Example:
git:(<branch_name>) $ cmp <commit_msg>gwtn()
Git Worktree New
gwtn is used to create a new worktree for a Git project. It accepts several options and a branch argument.
For adding a new worktree. This function will create the worktree based on the latest, if any, existing GitHub code, installs npm, and does an initial push of the branch if it isn't already set up. Once you run this command, you will be ready to work on this worktree. This will work with both existing and non-existing branches.
Arguments:
| Name | Function | Required | Optional |
|---|---|---|---|
branch_name |
Name of branch/project. | ✓ | |
-h or --help |
Displays a brief help message explaining the usage and options of the function. | ✓ | |
-s or --skip-install or --skip |
Specifies that the installation step should be skipped. | ✓ | |
-no or --noopen |
Specifies that the worktree should not be opened in VSCode. | ✓ | |
-m or --make |
Equivalent to calling gwtn -s -no , which skips installation and opening in VSCode. |
✓ | |
--detach |
Creates the local worktree without creating the branch in the origin repository. | ✓ |
Examples:
# create a new worktree named "mybranch"
gwtn mybranch
# displays a brief help message explaining the usage and options
gwtn -h
# create a new worktree named "mybranch" and skip npm installation without creating the branch in the origin repository.
gwtn mybranch -s --detach
# create a new worktree named "mybranch" without opening the project in VSCode
gwtn mybranch -no
#create a new worktree named "mybranch" with the options to skip installation and not open it in VSCode.
gwtn mybranch -s --noopen
# create a new worktree named "mybranch" and skips both the installation step and opening it in VSCode.
gwtn mybranch -m
# It is equivalent to
gwtn mybranch --skip-install --noopengwtr()
Git Worktree Remove
For removing a worktree. This function will run by using the current location's branch, or by specifying a branch name. If the branch also needs to be deleted, use the -d flag.
Arguments:
| Name | Function | Optional |
|---|---|---|
| -d | Flag to include deleting the branch | ✓ |
| branch_name | Name of branch. If empty, uses current branch. | ✓ |
Examples:
Remove the worktree of the current branch.
git:(<branch_name>) $ gwtr
git:(<branch_name>) $ gwtr -dRemove the worktree of a specific branch.
git:(root) $ gwtr <branch_name>
git:(root) $ gwtr -d <branch_name>new()
New Project Structure
Running this function creates an unobtrusive new starter_branch folder structure. It will add the desktop/, mobile/, images/, and styles/ folders, as well as call addkick, so it will add the latest Kickoff code. If any folders of the same name already exist, they will be untouched and no new folder will be created, leaving all previous work safe, but giving us the opportunity to easily work with the latest code and structure.
Example:
git:(<branch_name>) $ newstart()
Start Kickoff
Running this function will find the nearest folder with npm in your current branch, install npm, and run gulp.
Arguments:
| Name | Function | Required | Optional |
|---|---|---|---|
-i or --install-only |
Installs npm in the nearest folder possible | ✓ | |
-s or --skip-install |
Runs gulp in the nearest folder possible |
✓ | |
-d folder_name or folder_name |
Specifies a directory to run the commands | ✓ |
Examples:
#install npm in your project's styling
start -i
#run gulp in your project's styling
start -s
#install npm in a specified folder
start -i folder_namestats()
Statistics
Using this shows you, by default, the last 50 commits made to the repo.
You can specify how many results you want to see by adding -number after stats
Arguments:
| Name | Function | Optional |
|---|---|---|
| -# | Number of commits to view. Defaults to -50 |
✓ |
Examples:
git:(<branch_name>) $ stats
git:(<branch_name>) $ stats -10add
Git Add
Equivalent to git add
git:(<branch_name>) $ add .
git:(<branch_name>) $ add file.html
git:(<branch_name>) $ add folder/back
Go Back
This will take you back one commit in time.
git:(<branch_name>) $ backbranches
List Branches
This will return a list of all branches in the current repo.
branchescam
Commit. Add. Message.
Using this will add and commit, with a message, all the untracked files in your branch. If you don't want to commit all files, use the normal add, commit -m method.
Arguments:
| Name | Function | Optional |
|---|---|---|
| commit_msg | Message for commit. | x |
Example:
git:(<branch_name>) $ cam <commit_msg>chr
Git Checkout Root
Equivalent to git checkout root
chrchsb
Git Checkout starter_branch
Equivalent to git checkout starter_branch
chsbcm
Git Commit
Equivalent to git commit
Arguments:
| Name | Function | Optional |
|---|---|---|
| commit_msg | Message for commit. | x |
Example:
git:(<branch_name>) $ cm -m <commit_msg>fuck
Fuck
As the name suggests, this is when you've made a terrible oopsie and need to revert back to the origin/master branch.
Caution: This is a HARD reset. It will delete all uncommitted work.
git:(<branch_name>) $ fuckgrv
Git Remote -v
Equivalent to git remote -v.
Use this alias to view the remotes you have referrenced on your machine.
grvgwtl
Git Worktree List
Lists all worktrees
gwtlpeek
Peek
Using this alias allows you to view, by default, the last 20 commits on your current branch.
Very similarly to stats, you can specify how many commits you would like to see.
Arguments:
| Name | Function | Optional |
|---|---|---|
| -# | Number of commits to show. Defaults to -20 |
✓ |
Examples:
git:(<branch_name>) $ peek
git:(<branch_name>) $ peek -5poke
Poke
Equivalent to git push origin/branchName
git:(<branch_name>) $ pokeshit
Shit
Like the name suggests, you would use this when you make a mistake and need to revert to the latest commit.
git:(<branch_name>) $ shitstash
Git Stash
Equivalent to git stash
git:(<branch_name>) $ stash .git:(<branch_name>) $ stash myFile.jsgit:(<branch_name>) $ stash myFolder/stashed
Show Stashed
This shows the current stashed files.
git:(<branch_name>) $ stashedtug
Tug
Equivalent to git pull origin/branchName
git:(<branch_name>) $ tugconfig
Open .profile
Using this function will open your .profile in VS Code, allowing you to make updates to your aliases and functions.
configreload
Reload .profile
Using this function will allow you to reload and use any changes made to your .profile without needed to close your terminal.
reload