mirror of
https://github.com/Morantron/tmux-fingers.git
synced 2024-06-26 07:29:11 +02:00
use tmux status bar format
This commit is contained in:
parent
ad3bcb37cf
commit
844d6b8315
|
@ -14,6 +14,25 @@ function check_pattern() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function identity_fn() {
|
||||||
|
echo -ne "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function export_option() {
|
||||||
|
local option_name="$(echo $1 | tr '[:lower:]' '[:upper:]' | sed "s/-/_/g")"
|
||||||
|
local default_value="$2"
|
||||||
|
local transform_fn="$3"
|
||||||
|
|
||||||
|
local option_value=$(tmux show-option -gqv "@$1")
|
||||||
|
local final_value="${option_value:-$default_value}"
|
||||||
|
|
||||||
|
if [[ ! -z "$transform_fn" ]]; then
|
||||||
|
final_value="$($transform_fn "$final_value")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
eval "export ${option_name}=\"$(echo -e "$final_value")\""
|
||||||
|
}
|
||||||
|
|
||||||
source "$CURRENT_DIR/utils.sh"
|
source "$CURRENT_DIR/utils.sh"
|
||||||
|
|
||||||
PATTERNS_LIST=(
|
PATTERNS_LIST=(
|
||||||
|
@ -45,12 +64,19 @@ done
|
||||||
PATTERNS=$(array_join "|" "${PATTERNS_LIST[@]}")
|
PATTERNS=$(array_join "|" "${PATTERNS_LIST[@]}")
|
||||||
export PATTERNS
|
export PATTERNS
|
||||||
|
|
||||||
DEFAULT_FINGER_COMPACT_HINTS=1
|
export_option 'fingers-compact-hints' 1
|
||||||
FINGERS_COMPACT_HINTS=$(tmux show-option -gqv @fingers-compact-hints)
|
export_option 'fingers-hint-format' 1
|
||||||
FINGERS_COMPACT_HINTS=${FINGERS_COMPACT_HINTS:-$DEFAULT_FINGER_COMPACT_HINTS}
|
export_option 'fingers-copy-command' ""
|
||||||
export FINGERS_COMPACT_HINTS
|
|
||||||
|
|
||||||
export FINGERS_HINT_FORMAT=$(echo -e "\033[30;1;43m%s\033[0m")
|
function process_format () {
|
||||||
export FINGERS_HIGHLIGHT_FORMAT=$(echo -e "\033[1;33m%s\033[0m")
|
echo -ne "$($CURRENT_DIR/print.sh "$1")"
|
||||||
export FINGERS_HINT_FORMAT_SECONDARY=$(echo -e "\033[1;33m[%s]\033[0m")
|
}
|
||||||
export FINGERS_HIGHLIGHT_FORMAT_SECONDARY=$(echo -e "\033[1;33m%s\033[0m ")
|
|
||||||
|
echo "wtf: $(process_format "#[fg=yellow]%s")" >> $CURRENT_DIR/../fingers.log
|
||||||
|
|
||||||
|
export_option 'fingers-hint-format' "#[fg=yellow,bold,reverse]%%s" process_format
|
||||||
|
export_option 'fingers-highlight-format' "#[fg=yellow,bold]%%s" process_format
|
||||||
|
export_option 'fingers-hint-format-secondary' "#[fg=yellow,bold][%%s]" process_format
|
||||||
|
export_option 'fingers-highlight-format-secondary' " #[fg=yellow,bold]%%s" process_format
|
||||||
|
|
||||||
|
printenv | grep FINGERS >> $CURRENT_DIR/../fingers.log
|
||||||
|
|
|
@ -8,8 +8,6 @@ source $CURRENT_DIR/hints.sh
|
||||||
source $CURRENT_DIR/utils.sh
|
source $CURRENT_DIR/utils.sh
|
||||||
source $CURRENT_DIR/help.sh
|
source $CURRENT_DIR/help.sh
|
||||||
|
|
||||||
FINGERS_COPY_COMMAND=$(tmux show-option -gqv @fingers-copy-command)
|
|
||||||
|
|
||||||
current_pane_id=$1
|
current_pane_id=$1
|
||||||
fingers_pane_id=$2
|
fingers_pane_id=$2
|
||||||
pane_input_temp=$3
|
pane_input_temp=$3
|
||||||
|
|
30
scripts/print.sh
Executable file
30
scripts/print.sh
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
tmux_format="TMUX_PRINTER_FORMAT${1}TMUX_PRINTER_FORMAT_END"
|
||||||
|
style_conf=$(mktemp "/tmp/tmux-printer.XXXXXX")
|
||||||
|
empty_conf=$(mktemp "/tmp/tmux-printer.XXXXXX")
|
||||||
|
|
||||||
|
touch "$empty_conf"
|
||||||
|
echo "set -g status-left '$tmux_format'" >> "$style_conf"
|
||||||
|
echo "set -g status-left-length 255" >> "$style_conf"
|
||||||
|
echo "set -g status-right ''" >> "$style_conf"
|
||||||
|
|
||||||
|
PREV_TMUX=$TMUX
|
||||||
|
TMUX=''
|
||||||
|
|
||||||
|
tmux -L tmux-printer-outer -f "$empty_conf" new -s tmux-printer-outer -d
|
||||||
|
tmux -L tmux-printer-outer send-keys "TMUX='' tmux -L tmux-printer-inner -f \"$style_conf\""
|
||||||
|
tmux -L tmux-printer-outer send-keys Enter
|
||||||
|
sleep 0.1 # tmux wait?
|
||||||
|
output=$( \
|
||||||
|
tmux -L tmux-printer-outer capture-pane -p -e | \
|
||||||
|
grep --color=never -Eo "TMUX_PRINTER_FORMAT.*TMUX_PRINTER_FORMAT_END" | \
|
||||||
|
sed "s/TMUX_PRINTER_FORMAT\(_END\)\?//g" \
|
||||||
|
)
|
||||||
|
|
||||||
|
tmux -L tmux-printer-outer kill-server
|
||||||
|
tmux -L tmux-printer-inner kill-server
|
||||||
|
|
||||||
|
TMUX=$PREV_TMUX
|
||||||
|
|
||||||
|
echo -ne "$output$(tput sgr0)"
|
Loading…
Reference in New Issue
Block a user