Skip to content

Instantly share code, notes, and snippets.

@thdtt
Last active May 12, 2022 14:28
Show Gist options
  • Save thdtt/d77a6f9cd53df618310daa66e255160c to your computer and use it in GitHub Desktop.
Save thdtt/d77a6f9cd53df618310daa66e255160c to your computer and use it in GitHub Desktop.
PowerShell profile
# Function
Function cd_home {Set-Location -Path C:\Users\thanh}
Function cd_root {Set-Location -Path C:\}
Function cd_rabbitmq {Set-Location -Path 'C:\Program Files\RabbitMQ Server\rabbitmq_server-3.9.13\sbin'}
Function ls_hidden($path) {Get-ChildItem -Force "$path"}
Function rmf_path($path) {Remove-Item -r -fo "$path"}
Function take_path($path) {
mkdir "$path"
Set-Location -Path "$path"
}
Function get_tail($path) {
Get-Content -Tail 50 "$path"
}
Function get_tailf($path) {
Get-Content -Wait -Tail 50 "$path"
}
Function get_head($path) {
Get-Content -Head 50 "$path"
}
#####################################################################################################################
# Alias
Set-Alias ll ls
Set-Alias grep findstr
Set-Alias touch New-Item
Set-Alias tig 'C:\Program Files\Git\usr\bin\tig.exe'
Set-Alias less 'C:\Program Files\Git\usr\bin\less.exe'
Set-Alias -Name loc -Value Get-Location -Option ReadOnly -Description 'Displays the current directory' -Force
Set-Alias -Name home -Value cd_home
Set-Alias -Name root -Value cd_root
Set-Alias -Name ll -Value ls_hidden
Set-Alias -Name rmf -Value rmf_path
Set-Alias -Name take -Value take_path
Set-Alias -Name vi -Value vim
Set-Alias -Name tail -Value get_tail
Set-Alias -Name tailf -value get_tailf
Set-Alias -Name head -Value get_head
#####################################################################################################################
# Utilities
function which ($command) {
Get-Command -Name $command -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}
#####################################################################################################################
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment