all repos — dotfiles @ fbd4a0d2799ca35ab51aed3f1c6038c394fe3991

my *nix dotfiles

bash: fix fzy reverse search
Anirudh Oppiliappan x@icyphox.sh
Wed, 01 Nov 2023 20:54:39 +0200
commit

fbd4a0d2799ca35ab51aed3f1c6038c394fe3991

parent

0cd32a4982c6e6f43b0d1473de0c5b8c7c6f8256

4 files changed, 21 insertions(+), 192 deletions(-)

jump to
M nix/flake.locknix/flake.lock

@@ -21,104 +21,6 @@ "repo": "nix-darwin",

"type": "github" } }, - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": [ - "neovim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1698579227, - "narHash": "sha256-KVWjFZky+gRuWennKsbo6cWyo7c/z/VgCte5pR9pEKg=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "f76e870d64779109e41370848074ac4eaa1606ec", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "flake-parts", - "type": "github" - } - }, - "flake-parts_2": { - "inputs": { - "nixpkgs-lib": [ - "neovim", - "hercules-ci-effects", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1696343447, - "narHash": "sha256-B2xAZKLkkeRFG5XcHHSXXcP7To9Xzr59KXeZiRf4vdQ=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4", - "type": "github" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1685518550, - "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "hercules-ci-effects": { - "inputs": { - "flake-parts": "flake-parts_2", - "nixpkgs": [ - "neovim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1698165573, - "narHash": "sha256-cnMTgCDnZiQKsf+wVzigpexskqRCFTKgS58Wx2rNU1c=", - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "rev": "300e0af24a1bbe32d115beb182efb01785582c45", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "hercules-ci-effects", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [

@@ -139,52 +41,6 @@ "repo": "home-manager",

"type": "github" } }, - "neovim": { - "inputs": { - "flake-compat": "flake-compat", - "flake-parts": "flake-parts", - "hercules-ci-effects": "hercules-ci-effects", - "neovim-flake": "neovim-flake", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1698624085, - "narHash": "sha256-n3Qy+j0Y3Tiw/JtxnDdWLiReTodikcxzvAr2CgvqMwM=", - "owner": "nix-community", - "repo": "neovim-nightly-overlay", - "rev": "06a5aedc5a6da00f5340deff07a41dd9b4b6e31b", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "neovim-nightly-overlay", - "type": "github" - } - }, - "neovim-flake": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": [ - "neovim", - "nixpkgs" - ] - }, - "locked": { - "dir": "contrib", - "lastModified": 1698578059, - "narHash": "sha256-ag1gtyLgdz42ytzv3X+6T8ir1Ul1fiPTg5NCf8RWs/s=", - "owner": "neovim", - "repo": "neovim", - "rev": "8405649f92a8a8eb254944eca15e8b0169cbb6fb", - "type": "github" - }, - "original": { - "dir": "contrib", - "owner": "neovim", - "repo": "neovim", - "type": "github" - } - }, "nixos-hardware": { "locked": { "lastModified": 1698053470,

@@ -202,22 +58,6 @@ }

}, "nixpkgs": { "locked": { - "lastModified": 1698553279, - "narHash": "sha256-T/9P8yBSLcqo/v+FTOBK+0rjzjPMctVymZydbvR/Fak=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "90e85bc7c1a6fc0760a94ace129d3a1c61c3d035", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { "lastModified": 1698434055, "narHash": "sha256-Phxi5mUKSoL7A0IYUiYtkI9e8NcGaaV5PJEaJApU1Ko=", "owner": "NixOS",

@@ -256,25 +96,9 @@ "root": {

"inputs": { "darwin": "darwin", "home-manager": "home-manager", - "neovim": "neovim", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs", "prompt": "prompt" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" } } },
M nix/flake.nixnix/flake.nix

@@ -11,7 +11,6 @@ url = "github:nix-community/home-manager";

inputs.nixpkgs.follows = "nixpkgs"; }; - neovim.url = "github:nix-community/neovim-nightly-overlay"; darwin = { url = "github:lnl7/nix-darwin/master";

@@ -29,14 +28,12 @@ { self

, nixpkgs , nixos-hardware , home-manager - , neovim , prompt , darwin , ... } @ inputs: { overlays = { - nvim-nightly = neovim.overlay; prompt = prompt.overlay; };
M nix/hosts/wyndle/configuration.nixnix/hosts/wyndle/configuration.nix

@@ -64,7 +64,6 @@ firefox.enablePlasmaBrowserIntegration = true;

}; nixpkgs.overlays = with self.overlays; [ - nvim-nightly prompt ];
M nix/programs/bash.nixnix/programs/bash.nix

@@ -91,22 +91,31 @@ }

''; initExtra = '' - # Ctrl+W kills word - stty werase undef + __fzy_history__() { + script='function P(b) { ++n; sub(/^[ *]/, "", b); if (!seen[b]++) { printf "%d\t%s%c", '$((BASH_REMATCH + 1))' - n, b, 0 } } + NR==1 { b = substr($0, 2); next } + /^\t/ { P(b); b = substr($0, 2); next } + { b = b RS $0 } + END { if (NR) P(b) }' - # fzy reverse search - __fzy_history() { - ch="$(fc -rl 1 | awk -F'\t' '{print $2}' | sort -u | fzy)" - : "''${ch#"''${ch%%[![:space:]]*}"}" - printf "$_" + + output=$( + set +o pipefail + builtin fc -lnr -2147483648 2> /dev/null | # ( $'\t '<lines>$'\n' )* ; <lines> ::= [^\n]* ( $'\n'<lines> )* + command awk "$script" | # ( <counter>$'\t'<lines>$'\000' )* + fzy --query "$READLINE_LINE" + ) || return + READLINE_LINE=''${output#*$'\t'} + if [[ -z "$READLINE_POINT" ]]; then + echo "$READLINE_LINE" + else + READLINE_POINT=0x7fffffff + fi } - bind -x '"\C-r": READLINE_LINE=$(__fzy_history); READLINE_POINT="''${#READLINE_LINE}"' + bind -m emacs-standard -x '"\C-r": __fzy_history__' complete -cf doas - - source <(kubectl completion bash) - complete -F __start_kubectl k ''; };