From fbe61de8e381b1558414064af85e22a896823b09 Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Wed, 23 Nov 2022 16:48:42 +0530 Subject: Adds Retrowave Player in profile --- powershell/user_profile.ps1 | 73 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/powershell/user_profile.ps1 b/powershell/user_profile.ps1 index 2abee8a..43cdf72 100644 --- a/powershell/user_profile.ps1 +++ b/powershell/user_profile.ps1 @@ -1,7 +1,8 @@ #Prompt -Import-Module posh-git -Import-Module oh-my-posh -Set-PoshPrompt default +#Import-Module posh-git +#Import-Module oh-my-posh +#Set-PoshPrompt default +$ENV:STARSHIP_CONFIG = "$HOME\.config\starship.toml" Import-Module -Name Terminal-Icons # Alias Set-Alias vim nvim @@ -14,7 +15,8 @@ Set-Alias -Name lv -Value Love2D Set-Alias guid New-Guid Set-Alias exif 'C:\tools\exiftool(-k).exe' Set-Alias -Name upload -Value UploadFile -Set-Alias -Name getwalls -Value GetWallPapers +Set-Alias -Name getwalls -Value GetWallPapers +Set-Alias -Name retrowave -Value PlayRetrowave ## Git Alias Set-Alias g git @@ -26,6 +28,7 @@ Set-Alias -Name push -Value GitPush Set-Alias -Name status -Value GitStatus Set-Alias -Name pcb -Value PushCurrentBranch Set-Alias -Name glm -Value GitLastMessage +Set-Alias -Name chbranch -Value GitChooseBranch function GitDiff { $output = (git diff --stat) | Out-String @@ -75,8 +78,7 @@ function GitStatus { } function PushCurrentBranch { - $branchQuery = (git branch) | grep '*' | Out-String - $branchName = $branchQuery -replace '[*?\{]', '' -replace "\s", "" + $branchName = (git branch --show-current) $originQuery = (git config --get remote.origin.url) (git push -u $originQuery $branchName) } @@ -89,6 +91,7 @@ function GitLastMessage { function UploadFile { $fileName = $args[0] $output = (curl -F'file=@"'$fileName'"' https://0x0.st) + Set-Clipboard -Value $output Write-Output $output } @@ -96,14 +99,54 @@ function GetWallPapers { $searchQuery = $args[0]; $response = Invoke-RestMethod -URI https://wallhaven.cc/api/v1/search?q="$searchQuery" $currentFolder = Get-Location - Set-Location -Path "C:\Users\Indrajith\Pictures\wallpapers\wallhaven\" - for (($i=0); ($i -lt $response.data.Length); $i++) { - $data = $response.data[$i] - $currentId = $data.id - $filePath = $data.path - # Write-Output $currentId - (curl $filePath --output "$currentId.jpg") + + if ($response.data.Length -eq 0) { + Write-Output "No Wallpapers found with the search term -> $searchQuery 😢" } - # Write-Output $response.data - Set-Location -Path $currentFolder + else { + $isFolderExists = Test-Path -Path "C:\Users\Indrajith\Pictures\wallpapers\wallhaven\$searchQuery" + if ($isFolderExists -eq $false) { + New-Item -ItemType Directory -Path "C:\Users\Indrajith\Pictures\wallpapers\wallhaven\$searchQuery" + } + Set-Location -Path "C:\Users\Indrajith\Pictures\wallpapers\wallhaven\$searchQuery" + for (($i = 0); ($i -lt $response.data.Length); $i++) { + $data = $response.data[$i] + $currentId = $data.id + $filePath = $data.path + # Write-Output $currentId + (curl $filePath --output "$currentId.jpg") + } + # Write-Output $response.data + Set-Location -Path $currentFolder + } +} + +function GitChooseBranch { + # requires charm.sh gum in path + $branches = (git branch --format="%(refname:short)") + # Write-Output $branches + $selectedBranch = (gum choose $branches) + Write-Output "Hello $selectedBranch" } + +function PlayRetrowave { + # requires ffplay in path + + $response = Invoke-RestMethod -URI "http://retrowave.ru/api/v1/tracks?limit=50&cursor=0" + $musicBaseUrl = "https://retrowave.ru" + + if ($response.body.tracks.Length -gt 0) { + for (($i = 0); ($i -lt $response.body.tracks.Length); $i++) { + $currentTrack = $response.body.tracks[$i] + $currentTrackUrl = $currentTrack.streamUrl + $jsonData = (ffprobe -v quiet -print_format json -show_format "$musicBaseUrl$currentTrackUrl") | ConvertFrom-Json + $albumName = $jsonData.format.tags.title + $artist = $jsonData.format.tags.artist + # Write-Output "Now Playing : $albumName - $artist" + $asciiText = (Invoke-RestMethod -URI https://asciified.thelicato.io/api?text="$albumName - $artist&font=Big") + Write-Output $asciiText + (ffplay $musicBaseUrl$currentTrackUrl -nodisp -autoexit -loglevel -8 ) + Clear-Host + } + } +} \ No newline at end of file -- cgit v1.2.3