mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-14 14:48:49 +00:00
#N/A: show shell information on thefuck --version
This commit is contained in:
parent
e7d508a9af
commit
318ae0b55c
7
.github/ISSUE_TEMPLATE.md
vendored
7
.github/ISSUE_TEMPLATE.md
vendored
@ -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
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -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:
|
||||
|
@ -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))
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user