-
Notifications
You must be signed in to change notification settings - Fork 1
/
.aliases.ps1
261 lines (201 loc) · 4.81 KB
/
.aliases.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
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# Functions
function GoTo {
cd ..
}
function Cloud {
cd ~/Documents/Dropbox
}
function _Documents {
cd ~/Documents
}
function _Desktop {
cd ~/Desktop
}
function Downloads {
cd ~/Downloads
}
function Kidchenko {
cd ~/kidchenko
}
function Playground {
cd "~/kidchenko/playground"
}
function _Lambda3 {
cd ~/lambda3
}
function _Jetabroad {
cd ~/jetabroad
}
function _Thoughtworks {
cd ~/thoughtworks
}
function _Thoughtworks {
cd ~/thoughtworks
}
function _isho {
cd ~/isho
}
function _SevenPeaks {
cd ~/sevenpeaks
}
function Find-Text {
Get-ChildItem -Recurse -Force | Select-String $args[0] -List
}
function List-All {
Get-ChildItem -Force
}
function List-Directory {
Get-ChildItem -Directory
}
function List-Hidden {
Get-ChildItem -Hidden
}
function Get-Week {
Get-Date -UFormat %V
}
function Run-Update {
if (!($IsMacOS)) {
choco.exe upgrade all -y;
}
}
# WinMac compatibility
Set-Alias open ii
# Find aliases
##
###
if (!(Get-Command grep -ErrorAction SilentlyContinue)) {
Set-Alias grep Find-Text
}
###
##
# End of WinMac compatibility
# Easier navigation:
Set-Alias -Force ".." GoTo
# Shortcuts
Set-Alias d _Documents
Set-Alias dl Downloads
Set-Alias dt _Desktop
# Me and my stuffs
Set-Alias ko Kidchenko
Set-Alias isho _isho
# Work related
Set-Alias l3 _Lambda3
Set-Alias jeta _Jetabroad
Set-Alias tw _Thoughtworks
Set-Alias sps _Sevenpeaks
# Set-Alias play Playground
### Git aliases
function GitPush {
git push
}
function GitPull {
git pull -r
}
# G for git
Set-Alias g git
# gps in Ppwershell is alias for GetProcess
if (Test-Path alias:gps) {
if ($Host.Version.Major -lt 5) {
Remove-Alias -Name gps -Force
}
else {
Remove-Item alias:gps -Force
}
}
Set-Alias gps GitPush
Set-Alias gpl GitPull
function Reload-Profile {
. Update-Profile
}
function Update-Profile {
$profiles = @(
$Profile.AllUsersAllHosts,
$Profile.AllUsersCurrentHost,
$Profile.CurrentUserAllHosts,
$Profile.CurrentUserCurrentHost
)
foreach ($profile in $profiles) {
if (Test-Path $profile) {
Write-Output "Running $profile"
. $profile
}
}
}
function Get-Profile {
Write-Output $PROFILE
cat $PROFILE
}
Set-Alias reload Reload-Profile
Set-Alias profile Get-Profile
# ls alias
# List files
Set-Alias l ls
# List all files
Set-Alias la List-All
# List only directories
Set-Alias lsd List-Directory
# List only hidden files
Set-Alias lsh List-Hidden
# Get week number
Set-Alias week Get-Week
# Get current date
Set-Alias today Get-Date
# Update Choco/Homebrew
Set-Alias update Run-Update
# Brave
if ($IsMacOS) {
function Open-Brave { open -n '/Applications/Brave Browser.app' }
Set-Alias brave Open-Brave
}
else {
Set-Alias brave "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe"
}
# IP Aliases
if ($IsMacOS) {
function Get-LocalIp { ipconfig getifaddr en0 }
Set-Alias localip Get-LocalIp
}
else {
function Get-LocalIp { (Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias Ethernet*).IPAddress }
Set-Alias localip Get-LocalIp
Set-Alias ip Get-LocalIp
}
# todo flush / clean up
# end todo
# C# Repl - waf/csharprepl
Set-Alias csrepl csharprepl
# Alias to generate md5 from string input
if (!(Get-Command md5 -ErrorAction SilentlyContinue)) {
function Get-Md5($value) {
([System.BitConverter]::ToString((New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider).ComputeHash((New-Object -TypeName System.Text.UTF8Encoding).GetBytes($value)))).Replace("-", "").ToLower()
}
Set-Alias md5 Get-Md5
}
# Alias to generate sha1 from string input
if (!(Get-Command sha1 -ErrorAction SilentlyContinue)) {
function Get-Sha1($value) {
([System.BitConverter]::ToString((New-Object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider).ComputeHash((New-Object -TypeName System.Text.UTF8Encoding).GetBytes($value)))).Replace("-", "")
}
Set-Alias sha1 Get-Sha1
}
# Alias to generate sha256 from string input
if (!(Get-Command sha256 -ErrorAction SilentlyContinue)) {
function Get-Sha256($value) {
([System.BitConverter]::ToString((New-Object -TypeName System.Security.Cryptography.SHA256CryptoServiceProvider).ComputeHash((New-Object -TypeName System.Text.UTF8Encoding).GetBytes($value)))).Replace("-", "")
}
Set-Alias sha256 Get-Sha256
}
# PATH
if ($IsMacOS) {
function Write-Path { $Env:PATH.Split(":") }
Set-Alias path Write-Path
}
else {
function Write-Path { $Env:PATH.Split(";") }
Set-Alias path Write-Path
}
function _SetEnv($keyValue) {
$tuple = $keyValue.Split(":");
[System.Environment]::SetEnvironmentVariable($tuple[0].ToString().ToUpper(), $tuple[1].ToString(), "Machine")
}
Set-Alias env _SetEnv