How to check the used environment (shell):
| Command | |
|---|---|
| Confirm CMD | echo %COMSPEC% |
| Confirm CMD (stronger) | echo %cmdcmdline% |
| Confirm PowerShell | $PSVersionTable |
| Confirm Bash | echo $SHELL |
| Confirm WSL vs Git Bash | uname -a |
for CMD:
notepad C:\Users\%USERNAME%\cmd_aliases.cmd
@echo off
doskey ll=dir /a
doskey cd..=cd ..
doskey gs=git status $*
$* = forward all arguments (like $@ in Bash)CheatSheet:
| Bash | CMD |
|---|---|
alias ll='ls -la' | doskey ll=dir /a |
alias gs='git status' | doskey gs=git status |
alias k='kubectl' | doskey k=kubectl $* |
Auto-run:
reg add "HKLM\Software\Microsoft\Command Processor" ^
/v AutoRun ^
/t REG_SZ ^
/d "C:\Users\%USERNAME%\cmd_aliases.cmd"
for PowerShell
notepad $PROFILE
$TerraformBackends = @{
f1 = "C:\f1.conf"
f2 = "C:\f2.conf"
'f3-hub' = "C:\f4_hub.conf" ### spaces in names are not supported
'f4-spoke' = "C:\f4_spoke.conf" ### hypens (-) are not valid. That is why f3-hub is closed with ''
f5 = "C:\f5-phxmedsl-hub.conf"
}
function init {
param (
[Parameter(Mandatory)]
[ValidateSet("f1", "f2", "f3-hub", "f4-spoke", "f5")]
[string]$Env
)
terraform init --backend-config $TerraformBackends[$Env]
}
Auto-run: (reload ps profile)
. $PROFILE
Execute:
PS C:\init f1
will execute terraform init --backend-config= "C:\f1.conf"
will execute terraform init --backend-config= "C:\f1.conf"
CheatSheet:
| Bash | PowerShell |
|---|---|
alias ll='ls -la' | function ll { Get-ChildItem -Force } |
alias gs='git status' | function gs { git status @args } |
alias k='kubectl' | function k { kubectl @args } |
alias grep='grep --color' | function grep { grep --color=auto @args } |
Няма коментари:
Публикуване на коментар