blob: 5730017bfc721ddd0a194facd19d02dac81a98ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# Make our own copy-mode with Kakoune!
# cursor_y=$(tmux display-message -t "''${pane_id}" -p "#{cursor_y}") ;\
# cursor_x=$(tmux display-message -t "''${pane_id}" -p "#{cursor_x}") ;\
# pane_height=$(tmux display-message -t "''${pane_id}" -p "#{pane_height}") ;\
# line_count="$(wc -l "$file" |awk "{print \$1}")" ;\
# sel_line=$(( line_count - ( pane_height - cursor_y ) + 1 )) ;\
# printf "sel = %s\n" "$line_count" >>/tmp/debug.log ;\
# cursor="''${sel_line}.''${cursor_x},''${sel_line}.''${cursor_x}" ;\
# printf "cursor = %s\n" "$cursor" >>/tmp/debug.log
kakoune_session="$(tmux display-message -p "#{window_name}" | sed "s/kakc@//")"
dispatch_name="dispatch://$(tmux display-message -p "#{pane_start_command}")"
case "${@}" in
'')
output=$(mktemp -d /tmp/kak-tmux.XXXXXXXX)/fifo
mkfifo ${output}
( tmux capture-pane -S '-' -E '-' -J -e -p -t $TMUX_PANE | filter-ansi >${output} & )
tmux new-window -t kaks@$kakoune_session -n "$dispatch_name" -d "
kak -c '$kakoune_session' -e \"edit -fifo ${output} '${dispatch_name}';\
set-option buffer readonly true ;\
set-option window filetype dispatch ;\
hook -always -once buffer BufCloseFifo .* %{ nop %sh{ rm -r $(dirname ${output}) } }\""
tmux swap-pane -s kaks@$kakoune_session:"$dispatch_name".0 -t :
;;
--quit)
tmux break-pane -t kaks@$kakoune_session -a -d -n "$dispatch_name"
;;
esac
|