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.

Revisions

  1. thdtt revised this gist May 12, 2022. 1 changed file with 38 additions and 18 deletions.
    56 changes: 38 additions & 18 deletions profile.ps1
    Original file line number Diff line number Diff line change
    @@ -1,27 +1,26 @@
    # 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"
    }

    # Prompt
    Import-Module posh-git
    Import-Module oh-my-posh

    # Theme
    Set-PoshPrompt bubblesline

    # Terminal Icons
    Import-Module Terminal-Icons

    $GitPromptSettings.EnableFileStatus = $false

    # PSReadLine
    Set-PSReadLineOption -PredictionSource History
    Set-PSReadLineOption -BellStyle None
    #####################################################################################################################

    # Load prompt config
    function Get-ScriptDirectory { Split-Path $MyInvocation.ScriptName }
    $PROMPT_CONFIG = Join-Path (Get-ScriptDirectory) 'thdtt.omp.json'
    oh-my-posh --init --shell pwsh --config $PROMPT_CONFIG | Invoke-Expression

    # Alias
    Set-Alias ll ls
    @@ -32,9 +31,30 @@ 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"
    }
  2. thdtt created this gist Jan 1, 2022.
    40 changes: 40 additions & 0 deletions profile.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    # Function
    Function cd_home {Set-Location -Path C:\Users\thanh}
    Function cd_root {Set-Location -Path C:\}

    # Prompt
    Import-Module posh-git
    Import-Module oh-my-posh

    # Theme
    Set-PoshPrompt bubblesline

    # Terminal Icons
    Import-Module Terminal-Icons

    $GitPromptSettings.EnableFileStatus = $false

    # PSReadLine
    Set-PSReadLineOption -PredictionSource History
    Set-PSReadLineOption -BellStyle None

    # Load prompt config
    function Get-ScriptDirectory { Split-Path $MyInvocation.ScriptName }
    $PROMPT_CONFIG = Join-Path (Get-ScriptDirectory) 'thdtt.omp.json'
    oh-my-posh --init --shell pwsh --config $PROMPT_CONFIG | Invoke-Expression

    # 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

    # Utilities
    function which ($command) {
    Get-Command -Name $command -ErrorAction SilentlyContinue |
    Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
    }