Skip to content

Commit

Permalink
Merge pull request #15 from pawlik/focus-pane-after-open
Browse files Browse the repository at this point in the history
Focus pane after open
  • Loading branch information
artemave authored Apr 4, 2024
2 parents 518044e + 94f5e0a commit 6b27a8c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ Now let's plug it in:
set -g @super-fingers-extend /path/to/the/above/code.py
```

## Troubleshooting

Check `/tmp/tmux_super_fingers_error.txt` for errors:
```
tail -F /tmp/tmux_super_fingers_error.txt
```

### Text files are not opened in vim/nvim but in a different editor

Please make sure your `EDITOR` env is set, and it's exclusively is set to `vim` or `nvim` (i.e. `EDITOR=/my/custom/path/nvim` will not work)


## Development

Prerequisites: python3, pipenv, node, make
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def perform(self) -> None:
editor_pane.pane_id,
f'Escape ":e {self._vim_e_args()}" Enter zz'
)
self.cli_adapter.select_tmux_pane(editor_pane.pane_id)
else:
self.cli_adapter.new_tmux_window(
os.environ['EDITOR'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ def test_sends_keys_to_existing_window_running_vim(monkeypatch: MonkeyPatch):

assert cli_adapter.calls == [
['select_tmux_window', '2'],
['tmux_send_keys', '2', 'Escape ":e +2 /tmp/file.txt" Enter zz']
['tmux_send_keys', '2', 'Escape ":e +2 /tmp/file.txt" Enter zz'],
['select_tmux_pane', '2']
]
7 changes: 7 additions & 0 deletions tmux_super_fingers/cli_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def find_tmux_pane_with_running_process(self, command: str) -> Optional[PaneProp
def select_tmux_window(self, id: str) -> None:
...

@abstractmethod
def select_tmux_pane(self, id: str) -> None:
...

@abstractmethod
def tmux_send_keys(self, id: str, keys: str) -> None:
...
Expand Down Expand Up @@ -83,6 +87,9 @@ def tty_sort(line: str) -> str:
def select_tmux_window(self, id: str) -> None:
os.system(f'tmux select-window -t {id}')

def select_tmux_pane(self, id: str) -> None:
os.system(f'tmux select-pane -t {id}')

def tmux_send_keys(self, id: str, keys: str) -> None:
os.system(f'tmux send-keys -t {id} {keys}')

Expand Down
3 changes: 3 additions & 0 deletions tmux_super_fingers/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def find_tmux_pane_with_running_process(self, command: str) -> Optional[PaneProp
def select_tmux_window(self, id: str) -> None:
self.calls.append(['select_tmux_window', id])

def select_tmux_pane(self, id: str) -> None:
self.calls.append(['select_tmux_pane', id])

def new_tmux_window(self, name: str, command: str) -> None:
self.calls.append(['new_tmux_window', name, command])

Expand Down

0 comments on commit 6b27a8c

Please sign in to comment.