mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +00:00
Add a tmux rule
This commit is contained in:
parent
cb33c912e5
commit
3822f62d90
@ -189,7 +189,8 @@ using the matched rule and runs it. Rules enabled by default are as follows:
|
||||
* `sudo` – prepends `sudo` to previous command if it failed because of permissions;
|
||||
* `switch_layout` – switches command from your local layout to en;
|
||||
* `systemctl` – correctly orders parameters of confusing systemctl;
|
||||
* `test.py` &ndasg; runs `py.test` instead of `test.py`;
|
||||
* `test.py` – runs `py.test` instead of `test.py`;
|
||||
* `tmux` – fixes tmux commands;
|
||||
* `whois` – fixes `whois` command.
|
||||
|
||||
Enabled by default only on specific platforms:
|
||||
|
19
tests/rules/test_tmux.py
Normal file
19
tests/rules/test_tmux.py
Normal file
@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
from thefuck.rules.tmux import match, get_new_command
|
||||
from tests.utils import Command
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tmux_ambiguous():
|
||||
return "ambiguous command: list, could be: " \
|
||||
"list-buffers, list-clients, list-commands, list-keys, " \
|
||||
"list-panes, list-sessions, list-windows"
|
||||
|
||||
|
||||
def test_match(tmux_ambiguous):
|
||||
assert match(Command('tmux list', stderr=tmux_ambiguous), None)
|
||||
|
||||
|
||||
def test_get_new_command(tmux_ambiguous):
|
||||
assert get_new_command(Command('tmux list', stderr=tmux_ambiguous), None)\
|
||||
== 'tmux list-buffers'
|
14
thefuck/rules/tmux.py
Normal file
14
thefuck/rules/tmux.py
Normal file
@ -0,0 +1,14 @@
|
||||
import re
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
return ('tmux' in command.script
|
||||
and 'ambiguous command:' in command.stderr
|
||||
and 'could be:' in command.stderr)
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
cmd = re.match(r"ambiguous command: (.*), could be: ([^, \n]*)",
|
||||
command.stderr)
|
||||
|
||||
return command.script.replace(cmd.group(1), cmd.group(2))
|
Loading…
x
Reference in New Issue
Block a user