🪟: Add pathlib, PowerShell Password Script

This commit is contained in:
js0ny 2024-08-12 16:34:26 +08:00
parent 684f694d23
commit 1a0f4a01a4
3 changed files with 81 additions and 29 deletions

19
pathlib.json Normal file
View file

@ -0,0 +1,19 @@
{
".bashrc": "~/.bashrc",
".zshrc": "~/.zshrc",
"nvim/": "~/.config/nvim/",
".condarc": "~/.condarc",
".gitconfig": "~/.gitconfig",
".ideavimrc": "~/.ideavimrc",
"pip.conf": "~/.config/pip/pip.conf",
".npmrc": "~/.npmrc",
"Microsoft.PowerShell_profile.ps1": {
"Mac": "~/.config/powershell/Microsoft.PowerShell_profile.ps1",
"Windows": "~/Documents/PowerShell/Microsoft.PowerShell_profile.ps1"
},
".wslconfig": "~/.wslconfig",
"neovide.toml": {
"Mac": "~/.config/neovide/neovide.toml",
"Windows": "~/AppData/Local/neovide/neovide.toml"
}
}

33
powershell/bw.ps1 Normal file
View file

@ -0,0 +1,33 @@
function Get-Password {
param (
[Parameter(Mandatory = $true)]
[string]$Name,
[Boolean]$Hidden = $true
)
$result = (bw list items --search $Name | ConvertFrom-Json).login | Select-Object -Property username, password
if ($result.Length -eq 0) {
Write-Host -ForegroundColor Red "No password found"
return
}
elseif ($result.Length -gt 1) {
Write-Host -ForegroundColor Red "More than one password found, please specify"
$counter = 0
foreach ($username in $result.username) {
Write-Host "["$counter "]" $username
$counter++
}
$selector = Read-Host -MaskInput "Select the username"
if ($result[$selector] -eq "") {
Write-Host -ForegroundColor Red "Invalid selection"
return
}
$result = $result[$selector]
}
if ($Hidden) {
Write-Host -ForegroundColor Green "Password copied to clipboard"
Set-Clipboard -Value $result.password
} else {
Write-Host $result
}
return $result
}

View file

@ -3,14 +3,6 @@
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command": "unbound",
"keys": "alt+shift+plus"
@ -47,6 +39,22 @@
"command": "unbound",
"keys": "alt+shift+left"
},
{
"command":
{
"action": "copy",
"singleLine": false
},
"keys": "ctrl+c"
},
{
"command":
{
"action": "moveFocus",
"direction": "up"
},
"keys": "ctrl+k"
},
{
"command": "paste",
"keys": "ctrl+v"
@ -60,12 +68,8 @@
"keys": "ctrl+shift+k"
},
{
"command":
{
"action": "moveFocus",
"direction": "up"
},
"keys": "ctrl+k"
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command":
@ -75,10 +79,6 @@
},
"keys": "ctrl+shift+h"
},
{
"command": "find",
"keys": "ctrl+shift+f"
},
{
"command":
{
@ -88,14 +88,6 @@
},
"keys": "alt+shift+d"
},
{
"command":
{
"action": "moveFocus",
"direction": "down"
},
"keys": "ctrl+j"
},
{
"command":
{
@ -104,6 +96,14 @@
},
"keys": "alt+shift+/"
},
{
"command":
{
"action": "moveFocus",
"direction": "down"
},
"keys": "ctrl+j"
},
{
"command":
{
@ -159,8 +159,8 @@
{
"face": "CaskaydiaCove Nerd Font"
},
"opacity": 95,
"useAcrylic": true
"opacity": 100,
"useAcrylic": false
},
"list":
[
@ -171,7 +171,7 @@
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell",
"opacity": 30,
"opacity": 100,
"scrollbarState": "hidden",
"source": "Windows.Terminal.PowershellCore",
"useAcrylic": true