1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-02-21 04:18:55 +00:00

Suggest ls -A when ls has no output

This commit is contained in:
Joseph Frazier 2016-10-10 14:55:45 -04:00
parent ddd8788353
commit 756044e087
3 changed files with 23 additions and 0 deletions

View File

@ -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`;

View 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
View 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:])