diff options
Diffstat (limited to 'powershell/Microsoft.PowerShell_profile.ps1')
-rw-r--r-- | powershell/Microsoft.PowerShell_profile.ps1 | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/powershell/Microsoft.PowerShell_profile.ps1 b/powershell/Microsoft.PowerShell_profile.ps1 index 574b323..22924e9 100644 --- a/powershell/Microsoft.PowerShell_profile.ps1 +++ b/powershell/Microsoft.PowerShell_profile.ps1 @@ -1,45 +1,52 @@ # ----------------------------------------------------------------------------- -# - MODULES - +# - ENVIRONMENT VARIABLES - # ----------------------------------------------------------------------------- -Import-Module -Name PSFzf -ErrorAction 'SilentlyContinue' -Import-Module -Name posh-git -ErrorAction 'SilentlyContinue' +[Environment]::SetEnvironmentVariable("POWERSHELL_TELEMETRY_OPTOUT", "1") +[Environment]::SetEnvironmentVariable("EDITOR", "vim") +[Environment]::SetEnvironmentVariable("VISUAL", "code") + +$env:PATH += ":$env:HOME/go/bin" if ($IsWindows) { - $env:XDG_CONFIG_HOME = "$env:USERPROFILE/.config" - if (-not(Test-Path -Path $env:XDG_CONFIG_HOME -PathType Container)) { - New-Item -Path $env:XDG_CONFIG_HOME -ItemType Directory - } + [Environment]::SetEnvironmentVariable("XDG_CONFIG_HOME", "$env:USERPROFILE/.config") } else { - $env:XDG_CONFIG_HOME = "$env:HOME/.config" + [Environment]::SetEnvironmentVariable("XDG_CONFIG_HOME", "$env:HOME/.config") +} + +if (-not(Test-Path -Path $env:XDG_CONFIG_HOME -PathType Container)) { + New-Item -Path $env:XDG_CONFIG_HOME -ItemType Directory } # ----------------------------------------------------------------------------- +# - MODULES - +# ----------------------------------------------------------------------------- + +Import-Module -Name PSFzf -ErrorAction 'SilentlyContinue' +Import-Module -Name posh-git -ErrorAction 'SilentlyContinue' + +# ----------------------------------------------------------------------------- # - PROMPT - # ----------------------------------------------------------------------------- -if (Get-Command 'oh-my-posh' -ErrorAction 'SilentlyContinue') { - oh-my-posh init pwsh --config "$env:XDG_CONFIG_HOME/oh-my-posh/config.yml" | Invoke-Expression -} else { - function prompt { - $git_branch = $(git branch --show-current 2>/dev/null) - if ($git_branch -ne $null -and $git_branch -ne "") { - $git_branch = "($($git_branch))" - } - $hostname = [System.Net.Dns]::GetHostName().Split(".")[0] - $pathname = Split-Path -Path $pwd -Leaf - $path = if ($pathname -eq $env:USER) { "~" } else { $pathname } - "[pwsh] `e[01;32m$($env:USER)@$($hostname)`e[00m:`e[01;34m$($path) `e[1;35m$git_branch`e[00m`$ " +function prompt { + $git_branch = $(git branch --show-current 2>/dev/null) + if ($git_branch -ne $null -and $git_branch -ne "") { + $git_branch = "($($git_branch))" } + $hostname = [System.Net.Dns]::GetHostName().Split(".")[0] + $pathname = Split-Path -Path $pwd -Leaf + $path = if ($pathname -eq $env:USER) { "~" } else { $pathname } + "[pwsh] `e[01;32m$($env:USER)@$($hostname)`e[00m:`e[01;34m$($path) `e[1;35m$git_branch`e[00m`$ " } # ----------------------------------------------------------------------------- -# - ENVIRONMENT VARIABLES - +# - STYLES - # ----------------------------------------------------------------------------- -$env:PATH += ":$env:HOME/go/bin" -$env:EDITOR = "vim" -$env:VISUAL = "code" +# disable color for directory listings +$PSStyle.FileInfo.Directory = '' + # ----------------------------------------------------------------------------- # - CUSTOM FUNCTIONS - @@ -96,16 +103,10 @@ Set-PSReadLineOption -AddToHistoryHandler { return ($line -notmatch $sensitive) } -Set-PSReadLineOption -Colors @{ Member = "`e[95m"; Number = "`e[95m" } -Set-PSReadLineOption -Colors @{ - Member = "`e[95m" - Parameter = "`e[97m" - Number = "`e[97m" -} - # ----------------------------------------------------------------------------- # - ALIASES - # ----------------------------------------------------------------------------- + function ListFilesAndFolders { param([string]$path = ".") Get-ChildItem -Path $path } Set-Alias -Name ll -Value ListFilesAndFolders |