1
0
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:
Vladimir Iakovlev 2016-11-01 12:51:04 +01:00 committed by GitHub
commit 6173913291
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:])