Режим дзен в PowerShell
Приведенный ниже код PowerShell может помочь вам создать собственный псевдоним для деятельности, подобной ниндзя.
- Замените %userprofile% своим именем пользователя.
- Замените [подсказки] исходным путем
Тип
$profile
в вашем powershell cli и добавьте приведенный ниже код, чтобы начать
Не повлияет ли это действие на производительность системы?
function poweroff_ {
shutdown -s -f
}
function hibernate_ {
shutdown -h
}
function restart_ {
shutdown -r -f
}
function eject_usb($driveletter){
# safely eject the mention drive eg:- d:\
$driveEject = New-Object -comObject Shell.Application
$driveEject.Namespace(17).ParseName($driveletter).InvokeVerb("Eject")
}
function cleanup_ {
#remove clutter from temp directory
rm -r -fo "C:\Users\%userprofile%\AppData\Local\Temp"
#clear Recycle-bin
clear-RecycleBin -confirm:$false
}
function pomodoro_timer{
#Reference: https://en.wikipedia.org/wiki/Pomodoro_Technique
Write-Host "'f' for Foucs(40 mins), 'sb' fo Short Break(10 mins), 'lb' for Long Break(30 mins)"
$logic = Read-Host "Ready? [f/sb/lb]"
if($logic -eq "f"){
$minutes = 40
} elseif ($logic -eq "sb") {
$minutes = 10
} elseif ($logic -eq "lb") {
$minutes = 30
}
#To-Do: Include background music [vlc] for each mode, and upon completing - play alert sound [custom sound, from local path]
$seconds = $minutes * 60
$delay = 1 #seconds between ticks
for ($i = $seconds; $i -gt 0; $i = $i - $delay) {
$percentComplete = 100 - (($i / $seconds) * 100)
Write-Progress -SecondsRemaining $i `
-Activity "Pomodoro Focus sessions" `
-Status "Time remaining:" `
-PercentComplete $percentComplete
if ($i -eq 16){Write-Host "Wrapping up, you will be available in $i seconds" -ForegroundColor Green}
Start-Sleep -Seconds $delay
}#Timer ended
}
# Native command renaming
set-alias -Name unzip -Value expand-archive
# Path specific
set-alias -Name np -Value notepad.exe
set-alias -name notes -Value C:\Users\%userprofile%\AppData\Local\[notetaking app.exe]
set-alias -name brave -value C:\Users\%userprofile%\AppData\Local\BraveSoftware\Brave-Browser\Application\brave.exe
Set-Alias -name paswdmng -value C:\Users\%userprofile[paswword manager app.exe]
Set-Alias -Name vs -value "C:\Users\%userprofile%\AppData\Local\Programs\Microsoft VS Code\Code.exe"
Set-Alias -Name outlook -Value "C:\Users\%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Brave Apps\Outlook.lnk"
Set-Alias -Name teams -Value "C:\Users\%userprofile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Microsoft Teams.lnk"
Set-Alias -Name vlc -Value "C:\Program Files\VideoLAN\VLC\vlc.exe"
# Invoking custom fuctions
New-Alias poweroff poweroff_
New-Alias frezze hibernate_
New-Alias restart restart_
New-Alias eject eject_usb
New-Alias cleanup cleanup_
New-alias focusmode pomodoro_timer