Tips and Tricks
General tips and tricks to make your life easier
This guide will provide some useful tips and tricks that have been useful for me while working on SplashKit.
Setting Git Bash terminal as default in VS Code
By setting the terminal to Git Bash in VS Code you can compile and run your code without having to open a new terminal and changing directory to your working directory.
To do this:
- Open VS Code
- Open a new terminal by pressing
Ctrl + Shift + `
or Terminal tab -> new terminal - In the terminal, locate the small drop down arrow to the top right
- In the drop down menu click “Select Default Profile”
- You should see a drop down menu at the top of the window with a list of terminals where you can
select Git Bash or your terminal of choice.
- Select the terminal you would like as the default terminal within VS Code. I recommend Git Bash
By following these steps, VS Code will automatically open an embedded terminal in your working directory. No more alt-tabbing when building your SplashKit projects.
Setting up aliases in your Bash terminal
Constantly typing the same lengthy commands can become tedious so by setting up aliases you can save yourself a bunch of time. Whether it is shortened git commands or a compilation command for C++ aliases are a great time saver.
To create Aliases:
-
Open a new terminal
-
Enter the command
nano ~/.bashrc
-
In the text editor create the alias you want to use as such:
alias name='command'
-
Once you have added the aliases you wish to use, to exit the nano editor and save changes press
Ctrl + X
-
When prompted to save changes press
Y
and thenenter
. This should close the editor and take you back to the terminal -
Now to apply the changes enter the command
source ~/.bashrc
or restart your terminal
Now when you enter your alias it should run the command you have set. Some Aliases I use are:
Aliases | Purpose |
---|---|
alias gc='git checkout' | allows gc branchname for easier branch switching |
alias gcm='git checkout main' | quickly get to main branch |
alias skcompile='skm clang++ \*.cpp -o a && ./a | quickly compiles and runs C++ SplashKit projects in one command |
These are some example aliases but you can do pretty much anything. If there are any commands you find yourself typing and think “Man this is tedious” just make a new alias for it!
Useful VS Code Extensions
These are some helpful extensions that you can add to VS Code that may help with your workflow
Extension | Description |
---|---|
C/C++ and C# | Syntax highlighting, IntelliSense, and debugging tools. |
IntelliCode | Offers tools like line autocomplete and code suggestions |
GitHub Pullrequests | Lets you work on existing pull requests in your local developer environment |
GitLens | Better Git history and inline blame tools. |
Prettier | Automatically Formats your code (doesn’t work on all languages) |
Code Spell Checker | Spell checks your code |
Enable format on save
Enabling format on save will allow your formatting extensions like Intellisense or prettier to format your code automatically when you save the document.
To enable this:
- Go to File -> Preferences -> Settings or
Ctrl + ,
- In the search bar type “Format on save”
- Enable the Format on save box
Common Git Commands
Command | Purpose |
---|---|
git pull upstream main | Pulls changes from the main branch of the upstream repo – great to run at the start of the day |
git clean -df | Removes untracked files and directories - helpful if you forget a branch name |
git branch | Lists all branches in your repo - good if you have forgotten the name of a branch |
git stash | Temporarily stores uncommitted changes so you can switch branches or pull updates |
git checkout -b <name> | Allows the creation and checkout of branch in 1 command |
git add . | Stages all changed files in the current directory and below |
git status | Shows staging area - Useful to see what will be committed |
git commit -m "message | Commits and creates messages in 1 command |
git reset --hard | Resets your working directory to last commit - Useful if you make some breaking changes and cannot fix. use with care |