diff --git a/src/fingers/commands/start.cr b/src/fingers/commands/start.cr index 57361eb..ffa2f43 100644 --- a/src/fingers/commands/start.cr +++ b/src/fingers/commands/start.cr @@ -26,9 +26,11 @@ module Fingers::Commands class Start < Base @original_options : Hash(String, String) = {} of String => String + @last_pane_id : String | Nil def run - track_options_to_restore! + track_options_to_restore + track_last_pane show_hints if Fingers.config.benchmark_mode == "1" @@ -40,7 +42,7 @@ module Fingers::Commands teardown end - private def track_options_to_restore! + private def track_options_to_restore options_to_preserve.each do |option| value = tmux.get_global_option(option) @original_options[option] = value @@ -53,6 +55,16 @@ module Fingers::Commands end end + private def restore_last_pane + tmux.select_pane(@last_pane_id) + tmux.select_pane(target_pane.pane_id) + end + + private def track_last_pane + last_pane_id = tmux.exec("display-message -t '{last}' -p '\#{pane_id}'").chomp + @last_pane_id = last_pane_id unless last_pane_id.empty? + end + private def options_to_preserve %w[prefix prefix2] end @@ -94,7 +106,9 @@ module Fingers::Commands tmux.swap_panes(fingers_pane_id, target_pane.pane_id) tmux.kill_pane(fingers_pane_id) + restore_last_pane restore_options + view.run_action if state.result end diff --git a/src/tmux.cr b/src/tmux.cr index 7c03141..74e086b 100644 --- a/src/tmux.cr +++ b/src/tmux.cr @@ -283,7 +283,7 @@ class Tmux exec(Process.quote(["display-message", "-d", delay.to_s, msg])) end - private def exec(cmd) + def exec(cmd) @sh.exec("#{tmux} #{cmd}") end end