Tool Commands/Shortcuts
Powershell Commands
- To get to Powershell, you can type
powershellinto the top command line in windows explorer just likecmd. - Navigating Folders and Files
pwd- To print the current directoryls- To list all options in the current folderls -la- List everything in current directorycd xxx- To change directory to the next typed characterscd ~- To change directory back to the root levelcd ..- To change directory back up one levelcat xxx- To print the contents of a filehistory- To print the history of commands
- Modifying Files
mkdir xxx- To create a new folder with the name of the next typed characterstouch xxx- To create a new file with the name of the next typed characterscode xxx- To open a file in VS Codecp xxx yyy- To copy a file from xxx to yyymv xxx yyy- To move a file from xxx to yyyrm xxx- To remove a file>- To overwrite a file, e.g.echo "Hello World" > hello.txtwill overwrite the file hello.txt with "Hello World">>- To append a call to a file, e.g.echo "Hello World" >> hello.txtwill append "Hello World" to the end of the file hello.txt
- Aliases
- To open your bash alias file, navigate to the root folder using
cd ~and then open usingcode .bash_aliases. This should open the file up in VS Code. alias- To print all aliasesalias xxx="yyy"- To create a new alias, e.g.alias g="git"will create an alias for git
- To open your bash alias file, navigate to the root folder using
PowerShell Aliases Example
See my PowerShell Aliases GitHub repo for the aliases I use.
The below example shows how to create a PowerShell alias for opening the PowerShell profile file in VS Code or Cursor and then setting an alias for a folder in the Documents folder.
# Add a welcoming message
Write-Host "PowerShell profile loaded from `C:\Users\bangs\Documents\Coding Projects\PowerShell-Aliases\Microsoft.PowerShell_profile.ps1`!" -ForegroundColor Yellow
function OpenAliasFunction {
param (
[string]$Path = $PROFILE
)
try {
code $Path
} catch {
Write-Host "'code' failed, trying 'cursor'..." -ForegroundColor Yellow
try {
cursor $Path
} catch {
Write-Host "Both editors failed to launch." -ForegroundColor Red
}
}
}
Set-Alias openalias OpenAliasFunction
Set-Alias profile OpenAliasFunction
# Define the folder path variable
$folderPath = "C:\Users\bangs\Documents\Coding Projects\"
function CodingFunction {
$fullPath = $folderPath
set-location $fullPath
}
Set-Alias coding CodingFunction
Git Commands
git clone https://git.rle.de/deloitte/deloitte-pm-tool.git- Clone a repo from the provided URLgit init- Initiate a git repositorygit remote add origin https://github.com/bangsluke/hacker-stories.git- Add a GitHub repositorygit branch -M main- Switch to the main branchgit commit -m "Initial commit"- Commit with the message (-m) "Initial commit"git push -u origin main- Push to the main branchgit fetch --prune- Fetch all branches and remove remote deleted branchesgit commit --allow-empty -m 'Empty commit'- Trigger the CI/CD pipeline with a blank commitgit rev-list --all | xargs git grep "git"- Search for the word "git" in all files of all commits
VS Code Commands
Ctrl + P- Open the file searchCtrl + Shift + P- Open the command paletteCtrl + D- Multi select (highlight a word and then press multiple times to select all words to type and replace)Ctrl + Space- Autocomplete the word (and auto import)Ctrl + Shift + K- Delete the current code lineAlt + Up/Down- Move the current line up or downAlt + Shift + Up/Down- Copy the current line up or down
Chrome Shortcuts
Ctrl + Shift + J- Open Chrome dev tools console
VBA Shortcuts
F5- Run the current scriptF8- Run the current line of codeCtrl + Y- Delete the current code line