Last active
November 12, 2022 04:27
-
-
Save xram64/c716cdf95cfc41183d0348802bed71b5 to your computer and use it in GitHub Desktop.
PowerShell profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #│░░░│ PowerShell profile │░░░│ xram │░░░│ 2022 │░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│ | |
| #———| Notes |—————————————————————————————————————————————————————————————————————————————————————\ | |
| # * This file must be saved using UTF-16LE encoding. | | |
| # * For permissions issues, run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned` as admin. | | |
| #—————————————————————————————————————————————————————————————————————————————————————————————————/ | |
| #———| Example Alias Function |—————————————\ | |
| # function exAliasFunction { | | |
| # params ( $Value ) | | |
| # Write-Output $Value | | |
| # } | | |
| # Set-Alias exAlias exAliasFunction | | |
| # ## Usage: exAlias "Hello world" | | |
| #——————————————————————————————————————————/ | |
| #│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│ | |
| # ┍━━━━━━━━━━━━━━━┑ # | |
| # │ Environment │ # | |
| # ┕━━━━━━━━━━━━━━━┙ # | |
| $Env:LESS = "-R -Q" # less: disable bell and output raw ANSI color control chars | |
| # Set all encodings to UTF-16LE (see `Help about_Character_Encoding`). This seems to break certain things like `less`. | |
| #$OutputEncoding = New-Object System.Text.UnicodeEncoding # default: `System.Text.ASCIIEncoding` | |
| #[Console]::OutputEncoding = [Console]::InputEncoding = New-Object System.Text.UnicodeEncoding # default: `IBM437` | |
| # ┍━━━━━━━━━━━┑ # | |
| # │ Aliases │ # | |
| # ┕━━━━━━━━━━━┙ # | |
| # Bash equivalents | |
| function aliasfn-l { param ($Path); Get-ChildItem -Force -Path $Path } | |
| Set-Alias -Name "l" -Value "aliasfn-l" | |
| function aliasfn-env { Get-ChildItem -Path Env: } | |
| Set-Alias -Name "env" -Value "aliasfn-env" | |
| Set-Alias -Name "which" -Value "Get-Command" | |
| Set-Alias -Name "less" -Value "C:\Program Files\Git\usr\bin\less.exe" | |
| #Set-Alias -Name "find" -Value "...TODO..." | |
| # ┍━━━━━━━━━━━━━━━┑ # | |
| # │ Quick Notes │ # | |
| # ┕━━━━━━━━━━━━━━━┙ # | |
| function aliasfn-psnotes { | |
| Write-Output '' | |
| '‖‖ Profile ‖‖' | |
| ' • Location of profile config (.bashrc equivalent): $PROFILE' | |
| '‖‖ Environment Variables ‖‖' | |
| ' • `Get-Variable` prints only the (local) variables, visible to the current shell process.' | |
| ' • `Get-ChildItem Env:` prints the list of environment variables, visible to any child process.' | |
| ' • Use `$Env:NAME = "VALUE"` to set the NAME variable to VALUE.' | |
| '‖‖ PSDrives ‖‖' | |
| ' • PSDrives are physical and virtual drives managed by the system.' | |
| ' • Use `Get-ChildItem -Path <DRIVE:>` to list all members of <DRIVE:>.' | |
| ' • List all drives using `Get-PSDrive`.' | |
| ' • ⊢— Drives ————————————————————————————————————————————————————————————————————⊣' | |
| ' ↳ Alias: | Holds all available aliases.' | |
| ' ↳ Env: | Holds all environment variables.' | |
| ' ↳ Function: | Holds all available functions.' | |
| ' ↳ Variable: | Holds all local shell variables. Equivalent to `Get-Variable`.' | |
| '' | |
| } | |
| Set-Alias -Name "psnotes" -Value "aliasfn-psnotes" | |
| Set-Alias pshelp psnotes | |
| # ┍━━━━━━━━━┑ # | |
| # │ Other │ # | |
| # ┕━━━━━━━━━┙ # | |
| # Starting directory | |
| #Set-Location $HOME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment