diff --git a/nix/debug.txt b/nix/debug.txt new file mode 100644 index 00000000..e475d899 --- /dev/null +++ b/nix/debug.txt @@ -0,0 +1 @@ +0.55.0 (v0.55.0) diff --git a/nix/home-manager/app/bitwarden/.bitwarden.nix.swp b/nix/home-manager/app/bitwarden/.bitwarden.nix.swp new file mode 100644 index 00000000..cd36ab28 Binary files /dev/null and b/nix/home-manager/app/bitwarden/.bitwarden.nix.swp differ diff --git a/nix/home-manager/app/bitwarden/bitwarden.nix b/nix/home-manager/app/bitwarden/bitwarden.nix index e42d8ced..bd53ce0e 100644 --- a/nix/home-manager/app/bitwarden/bitwarden.nix +++ b/nix/home-manager/app/bitwarden/bitwarden.nix @@ -1,9 +1,10 @@ -{ pkgs, ... }: +{ pkgs, pkgs-unstable, ... }: { home.packages = with pkgs; [ bitwarden-cli jq wl-clipboard + tmux ( writeShellApplication { name = "fzf-bw"; # { bwJson }: { itemPreviewJson } runtimeInputs = [ @@ -25,19 +26,28 @@ } ) ( writeShellApplication { name = "fzf-bw-selector"; # { bwJson }: { itemUuid } - runtimeInputs = [ jq fzf ]; - text = ''export json="$1"; echo "$json" | jq -r '.[].id' | fzf --height 33% --preview='fzf-bw-getItem {} "$json" | jq -C' --preview-window right,60% --disabled --border --padding=1''; + runtimeInputs = [ jq pkgs-unstable.fzf ]; + text = ''export json="$1"; echo "$json" | jq -r '.[].id' | fzf --preview='fzf-bw-getItem {} "$json" | jq -C' --disabled ''; + excludeShellChecks = [ "SC2016" ]; + } ) + ( writeShellApplication { + name = "fzf-bw-selector-tmux"; # { bwJson }: { itemUuid } + runtimeInputs = [ jq pkgs-unstable.fzf ]; + text = ''export json="$1"; echo "$json" | jq -r '.[].id' | fzf --tmux center,70% --preview='fzf-bw-getItem {} "$json" | jq -C' ''; excludeShellChecks = [ "SC2016" ]; } ) ] ; excludeShellChecks = [ "SC2016" ]; - 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''; + # Todo: Gracefully handle Ctrl+C canceling, offer method to directly print or copy a password, implement fzf-tmux. + # Roadmap: sops integration to decrypt passwords as late as possible, window-manager hotkey for quicker use in graphical applications. + text = ''export json="$1"; itemJson="$(fzf-bw-getItem "$(fzf-bw-selector "$json")" "$json")"; echo -n "Username: (copied to clipboard)"; fzf-bw-getUser "$itemJson" | wl-copy; read -r; echo "Password: (copied to clipboard)"; fzf-bw-getPass "$itemJson" | wl-copy; exit 0''; } ) - ]; programs.zsh.loginExtra = '' - export $(bw unlock --passwordfile /home/joey/.bwtoken | grep export | sed 's/^\$\s//' | cut -d' ' -f2) + export $(bw unlock --passwordfile /home/joey/.bwtoken | grep export | sed 's/^\$\s//' | cut -d' ' -f2) 2>/dev/null function bwf { search="$1"; fzf-bw "$(bw list items --search "$search")" } + function bwf-popup { search="$1"; kitty --title fzf-bw --override remember_window_size=no --override initial_window_width=960 --override initial_window_height=300 fzf-bw "$(bw list items --search $search)" } + ''; } diff --git a/nix/home-manager/app/fzf-jq/fzf-jq.nix b/nix/home-manager/app/fzf-jq/fzf-jq.nix new file mode 100644 index 00000000..eee46742 --- /dev/null +++ b/nix/home-manager/app/fzf-jq/fzf-jq.nix @@ -0,0 +1,19 @@ +{ pkgs, pkgs-unstable, ... }: +{ + home.packages = with pkgs; [ + jq + wl-clipboard + ( writeShellApplication { + name = "fzf-jq"; # { bwJson }: { itemPreviewJson } + runtimeInputs = [ wl-clipboard jq ] ; + excludeShellChecks = [ "SC2016" ]; + text = ''export json="$1"; itemJson="$(fzf-bw-getItem "$(fzf-bw-selector "$json")" "$json")"; echo -n "Username: (copied to clipboard)"; fzf-bw-getUser "$itemJson" | wl-copy; read -r; echo "Password: (copied to clipboard)"; fzf-bw-getPass "$itemJson" | wl-copy; exit 0''; + } ) + ]; + programs.zsh.loginExtra = '' ''; +} + +# fzf-jq { jsonBody, searchByExp, itemPreviewExp }: { } +# summary: allows the user to interactively browse json objects +# details: takes a json object containing a list of objects, a jq expression which returns the list of objects on one line each, and a jq expression which returns only the object currently selected + diff --git a/nix/home-manager/app/sh/sh.nix b/nix/home-manager/app/sh/sh.nix index 78616a1a..000dabc4 100644 --- a/nix/home-manager/app/sh/sh.nix +++ b/nix/home-manager/app/sh/sh.nix @@ -7,6 +7,13 @@ enable = true; }; + ## Tmux + programs.tmux = { + enable = true; + newSession = true; + shell = "$HOME/.nix-profile/bin/zsh"; + }; + # Shell ## Zsh programs.zsh = { @@ -17,7 +24,6 @@ syntaxHighlighting.enable = true; shellAliases = { bat = "bat --paging=never --color=always"; - cat = "bat"; fd = "fd -Lu"; ls = "eza"; fetch = "fastfetch"; @@ -63,7 +69,7 @@ home.packages = with pkgs; [ fastfetch tree btop - bat fd eza fzf-git-sh tmux + bat fd eza fzf-git-sh wl-clipboard pkgs-unstable.fzf ]; @@ -108,11 +114,5 @@ programs.fzf = { enable = true; package = pkgs-unstable.fzf; - }; - - ## tmux - programs.tmux = { - enable = true; - }; - + }; }