Update from joey@joey-laptop: Polish fzf-bw and create function bwf (bw fuzzyfind) to use it.
Some checks failed
SSH and echo to file / ssh (push) Failing after 4s

This commit is contained in:
Joey Hafner 2024-09-21 14:12:08 -07:00
parent e4f1d2f5e1
commit 7c56e94b4f
9 changed files with 41 additions and 21 deletions

View File

@ -5,24 +5,45 @@
jq
wl-clipboard
( writeShellApplication {
name = "fzf-bw";
name = "fzf-bw"; # { bwJson }: { itemPreviewJson }
runtimeInputs = [
jq
fzf
wl-clipboard
( writeShellApplication {
name = "fzf-bw-preview";
name = "fzf-bw-getUser"; # { itemJson }: { itemUsername }
runtimeInputs = [ jq ];
text = ''echo "$2" | jq -C --arg id "$1" '.[] | select(.id==$id) | {"user": "\(.login.username)", "password": "\(.login.password)", "name": "\(.name)"}' '';
text = ''echo "$1" | jq -r '.user' '';
} )
];
( writeShellApplication {
name = "fzf-bw-getPass"; # { itemJson }: { itemPassword }
runtimeInputs = [ jq ];
text = ''echo "$1" | jq -r '.password' '';
} )
( writeShellApplication {
name = "fzf-bw-getItem"; # { itemUuid, bwJson }: { itemJson }
runtimeInputs = [ jq ];
text = ''echo "$2" | jq -c --arg id "$1" '.[] | select(.id==$id) | {"user": "\(.login.username)", "password": "\(.login.password)", "name": "\(.name)"}' '';
} )
( writeShellApplication {
name = "fzf-bw-selector"; # { bwJson }: { itemUuid }
runtimeInputs = [ jq fzf ];
text = ''export json="$1"; echo "$json" | jq -r '.[].id' | fzf --height 30% --preview='fzf-bw-getItem {} "$json" | jq -C' --preview-window right --disabled --border --padding=1'';
excludeShellChecks = [ "SC2016" ];
} )
] ;
excludeShellChecks = [ "SC2016" ];
text = ''export json="$1"; echo "$json" | jq -r '.[].id' | fzf --height 30% --preview='fzf-bw-preview {} "$json"' --preview-window right --disabled --border --padding=1 '';
text = ''export json="$1"; itemJson="$(fzf-bw-getItem "$(fzf-bw-selector "$json")" "$json")"; echo "Username: (copied to clipboard)"; fzf-bw-getUser "$itemJson" | wl-copy; read -r; echo "Password: (copied to clipboard)"; fzf-bw-getPass "$itemJson" | wl-copy'';
} )
( writeShellApplication {
name = "fzf-bw-copy";
runtimeInputs = [ jq wl-clipboard ];
text = ''json="$1"'';
];
programs.zsh.loginExtra = ''export $(bw unlock --passwordfile /home/joey/.bwtoken | grep export | sed 's/^\$\s//' | cut -d' ' -f2)'';
programs.zsh.loginExtra = ''
export $(bw unlock --passwordfile /home/joey/.bwtoken | grep export | sed 's/^\$\s//' | cut -d' ' -f2)
function bwf { search="$1"; fzf-bw "$(bw list items --search "$search")" }
'';
}
# function { inputs }: { outputs }
# fzf-bw { bwJson }: { none } # copies user, pass to clipboard
# fzf-bw-getItem { itemUuid, bwJson }: { itemJson }
# fzf-bw-selector { bwJson }: { itemUuid }
# fzf-bw-getUser { itemJson }: { itemUsername }
# fzf-bw-getPass { itemJson }: { itemPassword }

View File

@ -1,6 +1,6 @@
{ pkgs, ... }:
{ ... }:
{
services.flatpak.packages = [
{ appId = "io.github.zen_browser.zen"; origin = "flathub"; }
];
}
}

View File

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ ... }:
{
programs.plasma = {
enable = true;

View File

@ -22,7 +22,7 @@
ls = "eza";
fetch = "fastfetch";
neofetch = "fetch";
fzf = ''fzf --preview "bat --color=always --style=numbers --line-range=:500 {}"'';
find = ''fzf --preview "bat --color=always --style=numbers --line-range=:500 {}"'';
nu = "sudo nixos-rebuild switch --flake ~/Jafner.net/nix";
hmu = "home-manager switch -b bak --flake ~/Jafner.net/nix";
ngls = "nix-env --profile /nix/var/nix/profiles/system --list-generations";

View File

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ ... }:
{
stylix = {
image = ./cooper.png;

View File

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ ... }:
{
stylix = {
image = ./temple.png;

View File

@ -20,7 +20,6 @@
# Desktop apps
home.packages = with pkgs; [
jq
git
kdePackages.kdeconnect-kde
];

View File

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ ... }:
{
services.flatpak.enable = true;

View File

@ -1,7 +1,7 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs-stable, modulesPath, ... }:
{ config, lib, modulesPath, ... }:
{
imports =