-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpwsh.ps1
More file actions
208 lines (174 loc) · 3.98 KB
/
Copy pathpwsh.ps1
File metadata and controls
208 lines (174 loc) · 3.98 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Aliases
Set-Alias less "C:\Program Files\git\usr\bin\less.exe"
Set-Alias grep findstr
Set-Alias touch New-Item
Set-Alias rm Remove-Item
# Git-Specific-Aliases
function gst {
git status
}
function gaa {
git add .
}
function glo {
git log --oneline
}
function gph {
git push
}
function gpl {
git pull
}
function gba {
git branch -a
}
function gr {
git reset
}
# git commit -m & git push in single cmd
function gcp {
param (
[string]$msg
)
git commit -m "$msg"
git push
}
# git add . and git commit -m in single cmd
function gacp {
param (
[string]$msg
)
git add .
git commit -m "$msg"
git push
}
# Alias: git commit -m msg
function gcmm {
param (
[string]$msg
)
git commit -m "$msg"
}
# Alias: git add file_path
function ga {
param (
[string]$path
)
git add "$path"
}
# Alias: git diff file_path
function gd {
param (
[string]$path
)
git diff "$path"
}
# Alias: git commit -am msg
function gcma {
param (
[string]$msg
)
git commit -am "$msg"
}
# Alias: git checkout branch_name
function gco {
param (
[string]$branch_name
)
git checkout "$branch_name"
}
# Alias: git checkout -b branch_name
function gcob {
param (
[string]$branch_name
)
git checkout -b "$branch_name"
}
# Alias: git branch branch_name
function gb {
param (
[string]$branch_name
)
git branch "$branch_name"
}
# NPM-Specific-Aliases
function ns {
npm start
}
function nd {
npm run dev
}
function nb {
npm run build
}
# Use legacy vim version
function vim {
nvim -u "$env:LOCALAPPDATA\nvim\init-legacy.vim" @args
}
# Configurations-Specific-Aliases
# Powershell Configuration
function pconf {
param (
[ValidateSet("cd", "vim", "nvim", "cat", "less")]
[string]$cmd
)
$filePath = "C:\Users\m4dd0c\.config\powershell\user_profile.ps1"
switch ($cmd) {
"cd" { Set-Location (Split-Path $filePath) }
"vim" { vim $filePath }
"nvim" { nvim $filePath }
"cat" { cat $filePath }
"less" { less $filePath }
default { vim $filePath }
}
}
# Neovim Configuration
function nconf {
param (
[ValidateSet("cd", "vim", "nvim", "cat", "less")]
[string]$cmd
)
$filePath = "C:\Users\m4dd0c\AppData\Local\nvim\lua\config\keymaps.lua"
switch ($cmd) {
"cd" { Set-Location (Split-Path $filePath) }
"vim" { vim $filePath }
"nvim" { nvim $filePath }
"cat" { cat $filePath }
"less" { less $filePath }
default { vim $filePath }
}
}
# GlazeWM Configuration
function gconf {
param (
[ValidateSet("cd", "vim", "nvim", "cat", "less")]
[string]$cmd = "nvim"
)
$filePath = "C:\Users\m4dd0c\.glzr\glazewm\config.yaml"
switch ($cmd) {
"cd" { Set-Location (Split-Path $filePath) }
"vim" { vim $filePath }
"nvim" { nvim $filePath }
"cat" { cat $filePath }
"less" { less $filePath }
default { vim $filePath }
}
}
# Laod prompt config (oh-my-posh)
function Get-ScriptDirectory { Split-Path $MyInvocation.ScriptName }
$PROMPT_CONFIG = Join-Path (Get-ScriptDirectory) 'unicorn.omp.json'
oh-my-posh --init --shell pwsh --config $PROMPT_CONFIG | Invoke-Expression
# Importing modules
Import-Module -Name terminal-icons
# AutoCompletion using PSReadLine
# Overwrite RightArrow key to complete single word.
Set-PSReadLineKeyHandler -Key RightArrow -Function forwardWord
# Ctrl+z to go back single word (default).
# Bind Alt+L to AcceptWholeSuggestion
Set-PSReadLineKeyHandler -Chord ALT+";" -Function AcceptSuggestion
# ClearScreen on ctrl+l
Set-PSReadlineKeyHandler -Key 'Ctrl+l' -Function ClearScreen
# Change default open location
Set-Location "D:"
# Allow-dubious-git to fix: detected dubious ownership in repository.
$env:GIT_ALLOW_DUBIOUS=1