From a3d76b8b94571e13958e433608ffc278ae839d2e Mon Sep 17 00:00:00 2001 From: Marc Deop Date: Thu, 9 May 2024 17:03:34 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20add=20an=20optional=20second=20paramete?= =?UTF-8?q?r=20to=20trigger=20extrakto=20with=20a=20spe=E2=80=A6=20(#118)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add an optional second parameter to trigger extrakto with a specific filter temporarily * feat: define the initial filter via optional second parameter The previous implementation of this functionallity temporary replaced the @extrakto_filter_order and restored the original value when finished. This is a much more elegant solution * refactor: use lower for extrakto_inital_mode environment variable --- scripts/helpers.sh | 2 +- scripts/open.sh | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/helpers.sh b/scripts/helpers.sh index 8782629..599c773 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -163,7 +163,7 @@ get_next_mode() { local next=$1 if [ $next == "initial" ]; then - echo ${modes_list[0]} + echo ${extrakto_inital_mode:-${modes_list[0]}} else echo ${next_mode[$next]} fi diff --git a/scripts/open.sh b/scripts/open.sh index 80ef8ef..d9c5da3 100755 --- a/scripts/open.sh +++ b/scripts/open.sh @@ -8,6 +8,7 @@ extrakto="$current_dir/extrakto.sh" pane_id=$1 split_direction=$(get_option "@extrakto_split_direction") +extrakto_inital_mode="$2" if [[ $split_direction == a ]]; then if [[ -n $(tmux list-commands popup) ]]; then split_direction=p @@ -26,11 +27,15 @@ if [[ $split_direction == p ]]; then -h ${popup_height:-$popup_width} \ -x ${popup_x} \ -y ${popup_y:-$popup_x} \ + -e extrakto_inital_mode="${extrakto_inital_mode}" \ -E "${extrakto} ${pane_id} popup" rc=$? done exit $rc else split_size=$(get_option "@extrakto_split_size") - tmux split-window -${split_direction} -l ${split_size} "tmux setw remain-on-exit off; ${extrakto} ${pane_id} split" + tmux split-window \ + -${split_direction} \ + -e extrakto_inital_mode="${extrakto_inital_mode}" \ + -l ${split_size} "tmux setw remain-on-exit off; ${extrakto} ${pane_id} split" fi