aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-05-02 16:31:47 +0530
committerAkshay Nair <phenax5@gmail.com>2025-05-02 16:31:47 +0530
commit05f36728f6c23eca37eded1d8e4fe7d0da65aa97 (patch)
tree6e24bb14b3b107a2b2131b93089eab15c687b799
parent8ff77c65e86d5a44374b3d7d6de92b322464759c (diff)
downloadnixos-config-05f36728f6c23eca37eded1d8e4fe7d0da65aa97.tar.gz
nixos-config-05f36728f6c23eca37eded1d8e4fe7d0da65aa97.zip
Fix fzfmenu script
-rw-r--r--config/zsh/aliases/dev.zsh2
-rwxr-xr-xscripts/fzfmenu.sh48
2 files changed, 33 insertions, 17 deletions
diff --git a/config/zsh/aliases/dev.zsh b/config/zsh/aliases/dev.zsh
index 46b1b7f..064eba4 100644
--- a/config/zsh/aliases/dev.zsh
+++ b/config/zsh/aliases/dev.zsh
@@ -3,6 +3,8 @@ alias remi="wyrd $REMINDER_FILE";
alias aws="docker run --rm -it amazon/aws-cli"
+alias pop_run="cd ~/dev/pop && just run"
+
# nix shell with zsh
nix-zsh() { nix-shell --run "WITH_NIX_PREFIX='${NX_PREFIX:-':'}' zsh" "$@"; }
diff --git a/scripts/fzfmenu.sh b/scripts/fzfmenu.sh
index 978b6b7..7166cef 100755
--- a/scripts/fzfmenu.sh
+++ b/scripts/fzfmenu.sh
@@ -4,32 +4,46 @@
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))
+fzfmenu() {
+ local screen_width=$(xdotool getdisplaygeometry 2>/dev/null | cut -d' ' -f1)
+
+ local win_width=$(($width_px / $font_width))
+ local win_offset=$((($screen_width - $width_px) / 2))
+
+ local fzf_args=$([ -z "$*" ] && echo "" || printf "'%s' " "$@")
+
+ local stdin_pipe=$(mktemp -u /tmp/fzfmenu-input-XXXX)
+ local stdout_pipe=$(mktemp -u /tmp/fzfmenu-output-XXXX)
+ mkfifo "$stdin_pipe" "$stdout_pipe"
+
+ trap "rm -f '$stdin_pipe' '$stdout_pipe'" EXIT
-fzf_args=$([ -z "$*" ] && echo "" || printf "'%s' " "$@")
+ cat >"$stdin_pipe" <&0 &
+ cat "$stdout_pipe" &
-stdin_pipe=$(mktemp -u /tmp/fzfmenu-input-XXXX)
-stdout_pipe=$(mktemp -u /tmp/fzfmenu-output-XXXX)
-mkfifo "$stdin_pipe" "$stdout_pipe"
+ local cmd="fzf --height=100% $fzf_args <'$stdin_pipe' >'$stdout_pipe'"
-trap "rm -f '$stdin_pipe' '$stdout_pipe'" EXIT
+ st \
+ -i -g "=${win_width}x${height_lines}+${win_offset}+${top_offset}" \
+ -e sh -c "$cmd" \
+ >/dev/null 2>&1;
-cat >"$stdin_pipe" <&0 &
-cat "$stdout_pipe" &
+ wait;
+}
-cmd="fzf --height=100% $fzf_args <'$stdin_pipe' >'$stdout_pipe'"
+fzfinput() {
+ fzfmenu --print-query "$@" | tail -n 1;
+}
-st \
- -i -g "=${win_width}x${height_lines}+${win_offset}+${top_offset}" \
- -e sh -c "$cmd" \
- >/dev/null 2>&1;
+cmd="$1";
+case "$cmd" in
+ select) shift 1; fzfmenu "$@" ;;
+ input) shift 1;fzfinput "$@" ;;
+ *) fzfmenu "$@" ;;
+esac
-wait;