exh-cli-cmd-md

this is a cataloging of commands and shortcuts i have found useful along my coding journey
-
ctrl + f to search for the cli term you are looking for (annotated w/ keywords and descriptions)
-
search using the roman numeral indexed legend for system or technology lookup
Index Technology System
I Visual Studio Code IDE
II Visual Studio IDE
III Bash Terminal
IV Powershell Terminal
V Command Prompt Terminal
VI Oh My Zsh! Terminal
VII Node Framework
VIII .Net Framework
IX Ubuntu Operating System
X Windows Operating System
XI Cron Misc.
XII Postman Misc.
XIII Tree Misc.


:: IDE ::


I. VSCode

open file "side by side" (in new panel)

ctrl + \

open file in second panel

ctrl + enter

focus file explorer panel

ctrl + 0 // <<-- 1, 2, 3 etc.. == panels

focus terminal

ctrl + `

focus source control view

ctrl + shift + g

check for changed settings

ctrl + shift + p // cmd palette
// search by "@modified"
// this will filter only settings
// you have made changes to

inside terminal to do "reverse lookup history" (commands entered)

ctrl + r

goto/go to definition

fn + f12

goto/go to references

shift + fn + f12

select current line

ctrl + l

open markdown preview

ctrl + shift + v

Side by side Markdown edit and preview

ctrl + k, v # ctrl + k, then release, press v

change coding language (inside text editor)

ctrl + k, m # release ctrl + k, then press m

go to line #

ctrl + shift + p
:# 
// backspace the > then :number

navigate history (tabs?)

ctrl + tab
alt + left # navigate back
alt + right # navigate forward

navigate to specific line

ctrl + g

add additional cursors to all occurrences

ctrl + shift + l

replace all occurrences in the open file

ctrl + h

ctrl + K + M –> “change language mode” –> JSON to format JSON stringified object grabbed from browser

II. Visual Studio

run application

ctrl + fn + f5 # <<-- default run
fn + f5 # <<-- debug run (slower)

open terminal (View.Terminal) shortcut added

ctrl + shift + t

quick launch

ctrl + q # search commands keywords e.g: "new"

multiline comment

shift + alt + a # multi line /* */

ctrl + k, ctrl + / # single line (can be multi) //

ctrl + k, ctrl + c # alternate single line comment
ctrl + k, ctrl + u # uncomment

see all references

alt + 2 // <<-- shows where used

<summary></summary> C#Docs

/// <-- will auto populate this...
/// <summary>
/// Comment goes here
/// </summary>

// e.g.
/// <summary>
/// Comment goes here
/// </summary>
///

Create

create a new file in project

shift + fn + f2 # with Add New File extension
---
ctrl + shift + a
ctrl + n # alternate option
ctrl + shift + n # new project

create new Class in project (custom) (j === insert)

ctrl + shift + j, c // release then press c

create new Interface in project (custom) (j === insert)

ctrl + shift + j, i // release then press i

format

ctrl + k, ctrl + d # formats entire DOCUMENT (d = doc)
ctrl + k, ctrl + f # formats selection (f = format)

focus text editor

esc # literally, just hit escape once...

navigate tabs | close tabs

ctrl + tab # next tab
ctrl + shift + tab # prev tab
ctrl + fn + f4 # close active tab
alt + w + l # close all tabs

navigate to solution explorer

ctrl + alt + l # ctrl + tab navigate tabs here too
ctrl + ; # to solution explorer w/ search bar

go to line start

fn + k # k === "home"
ctrl + / + leftArrow # Edit.LineStart

go to line end

fn + , # , === "end"
ctrl + / + rightArrow # Edit.LineEnd

go to Class(?)

ctrl + click // highlighted class

search file name

ctrl + , # type name of file to find

Go To

ctrl + g # go to line
fn + f12 # go to definition
ctrl + fn + f12 # go to declaration
ctrl + d # go to next (highlighted selection)

Go To All (NICE)

ctrl + t # backspace to clear out "symbol"

navigate back to prev window

ctrl + -

find closing brace

ctrl + ]

add cursor above/below

ctrl + alt + upArrow
ctrl + alt + downArrow

collapse/expand code blocks

ctrl + m, ctrl + m

replace

ctrl + h

replace all occurrences

alt + a # once you have entered what you would like to sub

delete to...

ctrl + delete # delete to start of word
ctrl + backspace # delete to end of word

save all

ctrl + shift + s

view in browser

ctrl + shift + w

bookmark (a keyboard chord is multiple shortcuts in a row)

ctrl + k, ctrl + k

next split pane

fn + f6

collapse markup element (html)

ctrl + m, ctrl + m

Debugger:

add breakpoint (highlight line first)

fn + f9 # <<-- press again to remove

continue to next breakpoint (inside debugger)

fn + fn5

step over (inside debugger)

fn + f10

step into method (inside debugger)

fn + f11

step out of method (if accidentally stepped in)

shift + fn + fn11

exit debugger

ctrl + shift + fn + f5

replace (find and replace)

ctrl + h

rename all properties

ctrl + r, ctrl + r

solution explorer (folder explorer)

ctrl + alt + l

copyLinesDown (without VSCode extra mappings

ctrl + d

alternate copyLinesDown option

# without any selection
ctrl + e
ctrl + v
alt + up/down # <<-- to move

extensions with .user will not get checked-in

httpenv.json.user

auto fix suggestions

alt + enter

compile/build application show error/warning outputs

ctrl + shift + b

Refactor

extract method

ctrl + r, ctrl + m

Object Browser

ctrl + alt + j

Code Snippets (inside VS)

populate snippets from context menu

ctrl + k, ctrl + x
# for example, surround With or e.g. Wrap {} w/ braces

Unity in VS

view Unity Project Explorer

alt + shift + e
// filters sln/proj to unity files


:: TERMINAL ::


III. Bash

following are bash specific

Explorer Windows File System (so helpful connecting sub-system partition to main OS) open windows file explorer GUI for WSL

explorer.exe .
How to echo or cat write to a file with Bash:
cat >> /path/to/existingFile.text<< EOF
some text line 1
some text line 2
some text line 3
EOF

switch cat >> to cat > to create a file instead of append

cat > /path/to/newFile.text<< EOF
some text line 1
some text line 2
some text line 3
EOF

(( expression )) <– this will execute/perform an expression

print BASH env

printenv

echo variables (example how to access vars in BASH)

echo $LANG # <-- LANG env var (bash)

$RANDOM in BASH will create a random number

echo $RANDOM # <-- 22024 : between 0 and 32767
I=0 # <-- passing this in the terminal will persist a var
(( I++ )) # <-- I will now become 1 and persist
# we don't need to prepend $ for vars in (( expression ))

this will print expressions for (( expression )) operations

help let
View file "long" with permissions list
ls -l

-rw-r--r-- in front of the file indicates the permissions: r = read, w = write, x = execute output: -rwxr-xr-x <– see x by 3 different “users” (all users can execute now)

Give executable permissions to a file
chmod +x filename.whatever

man command is “manual” (like help)

man bash # <-- prints manual for bash
man sleep # <-- prints manual for sleep (binary)

-e flag needed for special characters

echo -e "\n~~ Countdown Timer ~~\n"

lists root of the file system

ls /

ls /bin will list all binaries on the file system. Bash lives here: #!/bin/bash which will use bash commands. we can access other binaries or libraries here

lists bash commands

help

things we can pass to the bash TEST command (for testing true/false (for ifs or [[ EXPRESSIONS ]]))

help test
( expression ) # <-- evaluates expression/returns value
help [[ expression ]] # <-- output below
  ( EXPRESSION )    Returns the value of EXPRESSION
  ! EXPRESSION              True if EXPRESSION is false; else false
  EXPR1 && EXPR2    True if both EXPR1 and EXPR2 are true; else false
  EXPR1 || EXPR2    True if either EXPR1 or EXPR2 is true; else false

When the `==' and `!=' operators are used, the string to the right of
the operator is used as a pattern and pattern matching is performed.
When the `=~' operator is used, the string to the right of the operator
is matched as a regular expression.

The && and || operators do not evaluate EXPR2 if EXPR1 is sufficient to
determine the expression's value.

Exit Status:
Returns success if EXPR evaluates to true; fails if EXPR evaluates to
false or an invalid argument is given.

we can evaluate any expression in the BASH terminal or .sh script:

[[ 4 -le 5 ]] # <-- `-le` === less-than-or-equal

echo $?

echo $? # <-- prints last bash command's EXIT STATUS
0 # <-- 0 === true (0 === no errors)

[[ 4 -ge 5 ]]
echo $?
1 # <-- 1 === false (> 0 === contains errors | "false")
[[ 4 -ge 5 ]]; echo $? # <-- run multiple comands on single line with `;`
1 # <-- output

we can think of 0 return as TRUE but it actually means command had 0 errors (EXIT STATUS)

check if a file exists (and output EXIT STATUS) -a | -e THIS WILL CHECK THE FOLDER FROM WHERE THE COMMAND WAS ENTERED

[[ -a countdown.sh  ]]; echo $?
0 # <-- output 0 if file exists

to list all variables in BASH

declare -p

all variables: @ | *

ARR=("a" "b" "c")
echo ${ARR[@]}

declare -p ARR
# --> declare -a ARR=([0]="a" [1]="b" [2]="c")
# --> -a === array

Read (capture user INPUT)

capture user input

read

Debugging in Bash

set -x at the top of a script enables debugging (printing executed commands to the terminal)

#!/bin/bash

set -x

# Your script goes here

IV. Powershell

list all running processes w/ binary program names

netstat -ba # will require elevated perm
netstat -ban # this will also show IPs

get powershell version

$PSVersionTable.PSVersion

open persistent PS profile file will create new $PROFILE if not exists

code $PROFILE.AllUsersAllHosts

put this inside your $PROFILE.ps1 opens specified dir on shell launch

Set-Location C:\Users\User\Dev

to Set-Alias that takes params

function ListAll { # script block/fn
    Get-ChildItem -Force
}

Set-Alias ls-a ListAll # create Alias/invoke
# Set-Alias -Name list -Value cmdlet/fn
# this above syntax only works for no params

find windows IPs

ipconfig

find WSL IPs

wsl hostname -i
wsl hostname -I

Rename directory (like bash mv)

Rename-Item "D:\temp\Test Test1"

open Visual Studio IDE latest version

start devenv

open Visual Studio IDE specific solution (folder or file)

start devenv solution1.sln # file extension? solution?
# because I have multiple VS installed on my machine, i need to include the entier absolute path to the executable in order to run from CLI

open current folder in windows explorer

ii . # <<-- alias Invoke-item

create a new file

New-Item example.txt

delete recursive rm -rf

Remove-Item -Recurse -Force <path>

V. Command Prompt

display directory contents

dir // <<-- windows/cmd version of `ls`

initiate reboot ("windows terminal")

shutdown /r /t 0
(this might only work in windows terminal)

VI. Oh My ZSH!

runs zsh powerlvl10k setup (prompt styling)

p10k configure


:: FRAMEWORKS ::


VII. Node

find all running node processes

ps -ef | grep node

find node process by port

lsof -i :3000

kill process

kill -9 PROCESS_ID

VIII. .Net

restore nuget packages

dotnet restore

run C# program.cs (entry point)

dotnet run

create new console app .NET

dotnet new console -o ./CsharpProjects/TestProject
# pass `--use-program-main` for Program Class template

(VSCODE) generate assets for build and debug

ctrl + shift + p // cmd pallette
// enter ".net: g"
// select ".NET: Generate Assets for Build and Debug"


:: Operating System ::


IX. Ubuntu

check Ubuntu version

lsb_release -a

search for software to install <application>

sudo apt search <audacity>

install from cli

sudo apt install audacity

killall <-- terminates process

killall <snap-store>

X. Windows

dumbest windows shortcut ever switch entire windows dekstop

ctrl + win + right // next (new)
ctrl + win + left // prev (all old)

inside file explorer:

ctrl + l   // focus address bar
cmd        // enter cmd to open cmd in this location
powershell // open powershell in this location

anywhere, but useful inside file explorer more options include copy path, open powershell here, open linux shell here

shift + right-click // opens menu with more options


:: Misc. ::


XI. Cron

For Ubuntu/Debian, you can find cronlogs at:

/var/log/syslog

XII. Postman

variables created/stored in "Environments" in postman can be passed into fields using

Client ID: 
Client Secret: 
grep nri // <--

To get a list of all listening TCP ports using lsof

sudo lsof -nP -iTCP -sTCP:LISTEN

using ss tool (formerly netstat) to list all open ports

ss -tulpn

XII. Tree

tree [OPTIONS] [directory] (“.” might not be necessary) List folder structure only directories from current directory

tree -d .

List folder structure only directors at depth 1

tree -d -L 1 .

List folder structure and all hidden files

tree -a .