-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathMicrosoft.PowerShell_profile.ps1
133 lines (108 loc) · 3.46 KB
/
Microsoft.PowerShell_profile.ps1
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
# PowerShell user profile
# Copy to $PROFILE to enable:
# cp Microsoft.PowerShell_profile.ps1 $PROFILE
Set-Variable DOTFILES "$env:APPDATA\.dotfiles"
Set-Variable EMACSD "$env:APPDATA\.emacs.d"
Set-Variable EDITOR 'emacsclientw -a ""'
#
# Functions
#
function Update-Scoop-All {
Invoke-Expression 'scoop update --all && scoop cleanup --all'
}
function Open-Mini-Emacs {
Invoke-Expression 'runemacs -Q -l "$EMACSD\init-mini.el"'
}
function Open-Mini-Terminal-Emacs {
Invoke-Expression 'emacs -Q -nw -l "$EMACSD\init-mini.el"'
}
function Open-Emacs-Client-Nowait {
param ([string]$FileName)
Invoke-Expression 'emacsclientw -a "" -n $FileName'
}
function Open-Emacs-Client-Frame-Nowait {
param ([string]$FileName)
Invoke-Expression 'emacsclientw -a "" -n -c $FileName'
}
function Open-Emacs-Client-Frame {
param ([string]$FileName)
Invoke-Expression 'emacsclientw -a "" -c $FileName'
}
function Open-Terminal-Emacs {
param ([string]$FileName)
Invoke-Expression 'emacs -Q -nw $FileName'
}
function Enable-Http-Proxy {
$Env:http_proxy="http://127.0.0.1:7890";$Env:https_proxy="http://127.0.0.1:7890"
}
function Disable-Http-Proxy {
$Env:http_proxy="";$Env:https_proxy=""
}
function List-Files {
param ([string]$Path)
Invoke-Expression "eza -lhF --icons --group-directories-first $Path"
}
function List-All-Files {
param ([string]$Path)
Invoke-Expression "eza -lAhF --icons --group-directories-first $Path"
}
#
# Aliases
#
Set-Alias -Name sua -Value Update-Scoop-All
# Emacs
Set-Alias -Name me -Value Open-Mini-Emacs
Set-Alias -Name mte -Value Open-Mini-Terminal-Emacs
Set-Alias -Name e -Value Open-Emacs-Client-Nowait
Set-Alias -Name ec -Value Open-Emacs-Client-Frame-Nowait
Set-Alias -Name ef -Value Open-Emacs-Client-Frame
Set-Alias -Name te -Value Open-Terminal-Emacs
# Utilities
if (Get-Alias -Name "diff" -ErrorAction SilentlyContinue) {
Remove-Alias diff -Force
}
if (Get-Alias -Name "rm" -ErrorAction SilentlyContinue) {
Remove-Alias rm -Force
}
Set-Alias -Name cat -Value bat # Use the latest less or --paging=never
Set-Alias -Name df -Value duf
Set-Alias -Name du -Value dust
Set-Alias -Name ls -Value List-Files
Set-Alias -Name l -Value List-Files
Set-Alias -Name ll -Value List-Files
Set-Alias -Name la -Value List-All-Files
Set-Alias -Name ping -Value gping
Set-Alias -Name top -Value btop
# Git
Import-Module git-aliases -DisableNameChecking
#
# Customizations
#
# Readline
Import-Module PSReadLine
Set-PSReadLineOption -EditMode Emacs
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
# Fish-like Autosuggest
Set-PSReadLineOption -PredictionSource History -HistoryNoDuplicates
# Icons
# Import-Module -Name Terminal-Icons
# Starship
Invoke-Expression (&starship init powershell)
# Z
Invoke-Expression (& { (zoxide init powershell | Out-String) })
#
# FZF
#
# Replace 'Ctrl+t' and 'Ctrl+r' with your preferred bindings:
Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'
# Replace Tab
Set-PSReadLineKeyHandler -Key Tab -ScriptBlock { Invoke-FzfTabCompletion }
Set-PsFzfOption -TabExpansion
# Options
Set-PsFzfOption -EnableAliasFuzzyEdit # fe
Set-PsFzfOption -EnableAliasFuzzyHistory # fh
Set-PsFzfOption -EnableAliasFuzzyKillProcess # fkill
Set-PsFzfOption -EnableAliasFuzzyScoop # fs
Set-PsFzfOption -EnableAliasFuzzyGitStatus # fgs
Set-PsFzfOption -EnableAliasFuzzySetEverything # cde
Set-PsFzfOption -EnableAliasFuzzyZLocation # fz