mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-14 06:38:32 +00:00
#611: Fix python 2 support
This commit is contained in:
parent
2315929875
commit
408cb5fa09
@ -5,6 +5,7 @@ init_output()
|
|||||||
|
|
||||||
import os # noqa: E402
|
import os # noqa: E402
|
||||||
from psutil import Process # noqa: E402
|
from psutil import Process # noqa: E402
|
||||||
|
import six # noqa: E402
|
||||||
from . import logs # noqa: E402
|
from . import logs # noqa: E402
|
||||||
from .shells import shell # noqa: E402
|
from .shells import shell # noqa: E402
|
||||||
from .conf import settings # noqa: E402
|
from .conf import settings # noqa: E402
|
||||||
@ -30,7 +31,7 @@ def _get_not_configured_usage_tracker_path():
|
|||||||
def _record_first_run():
|
def _record_first_run():
|
||||||
"""Records shell pid to tracker file."""
|
"""Records shell pid to tracker file."""
|
||||||
with _get_not_configured_usage_tracker_path().open('w') as tracker:
|
with _get_not_configured_usage_tracker_path().open('w') as tracker:
|
||||||
tracker.write(str(_get_shell_pid()))
|
tracker.write(six.text_type(_get_shell_pid()))
|
||||||
|
|
||||||
|
|
||||||
def _is_second_run():
|
def _is_second_run():
|
||||||
@ -41,7 +42,7 @@ def _is_second_run():
|
|||||||
|
|
||||||
current_pid = _get_shell_pid()
|
current_pid = _get_shell_pid()
|
||||||
with tracker_path.open('r') as tracker:
|
with tracker_path.open('r') as tracker:
|
||||||
return tracker.read() == str(current_pid)
|
return tracker.read() == six.text_type(current_pid)
|
||||||
|
|
||||||
|
|
||||||
def _is_already_configured(configuration_details):
|
def _is_already_configured(configuration_details):
|
||||||
@ -55,9 +56,9 @@ def _configure(configuration_details):
|
|||||||
"""Adds alias to shell config."""
|
"""Adds alias to shell config."""
|
||||||
path = Path(configuration_details.path).expanduser()
|
path = Path(configuration_details.path).expanduser()
|
||||||
with path.open('a') as shell_config:
|
with path.open('a') as shell_config:
|
||||||
shell_config.write('\n')
|
shell_config.write(u'\n')
|
||||||
shell_config.write(configuration_details.content)
|
shell_config.write(configuration_details.content)
|
||||||
shell_config.write('\n')
|
shell_config.write(u'\n')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -46,6 +46,6 @@ class Bash(Generic):
|
|||||||
config = 'bash config'
|
config = 'bash config'
|
||||||
|
|
||||||
return self._create_shell_configuration(
|
return self._create_shell_configuration(
|
||||||
content='eval $(thefuck --alias)',
|
content=u'eval $(thefuck --alias)',
|
||||||
path=config,
|
path=config,
|
||||||
reload=u'source {}'.format(config))
|
reload=u'source {}'.format(config))
|
||||||
|
@ -68,7 +68,7 @@ class Fish(Generic):
|
|||||||
|
|
||||||
def how_to_configure(self):
|
def how_to_configure(self):
|
||||||
return self._create_shell_configuration(
|
return self._create_shell_configuration(
|
||||||
content=r"eval (thefuck --alias | tr '\n' ';')",
|
content=u"eval (thefuck --alias | tr '\n' ';')",
|
||||||
path='~/.config/fish/config.fish',
|
path='~/.config/fish/config.fish',
|
||||||
reload='fish')
|
reload='fish')
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class Powershell(Generic):
|
|||||||
|
|
||||||
def how_to_configure(self):
|
def how_to_configure(self):
|
||||||
return ShellConfiguration(
|
return ShellConfiguration(
|
||||||
content='iex "thefuck --alias"',
|
content=u'iex "thefuck --alias"',
|
||||||
path='$profile',
|
path='$profile',
|
||||||
reload='& $profile',
|
reload='& $profile',
|
||||||
can_configure_automatically=False)
|
can_configure_automatically=False)
|
||||||
|
@ -32,6 +32,6 @@ class Tcsh(Generic):
|
|||||||
|
|
||||||
def how_to_configure(self):
|
def how_to_configure(self):
|
||||||
return self._create_shell_configuration(
|
return self._create_shell_configuration(
|
||||||
content='eval `thefuck --alias`',
|
content=u'eval `thefuck --alias`',
|
||||||
path='~/.tcshrc',
|
path='~/.tcshrc',
|
||||||
reload='tcsh')
|
reload='tcsh')
|
||||||
|
@ -46,6 +46,6 @@ class Zsh(Generic):
|
|||||||
|
|
||||||
def how_to_configure(self):
|
def how_to_configure(self):
|
||||||
return self._create_shell_configuration(
|
return self._create_shell_configuration(
|
||||||
content='eval $(thefuck --alias)',
|
content=u'eval $(thefuck --alias)',
|
||||||
path='~/.zshrc',
|
path='~/.zshrc',
|
||||||
reload='source ~/.zshrc')
|
reload='source ~/.zshrc')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user