Skip to content

Instantly share code, notes, and snippets.

@gafda
Created March 12, 2024 13:40
Show Gist options
  • Save gafda/54831e1413ce7913d169956775f93d5c to your computer and use it in GitHub Desktop.
Save gafda/54831e1413ce7913d169956775f93d5c to your computer and use it in GitHub Desktop.
Windows 10+ / PowerShell Core initializer
# List of environment variables in Windows 10/11:
# %ALLUSERSPROFILE% – C:\ProgramData
# %APPDATA% – C:\Users\<username>\AppData\Roaming
# %CD% – Typing in this command will give you the current directory you are working in.
# %CMDCMDLINE% – Outputs command line used to launch the current Command Prompt session. (Command Prompt.)
# %CMDEXTVERSION% – This variable expands to the version of the command-line extensions.
# %COMMONPRGRAMW6432% – C:\Program Files\Common Files
# %COMMONPROGRAMFILES% – C:\Program Files\Common Files
# %COMMONPROGRAMFILES(x86)% – C:\Program Files (x86)\Common Files
# %COMPUTERNAME% -Outputs the system name.
# %COMSPEC% – C:\Windows\System32\cmd.exe
# %DATE%: – This variable will give you the current date according to date format preferences.
# %DRVERDATA% – C:\Windows\System32\Drivers\DriverData
# %ERRORLEVEL% – Determines the error level set by last executing command.
# %HOMEDRIVE% – C:\
# %HOMEPATH% -C:\Users\<username>
# %LOCALAPPDATA% – C:\Users\<username>\AppData\Local
# %LOGONSERVER% – \\<domain_logon_server>
# %NUMBER_OF_PROCESSORS% – Outputs the number of physical and virtual cores.
# %ONEDRIVE% – C:\Users\<username>\OneDrive
# %OS% – Windows_NT
# %PATH% – C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem
# %PATHEXT% – .com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc
# %PROCESSOR_IDENTIFIER% – Outputs processor identifier.
# %PROCESSOR_LEVEL% – Outputs processor level.
# %PROCESSOR_REVISION% – Outputs processor revision.
# %PROGRAMDATA% – C:\ProgramData
# %PROGRAMFILES% – C:\Program Files
# %PROGRAMFILES(X86)% – C:\Program Files (x86)
# %PROGRAMW6432% – C:\Program Files
# %PROMPT% – $P$G
# %PSMODULEPATH% – %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\
# %PUBLIC% – C:\Users\Public
# %RANDOM% – This variable prints a random number from 0 through 32767
# %SYSTEMDRIVE% – C:
# %SYSTEMROOT% – C:\Windows
# %TEMP% – C:\Users\<username>\AppData\Local\Temp
# %TIME% – Similarly, it gives you current time according to the time format preferences.
# %TMP% – C:\Users\<username>\AppData\Local\Temp
# %USERDOMAIN% – Userdomain associated with current user.
# %USERDOMAIN_ROAMINGPROFILE% – Userdomain associated with roaming profile.
# %USERNAME% – <username>
# %USERPROFILE% – C:\Users\<username>
# %WINDIR% – C:\Windows
# IMPORTANT NOTES: Depends on:
# > Scoop - https://scoop.sh
# > Oh-My-Posh - https://ohmyposh.dev
# > Docker - https://docs.docker.com/engine/install/
# > Kuberneter CLI - https://kubernetes.io/docs/tasks/tools/
# > Anaconda3 - https://www.anaconda.com/download/
# #####
# Alias
Set-Alias update -Value "$env:HOMEPATH\Documents\tools\update-scoop.ps1"
# #####
# Init.
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/atomic.omp.json" | Invoke-Expression
# ############
# Docker alias
Set-Alias d -Value docker
Set-Alias dc -Value docker-compose
# ###########
# k8s + alias
Import-Module PSKubectlCompletion
Set-Alias k -Value kubectl
Register-KubectlCompletion
# ######
# Extras
Import-Module -Name Terminal-Icons
# ###########
# Conda Alias
function conda-on
{
conda activate $(Split-Path -Path $pwd -Leaf)
}
function conda-create
{
conda create -n $(Split-Path -Path $pwd -Leaf)
}
function conda-destroy
{
conda deactivate
conda remove --name $(Split-Path -Path $pwd -Leaf) --all
}
function conda-off
{
conda deactivate
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment