-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMicrosoft.PowerShell_profile.ps1
More file actions
141 lines (125 loc) · 3.29 KB
/
Copy pathMicrosoft.PowerShell_profile.ps1
File metadata and controls
141 lines (125 loc) · 3.29 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
Set-PSReadlineOption -BellStyle None
Set-PSReadlineOption -EditMode Emacs
Set-PSReadlineOption -ContinuationPrompt "? "
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"
}
$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"
}
$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
}
$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) {
Set-Alias ls eza -Option AllScope
function ll() {
eza -l $args
}
} else {
Set-Alias l ls
Set-Alias ll ls
}
# 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
}
# Plain ANSI colors — relies on the terminal's colorscheme (Gruvbox
# everywhere) to remap the base 16 colors, so no truecolor/256 detection.
function prompt {
$ok = $?
$rawCwd = (Get-Location).Path
$cwd = __path.tilde $rawCwd
$edge = ansi 90
$dir = ansi 32
$err = ansi 31
if (-not $ok) {
$dir = $err
}
$reset = ansi 0
Write-Host ""
Write-Host -NoNewline "${bold}${dir}${cwd} ${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