diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-04-13 20:35:57 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-04-13 20:39:52 +0530 |
| commit | b9b036c7eb19dce1b4a996915dcfdfda18b2c6ca (patch) | |
| tree | 288bd8eec45884a41251d491456e358b5803564c /scripts | |
| parent | 90862ce996ee704042333532f601eef08588722f (diff) | |
| download | nixos-config-b9b036c7eb19dce1b4a996915dcfdfda18b2c6ca.tar.gz nixos-config-b9b036c7eb19dce1b4a996915dcfdfda18b2c6ca.zip | |
Config sync
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/fzfmenu.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/fzfmenu.sh b/scripts/fzfmenu.sh new file mode 100755 index 0000000..978b6b7 --- /dev/null +++ b/scripts/fzfmenu.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env sh + +# log_() { echo "$@" >> ~/dump/log; } + +set -e; + +screen_width=$(xdotool getdisplaygeometry 2>/dev/null | cut -d' ' -f1) + +width_px=1000 +height_lines=25 +top_offset=0 +font_width=7 + +win_width=$(($width_px / $font_width)) +win_offset=$((($screen_width - $width_px) / 2)) + +fzf_args=$([ -z "$*" ] && echo "" || printf "'%s' " "$@") + +stdin_pipe=$(mktemp -u /tmp/fzfmenu-input-XXXX) +stdout_pipe=$(mktemp -u /tmp/fzfmenu-output-XXXX) +mkfifo "$stdin_pipe" "$stdout_pipe" + +trap "rm -f '$stdin_pipe' '$stdout_pipe'" EXIT + +cat >"$stdin_pipe" <&0 & +cat "$stdout_pipe" & + +cmd="fzf --height=100% $fzf_args <'$stdin_pipe' >'$stdout_pipe'" + +st \ + -i -g "=${win_width}x${height_lines}+${win_offset}+${top_offset}" \ + -e sh -c "$cmd" \ + >/dev/null 2>&1; + +wait; |
