0

Below PowerShell code can help you get motivated to write your own alias for ninja like activity

  1. Replace %userprofile% with your username
  2. Replace [hints] with the original path

Type $profile in your powershell cli, and append the below code to get started

Will this activity drag the systems performance?

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
jOSe
  • 687
  • 11
  • 22
  • 1
    What do you mean by "the system" and "performance"? Command lookup in PowerShell will be marginally slower (you'll never notice), but the rest of the OS won't care – Mathias R. Jessen Jul 14 '21 at 09:34
  • Will set-alias hold more memory space? If yes, it may impact the endpoints performance; when the project grows with more instruction to be loaded for the session. – jOSe Jul 15 '21 at 07:45
  • Yes, but again, we're talking so tiny amounts it won't make any difference. Are you planning on introducing 1000s of aliases? If not, don't worry – Mathias R. Jessen Jul 15 '21 at 09:22
  • Got it..! There is no lag with the current aliases – jOSe Aug 04 '21 at 15:17

0 Answers0