From 1a0f4a01a4f840a46c77edcb08d5045eb6ac0ce1 Mon Sep 17 00:00:00 2001 From: js0ny Date: Mon, 12 Aug 2024 16:34:26 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=9F:=20Add=20pathlib,=20PowerShell=20P?= =?UTF-8?q?assword=20Script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pathlib.json | 19 +++++++++++++ powershell/bw.ps1 | 33 +++++++++++++++++++++++ win/WindowsTerminal.json | 58 ++++++++++++++++++++-------------------- 3 files changed, 81 insertions(+), 29 deletions(-) create mode 100644 pathlib.json create mode 100644 powershell/bw.ps1 diff --git a/pathlib.json b/pathlib.json new file mode 100644 index 0000000..d58927a --- /dev/null +++ b/pathlib.json @@ -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" + } +} \ No newline at end of file diff --git a/powershell/bw.ps1 b/powershell/bw.ps1 new file mode 100644 index 0000000..cde2fc4 --- /dev/null +++ b/powershell/bw.ps1 @@ -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 +} \ No newline at end of file diff --git a/win/WindowsTerminal.json b/win/WindowsTerminal.json index 6842854..05345f4 100644 --- a/win/WindowsTerminal.json +++ b/win/WindowsTerminal.json @@ -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