mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 10:11:14 +00:00
Merge pull request #572 from josephfrazier/ls_all
Suggest `ls -A` when `ls` has no output
This commit is contained in:
commit
6173913291
@ -202,6 +202,7 @@ using the matched rule and runs it. Rules enabled by default are as follows:
|
||||
* `lein_not_task` – fixes wrong `lein` tasks like `lein rpl`;
|
||||
* `ln_no_hard_link` – catches hard link creation on directories, suggest symbolic link;
|
||||
* `ln_s_order` – fixes `ln -s` arguments order;
|
||||
* `ls_all` – adds `-A` to `ls` when output is empty;
|
||||
* `ls_lah` – adds `-lah` to `ls`;
|
||||
* `man` – changes manual section;
|
||||
* `man_no_space` – fixes man commands without spaces, for example `mandiff`;
|
||||
|
12
tests/rules/test_ls_all.py
Normal file
12
tests/rules/test_ls_all.py
Normal file
@ -0,0 +1,12 @@
|
||||
from thefuck.rules.ls_all import match, get_new_command
|
||||
from tests.utils import Command
|
||||
|
||||
|
||||
def test_match():
|
||||
assert match(Command(script='ls'))
|
||||
assert not match(Command(script='ls', stdout='file.py\n'))
|
||||
|
||||
|
||||
def test_get_new_command():
|
||||
assert get_new_command(Command(script='ls empty_dir')) == 'ls -A empty_dir'
|
||||
assert get_new_command(Command(script='ls')) == 'ls -A'
|
10
thefuck/rules/ls_all.py
Normal file
10
thefuck/rules/ls_all.py
Normal file
@ -0,0 +1,10 @@
|
||||
from thefuck.utils import for_app
|
||||
|
||||
|
||||
@for_app('ls')
|
||||
def match(command):
|
||||
return command.stdout.strip() == ''
|
||||
|
||||
|
||||
def get_new_command(command):
|
||||
return ' '.join(['ls', '-A'] + command.script_parts[1:])
|
Loading…
x
Reference in New Issue
Block a user