-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMicrosoft.PowerShell_profile.ps1
More file actions
190 lines (166 loc) · 4.38 KB
/
Copy pathMicrosoft.PowerShell_profile.ps1
File metadata and controls
190 lines (166 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
Set-PSReadlineOption -BellStyle None
Set-PSReadlineOption -EditMode Emacs
Set-PSReadlineOption -ContinuationPrompt "? "
# Inline gray suggestions from history, like zsh-autosuggestions
Set-PSReadlineOption -PredictionSource History
function __theme.set-light() {
Set-PSReadLineOption -Colors @{
ContinuationPrompt = "#666666"
Emphasis = "#666666"
Error = "#cc0000"
Selection = "#666666"
Default = "#666666"
Comment = "#666666"
Keyword = "#666666"
String = "#008888"
Operator = "#666666"
Variable = "#008800"
Command = "#880088"
Parameter = "#666666"
Type = "#666666"
Number = "#666666"
Member = "#666666"
InlinePrediction = "#008888"
}
$x = $Host.PrivateData
$x.ErrorForegroundColor = "Red"
$x.ErrorBackgroundColor = "Black"
$x.WarningForegroundColor = "Yellow"
$x.WarningBackgroundColor = "Black"
$x.DebugForegroundColor = "Yellow"
$x.DebugBackgroundColor = "Black"
$x.VerboseForegroundColor = "Yellow"
$x.VerboseBackgroundColor = "Black"
$x.ProgressForegroundColor = "DarkGray"
$x.ProgressBackgroundColor = "Black"
}
function __theme.set-dark() {
Set-PSReadLineOption -Colors @{
ContinuationPrompt = "#928374"
Emphasis = "#fe8019"
Error = "#fb4934"
Selection = "#665c54"
Default = "#ebdbb2"
Comment = "#928374"
Keyword = "#fb4934"
String = "#b8bb26"
Operator = "#ebdbb2"
Variable = "#83a598"
Command = "#fabd2f"
Parameter = "#d3869b"
Type = "#8ec07c"
Number = "#d3869b"
Member = "#ebdbb2"
InlinePrediction = "#8ec07c"
}
$x = $Host.PrivateData
$x.ErrorForegroundColor = "Red"
$x.ErrorBackgroundColor = "Black"
$x.WarningForegroundColor = "Yellow"
$x.WarningBackgroundColor = "Black"
$x.DebugForegroundColor = "Yellow"
$x.DebugBackgroundColor = "Black"
$x.VerboseForegroundColor = "Yellow"
$x.VerboseBackgroundColor = "Black"
$x.ProgressForegroundColor = "DarkGray"
$x.ProgressBackgroundColor = "Black"
}
function g() {
git status $args
}
function gl() {
git log $args
}
function d() {
(Get-Location).Path
}
# Easy open files
function o() {
if ($args) {
Invoke-Item @args
} else {
Invoke-Item .
}
}
$esc = [char]27
function ansi {
"$esc[$($args -join ';')m"
}
$bold = ansi 1
function __install.eza {
winget install eza-community.eza
}
if (Get-Command eza -ErrorAction SilentlyContinue) {
function ls() {
eza --group-directories-first $args
}
function l() {
ls $args
}
function ll() {
ls -l $args
}
function la() {
ls -la $args
}
} else {
Set-Alias l ls
Set-Alias ll ls
}
# Python virtualenv assumes you want your shell prompt mangled without this
$env:VIRTUAL_ENV_DISABLE_PROMPT = "true"
# Still easier to use vim for quick edits even though I prefer VS Code
if (Get-Command nvim -ErrorAction SilentlyContinue) {
$env:EDITOR = "nvim"
Set-Alias vim nvim
} else {
$env:EDITOR = "vim"
}
$env:GIT_EDITOR = $env:EDITOR
$env:VISUAL = $env:EDITOR
# Abbreviate a leading $HOME to ~ (only when it's a real prefix, not a substring)
function __path.tilde($path) {
$sep = [IO.Path]::DirectorySeparatorChar
$alt = [IO.Path]::AltDirectorySeparatorChar
$path = $path.Replace($alt, $sep)
$hdir = $HOME.Replace($alt, $sep).TrimEnd($sep)
if ($path -eq $hdir) {
return "~"
}
if ($path.StartsWith($hdir + $sep, [StringComparison]::OrdinalIgnoreCase)) {
return "~" + $path.Substring($hdir.Length)
}
return $path
}
function prompt {
$rawCwd = (Get-Location).Path
$cwd = __path.tilde $rawCwd
$edge = ansi 90
$leaf = ansi 32
$reset = ansi 0
$sep = [IO.Path]::DirectorySeparatorChar
# Gray path, green leaf
$parts = $cwd.Split($sep)
$parts[-1] = "${leaf}$($parts[-1])"
$cwdColored = "${edge}" + ($parts -join $sep)
Write-Host ""
Write-Host "${bold}${cwdColored}${reset}"
Write-Host -NoNewline "${bold}${edge}>${reset}"
return " "
}
function .. {
Set-Location ..
}
function s {
Set-Location ..
Write-Output (Get-Location).Path
}
function __git.fix () {
git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"
}
__theme.set-dark
# Windows default powershell doesn't have `cd` hooks. Got it, thanks.
$env:MISE_PWSH_CHPWD_WARNING = "0"
# When `cd` hooks are missing, mise wraps your `prompt` function. So keep this
# after `prompt` is defined.
mise activate pwsh | Out-String | Invoke-Expression