diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index f831da6d..4c0b95a1 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -6,11 +6,8 @@ update The Fuck and see if the bug is still there. --> if not, just open an issue on [GitHub](https://github.com/nvbn/thefuck) with the following basic information: --> -The output of `thefuck --version` (something like `The Fuck 3.1 using Python 3.5.0`): - - FILL THIS IN - -Your shell and its version (`bash`, `zsh`, *Windows PowerShell*, etc.): +The output of `thefuck --version` (something like `The Fuck 3.1 using Python +3.5.0 and Bash 4.4.12(1)-release`): FILL THIS IN diff --git a/tests/shells/test_bash.py b/tests/shells/test_bash.py index b10ae0e3..1bb36651 100644 --- a/tests/shells/test_bash.py +++ b/tests/shells/test_bash.py @@ -73,3 +73,8 @@ class TestBash(object): config_exists): config_exists.return_value = False assert not shell.how_to_configure().can_configure_automatically + + def test_info(self, shell, mocker): + patch = mocker.patch('thefuck.shells.bash.Popen') + patch.return_value.stdout.read.side_effect = [b'3.5.9'] + assert shell.info() == 'Bash 3.5.9' diff --git a/tests/shells/test_fish.py b/tests/shells/test_fish.py index 815382b1..6d8a66fc 100644 --- a/tests/shells/test_fish.py +++ b/tests/shells/test_fish.py @@ -112,3 +112,7 @@ class TestFish(object): config_exists): config_exists.return_value = False assert not shell.how_to_configure().can_configure_automatically + + def test_info(self, shell, Popen): + Popen.return_value.stdout.read.side_effect = [b'3.5.9'] + assert shell.info() == 'Fish Shell 3.5.9' diff --git a/tests/shells/test_zsh.py b/tests/shells/test_zsh.py index fc20a061..cbbf3f57 100644 --- a/tests/shells/test_zsh.py +++ b/tests/shells/test_zsh.py @@ -68,3 +68,8 @@ class TestZsh(object): config_exists): config_exists.return_value = False assert not shell.how_to_configure().can_configure_automatically + + def test_info(self, shell, mocker): + patch = mocker.patch('thefuck.shells.zsh.Popen') + patch.return_value.stdout.read.side_effect = [b'3.5.9'] + assert shell.info() == 'ZSH 3.5.9' diff --git a/thefuck/entrypoints/main.py b/thefuck/entrypoints/main.py index 63f9d8c9..01346870 100644 --- a/thefuck/entrypoints/main.py +++ b/thefuck/entrypoints/main.py @@ -8,6 +8,7 @@ import sys # noqa: E402 from .. import logs # noqa: E402 from ..argument_parser import Parser # noqa: E402 from ..utils import get_installation_info # noqa: E402 +from ..shells import shell # noqa: E402 from .alias import print_alias # noqa: E402 from .fix_command import fix_command # noqa: E402 @@ -20,7 +21,7 @@ def main(): parser.print_help() elif known_args.version: logs.version(get_installation_info().version, - sys.version.split()[0]) + sys.version.split()[0], shell.info()) elif known_args.command or 'TF_HISTORY' in os.environ: fix_command(known_args) elif known_args.alias: diff --git a/thefuck/logs.py b/thefuck/logs.py index aab3aca2..0c50765a 100644 --- a/thefuck/logs.py +++ b/thefuck/logs.py @@ -134,7 +134,8 @@ def configured_successfully(configuration_details): reload=configuration_details.reload)) -def version(thefuck_version, python_version): +def version(thefuck_version, python_version, shell_info): sys.stderr.write( - u'The Fuck {} using Python {}\n'.format(thefuck_version, - python_version)) + u'The Fuck {} using Python {} and {}\n'.format(thefuck_version, + python_version, + shell_info)) diff --git a/thefuck/shells/bash.py b/thefuck/shells/bash.py index 6021fead..d8a53180 100644 --- a/thefuck/shells/bash.py +++ b/thefuck/shells/bash.py @@ -1,9 +1,10 @@ import os +from subprocess import Popen, PIPE from tempfile import gettempdir from uuid import uuid4 from ..conf import settings from ..const import ARGUMENT_PLACEHOLDER, USER_COMMAND_MARK -from ..utils import memoize +from ..utils import DEVNULL, memoize from .generic import Generic @@ -81,3 +82,10 @@ class Bash(Generic): content=u'eval $(thefuck --alias)', path=config, reload=u'source {}'.format(config)) + + def info(self): + """Returns the name and version of the current shell""" + proc = Popen(['bash', '-c', 'echo $BASH_VERSION'], + stdout=PIPE, stderr=DEVNULL) + version = proc.stdout.read().decode('utf-8').strip() + return u'Bash {}'.format(version) diff --git a/thefuck/shells/fish.py b/thefuck/shells/fish.py index 5693404b..1435f902 100644 --- a/thefuck/shells/fish.py +++ b/thefuck/shells/fish.py @@ -103,6 +103,13 @@ class Fish(Generic): path='~/.config/fish/config.fish', reload='fish') + def info(self): + """Returns the name and version of the current shell""" + proc = Popen(['fish', '-c', 'echo $FISH_VERSION'], + stdout=PIPE, stderr=DEVNULL) + version = proc.stdout.read().decode('utf-8').strip() + return u'Fish Shell {}'.format(version) + def put_to_history(self, command): try: return self._put_to_history(command) diff --git a/thefuck/shells/generic.py b/thefuck/shells/generic.py index a810d8a7..6d1eb962 100644 --- a/thefuck/shells/generic.py +++ b/thefuck/shells/generic.py @@ -131,6 +131,10 @@ class Generic(object): 'type', 'typeset', 'ulimit', 'umask', 'unalias', 'unset', 'until', 'wait', 'while'] + def info(self): + """Returns the name and version of the current shell""" + return 'Generic Shell' + def _create_shell_configuration(self, content, path, reload): return ShellConfiguration( content=content, diff --git a/thefuck/shells/zsh.py b/thefuck/shells/zsh.py index e771918a..d4ea3400 100644 --- a/thefuck/shells/zsh.py +++ b/thefuck/shells/zsh.py @@ -1,10 +1,11 @@ from time import time import os +from subprocess import Popen, PIPE from tempfile import gettempdir from uuid import uuid4 from ..conf import settings from ..const import ARGUMENT_PLACEHOLDER, USER_COMMAND_MARK -from ..utils import memoize +from ..utils import DEVNULL, memoize from .generic import Generic @@ -85,3 +86,10 @@ class Zsh(Generic): content=u'eval $(thefuck --alias)', path='~/.zshrc', reload='source ~/.zshrc') + + def info(self): + """Returns the name and version of the current shell""" + proc = Popen(['zsh', '-c', 'echo $ZSH_VERSION'], + stdout=PIPE, stderr=DEVNULL) + version = proc.stdout.read().decode('utf-8').strip() + return u'ZSH {}'.format(version)