-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrosoft.PowerShell_profile.ps1
231 lines (208 loc) · 8.79 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
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
#===========================================================================
#region Dependencies Start
#===========================================================================
& ([ScriptBlock]::Create((oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\kali.omp.json" --print) -join "`n"))
if (-not (Get-Module -Name Terminal-Icons -ListAvailable)) {
Install-Module -Name Terminal-Icons -Repository PSGallery
}
else {
Import-Module -Name Terminal-Icons
}
Import-Module PSReadLine
Set-Alias ll Get-ChildItem
Set-Alias cls Clear-Host
#===========================================================================
#endregion Dependencies End
#===========================================================================
#===========================================================================
#region CMD Open
#===========================================================================
Write-Host "
Dark Knight's Terminal
⠈⠙⠲⢶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣿⡀⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀⡄⠀⠀⠀⠀⠀⠀⠀⣼⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣿⠟⠓⠉
⠀⠀⠀⠀⠈⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⢀⣧⣶⣦⣇⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠉⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣶⣶⣶⣾⣿⣿⣿⣿⣶⣶⣶⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠛⠛⠛⠛⠛⠛⠛⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠿⠟⠛⠛⠛⠛⠛⠛⠃⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠻⣿⣿⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Type 'help' to see List of commands " -ForegroundColor red
function help {
Write-Host "`n`Usage: [<command>] [<options>]`n` "
Write-Host "The following commands are available:"
Write-Host "help Display this help message."
Write-Host "open Available options: <itt> <github> <yt>"
Write-Host "run Available options: <itt>"
Write-Host "gog Search via Google"
Write-Host "rex Restart explorer"
Write-Host "Re Opening Recycle bin"
Write-Host "dark Toggle dark mode"
Write-Host "cch Clear commands history"
Write-Host "q Clear-Host"
}
function Open {
[CmdletBinding()]
param (
[string]$Open,
[switch]$Help
)
if ($Help) {
Write-Output "Usage: [<open>] available options [yt, github, itt]"
return
}
switch ($open) {
"yt" {
Start-Process ("https://youtube.com/@emadadel4")
}
"github" {
Start-Process ("https://github.com/emadadel4")
}
"itt" {
Start-Process ("https://github.com/emadadel4/itt")
}
}
}
function Run {
[CmdletBinding()]
param (
[string]$Run,
[switch]$Help
)
if ($Help) {
Write-Output "Usage: [<Run>] available options [itt]"
return
}
switch ($Run) {
"itt" {
irm bit.ly/ittea | iex
}
}
}
#===========================================================================
#endregion End Open
#===========================================================================
#===========================================================================
#region Normal CMD
#===========================================================================
function cch {
$historyFilePath = "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt"
if (Test-Path $historyFilePath) {
Remove-Item $historyFilePath -Force
Add-Log -Message "History Claerd" -Level "Info"
}
else {
Write-Output "ConsoleHost_history.txt not found."
}
}
function Q {
Clear-Host
& $profile
}
function Re { Write-Host "Opening Recycle bin..."; Start-Process C:\Windows\explorer.exe shell:RecycleBinFolder }
function rex {
Stop-Process -Name explorer
}
function Safe-Mode {
$userInput = Read-Host "Do you want to boot into Safe Mode (Yes/No)"
if ($userInput -eq "Yes") {
# Enable Safe Mode without networking
bcdedit /set { current } safeboot minimal
# Restart the computer
Write-Host "Your computer will restart and boot into Safe Mode (without Networking)."
Restart-Computer
}
elseif ($userInput -eq "No") {
Write-Host "Safe Mode will not be enabled. No changes were made."
}
else {
Write-Host "Invalid input. Please type 'Yes' or 'No'."
}
}
function gog {
[CmdletBinding()]
param (
[Parameter(ValueFromRemainingArguments = $true)]
[string]$Search = $null,
[switch]$Help
)
if ($Help) {
Add-Log -Message "Usage: [<gog>] [<search query>]" -Level "INFO"
return
}
if ($Search) {
if (-not $Search.Trim()) {
Write-Host "Please provide a search query."
}
else {
# Encode the search query for use in a URL
$encodedQuery = [System.Web.HttpUtility]::UrlEncode($Search)
# Define the DuckDuckGo search URL with the encoded query
$url = "https://www.google.com/search?q=$encodedQuery"
# Open the search results in the default web browser
Start-Process $url
}
}
}
function yt {
[CmdletBinding()]
param (
[Parameter(ValueFromRemainingArguments = $true)]
[string]$Search = $null,
[switch]$Help
)
if ($Help) {
Add-Log -Message "Usage: [<yt>] [<search query>]" -Level "INFO"
return
}
if ($Search) {
if (-not $Search.Trim()) {
Write-Host "Please provide a search query."
}
else {
# Encode the search query for use in a URL
$encodedQuery = [System.Web.HttpUtility]::UrlEncode($Search)
# Define the DuckDuckGo search URL with the encoded query
$url = "https://www.youtube.com/results?search_query=$encodedQuery"
# Open the search results in the default web browser
Start-Process $url
}
}
}
function Dark {
param (
$app = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize",
$system = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
)
try {
# Check if the registry keys exist
if (!(Test-Path $app) -or !(Test-Path $system)) {
Write-Host "Error: Registry paths not found."
return
}
# Get current theme settings for both App and System
$currentAppTheme = Get-ItemProperty -Path $app -Name AppsUseLightTheme -ErrorAction Stop
$currentSystemTheme = Get-ItemProperty -Path $system -Name SystemUsesLightTheme -ErrorAction Stop
# Toggle the values
if ($currentAppTheme.AppsUseLightTheme -eq 1 -and $currentSystemTheme.SystemUsesLightTheme -eq 1) {
# Switch to dark mode
Set-ItemProperty -Path $app -Name AppsUseLightTheme -Value 0
Set-ItemProperty -Path $system -Name SystemUsesLightTheme -Value 0
Write-Host "Switched to Dark Mode."
}
else {
# Switch to light mode
Set-ItemProperty -Path $app -Name AppsUseLightTheme -Value 1
Set-ItemProperty -Path $system -Name SystemUsesLightTheme -Value 1
Write-Host "Switched to Light Mode."
}
}
catch {
Write-Host "Error: $($_.Exception.Message)"
}
}
#===========================================================================
#endregion End Open
#===========================================================================