Last active
April 5, 2022 09:17
-
-
Save elsassph/b26c5c2b3a489ece4422a32166da2986 to your computer and use it in GitHub Desktop.
PowerShell profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load dev projects paths as variables | |
~/LoadPath.ps1 | |
# Rust | |
$Env:PATH += ":$($Env:HOME)/.cargo/bin" | |
# Java 1.8 | |
#$Env:JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/" | |
# Java 11 | |
$Env:JAVA_HOME="/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home" | |
# DEVICES | |
#$FrameIP="192.168.2.25" | |
$FrameIP="192.168.1.12" | |
$LGIP="192.168.2.27" | |
$Env:FRAME_IP=$FrameIP | |
$Env:LGIP=$LGIP | |
# NVM | |
Import-Module '/Users/philippe.elsass/dev/lib/ps-nvm/nvm.psd1' | |
# https://github.com/dfinke/PowerShellHumanizer | |
Import-Module PowerShellHumanizer | |
# Utils | |
function getKey() { | |
"Download private key..." | |
Invoke-WebRequest -Uri "http://$($LGIP):9991/webos_rsa" -OutFile /Users/philippe.elsass/.ssh/webos_rsa | |
chmod 600 ~/.ssh/webos_rsa | |
"Verify private key..." | |
ssh-keygen -y -P "0BF5EE" -f /Users/philippe.elsass/.ssh/webos_rsa | |
"Setup device..." | |
ares-setup-device -m tv -i "username=prisoner" -i "privatekey=webos_rsa" -i "passphrase=0BF5EE" -i "host=$LGIP" -i "port=9922" | |
} | |
function dotEnv() { | |
if (test-path ".env") { | |
return ConvertFrom-StringData (Get-Content .env -raw) | |
} | |
return @{} | |
} | |
function rokuDeploy { | |
if (!(test-path "rokudeploy.json")) { | |
set-content "rokudeploy.json" '{"host":"10.0.0.5","password":"doabarrelroll"}' | |
} | |
npx roku-deploy | |
} | |
function rokuDeeplink ($contentID) { | |
$ROKU_HOST = $(dotEnv).ROKU_HOST | |
Invoke-RestMethod "http://$($ROKU_HOST):8060/input?contentID=$contentID&mediaType=movie" -method "POST" -Verbose | |
} | |
function rokuVoice ($id, $cmd) { | |
$ROKU_HOST = $(dotEnv).ROKU_HOST | |
Invoke-RestMethod "http://$($ROKU_HOST):8060/input/dev?id=$id&type=transport&command=$cmd" -method "POST" -Verbose | |
} | |
function nuget { | |
mono /usr/local/bin/nuget.exe @Args | |
} | |
function unsafeChrome { | |
open -b com.google.Chrome -n --args --user-data-dir=/tmp/unsafe -ignore-certificate-errors | |
} | |
function StashTo($Branch) { | |
Invoke-StopOnError @( | |
"git stash", | |
"git checkout $Branch", | |
"git pull", | |
"git stash pop" | |
) | |
} | |
function npmdeps { | |
$p = Get-Content ./package.json | ConvertFrom-Json | |
$deps = $p.dependencies.PSObject.Properties | % { [PSCustomObject]@{ Name = $_.Name; Version = $_.Value; Dev = $false } } | |
$devDeps = $p.devDependencies.PSObject.Properties | % { [PSCustomObject]@{ Name = $_.Name; Version = $_.Value; Dev = $true } } | |
$deps + $devDeps | |
} | |
function Invoke-StopOnError($Cmds) { | |
foreach($Cmd in $Cmds) { | |
Invoke-Expression $Cmd | |
if ($LASTEXITCODE -ne 0) { return } | |
} | |
} | |
function set-elsassph { | |
git config user.email "[email protected]" | |
} | |
# nvm | |
Set-NodeVersion 12 | |
# Fix conflict with `ni` | |
Remove-Alias -Name ni -Force | |
# Starship shell | |
$Env:STARSHIP_CONFIG = "$HOME/.starship/pwsh-config.toml" | |
Invoke-Expression (&starship init powershell) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define a variable for every project | |
if (Test-Path ~/.allProjects.json) { | |
$list = Get-Content ~/.allProjects.json | ConvertFrom-Json | |
foreach($it in $list) { | |
Set-Variable -Name $it.Name -Value $it.Value -Scope Global | |
} | |
$global:Projects = $list | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($RootPath) | |
# Project folders as variables | |
$skip = @("node_modules", "src", "doc", "test", "www", "bin") | |
$TextInfo = (Get-Culture).TextInfo | |
function Get-Projects($Path) { | |
if (Test-Path "$($Path.FullName)/.git") { | |
$varName = $TextInfo.ToTitleCase($Path.Name) -replace "[-. ,;]","" | |
return @(@{ Name="$($varName)Folder"; Value=$Path.FullName }) | |
} | |
$res = @() | |
ForEach ($dir in Get-ChildItem $Path -Attributes Directory+!Hidden) { | |
if (!($skip -contains $dir.Name)) { | |
$res += Get-Projects($dir) | |
} | |
} | |
$res | |
} | |
if (!$RootPath) { | |
$RootPath = "~/dev" | |
} | |
$t = Measure-Command { | |
$list = Get-Projects $(Get-Item $RootPath) | |
$list | ConvertTo-Json | Set-Content ~/.allProjects.json | |
./LoadPath.ps1 | |
} | |
"Done $($t.TotalMilliseconds)ms, $($list.Length) projects found" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment