mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +00:00
refact(shells): add support to Fish functions
Signed-off-by: Pablo Santiago Blum de Aguiar <scorphus@gmail.com>
This commit is contained in:
parent
2bebfabf8d
commit
551e35e3b6
@ -78,6 +78,12 @@ class TestFish(object):
|
||||
def shell(self):
|
||||
return shells.Fish()
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def Popen(self, mocker):
|
||||
mock = mocker.patch('thefuck.shells.Popen')
|
||||
mock.return_value.stdout.read.return_value = (b'funced\nfuncsave\ngrep')
|
||||
return mock
|
||||
|
||||
@pytest.mark.parametrize('before, after', [
|
||||
('pwd', 'pwd'),
|
||||
('ll', 'll')]) # Fish has no aliases but functions
|
||||
@ -98,7 +104,9 @@ class TestFish(object):
|
||||
assert shell.and_('foo', 'bar') == 'foo; and bar'
|
||||
|
||||
def test_get_aliases(self, shell):
|
||||
assert shell.get_aliases() == {}
|
||||
assert shell.get_aliases() == {'funced': 'funced',
|
||||
'funcsave': 'funcsave',
|
||||
'grep': 'grep'}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('isfile')
|
||||
|
@ -97,6 +97,15 @@ class Fish(Generic):
|
||||
" end\n"
|
||||
"end")
|
||||
|
||||
def get_aliases(self):
|
||||
if not self._aliases:
|
||||
proc = Popen('fish -ic functions', stdout=PIPE, stderr=DEVNULL,
|
||||
shell=True)
|
||||
functions = proc.stdout.read().decode('utf-8').strip().split('\n')
|
||||
self._aliases = dict((function, function) for function in functions)
|
||||
|
||||
return self._aliases
|
||||
|
||||
def _get_history_file_name(self):
|
||||
return os.path.expanduser('~/.config/fish/fish_history')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user