#611: Allow to configure alias automatically by calling fuck twice
This commit is contained in:
@@ -45,8 +45,7 @@ class Bash(Generic):
|
||||
else:
|
||||
config = 'bash config'
|
||||
|
||||
return {
|
||||
'content': 'eval $(thefuck --alias)',
|
||||
'path': config,
|
||||
'reload': u'source {}'.format(config),
|
||||
}
|
||||
return self._create_shell_configuration(
|
||||
content='eval $(thefuck --alias)',
|
||||
path=config,
|
||||
reload=u'source {}'.format(config))
|
||||
|
||||
@@ -67,11 +67,10 @@ class Fish(Generic):
|
||||
return u'; and '.join(commands)
|
||||
|
||||
def how_to_configure(self):
|
||||
return {
|
||||
'content': r"eval (thefuck --alias | tr '\n' ';')",
|
||||
'path': '~/.config/fish/config.fish',
|
||||
'reload': 'fish',
|
||||
}
|
||||
return self._create_shell_configuration(
|
||||
content=r"eval (thefuck --alias | tr '\n' ';')",
|
||||
path='~/.config/fish/config.fish',
|
||||
reload='fish')
|
||||
|
||||
def put_to_history(self, command):
|
||||
try:
|
||||
|
||||
@@ -2,8 +2,14 @@ import io
|
||||
import os
|
||||
import shlex
|
||||
import six
|
||||
from collections import namedtuple
|
||||
from ..utils import memoize
|
||||
from ..conf import settings
|
||||
from ..system import Path
|
||||
|
||||
|
||||
ShellConfiguration = namedtuple('ShellConfiguration', (
|
||||
'content', 'path', 'reload', 'can_configure_automatically'))
|
||||
|
||||
|
||||
class Generic(object):
|
||||
@@ -116,3 +122,10 @@ class Generic(object):
|
||||
'shift', 'shopt', 'source', 'suspend', 'test', 'times', 'trap',
|
||||
'type', 'typeset', 'ulimit', 'umask', 'unalias', 'unset',
|
||||
'until', 'wait', 'while']
|
||||
|
||||
def _create_shell_configuration(self, content, path, reload):
|
||||
return ShellConfiguration(
|
||||
content=content,
|
||||
path=path,
|
||||
reload=reload,
|
||||
can_configure_automatically=Path(path).expanduser().exists())
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from .generic import Generic
|
||||
from .generic import Generic, ShellConfiguration
|
||||
|
||||
|
||||
class Powershell(Generic):
|
||||
@@ -18,8 +18,8 @@ class Powershell(Generic):
|
||||
return u' -and '.join('({0})'.format(c) for c in commands)
|
||||
|
||||
def how_to_configure(self):
|
||||
return {
|
||||
'content': 'iex "thefuck --alias"',
|
||||
'path': '$profile',
|
||||
'reload': '& $profile',
|
||||
}
|
||||
return ShellConfiguration(
|
||||
content='iex "thefuck --alias"',
|
||||
path='$profile',
|
||||
reload='& $profile',
|
||||
can_configure_automatically=False)
|
||||
|
||||
@@ -31,8 +31,7 @@ class Tcsh(Generic):
|
||||
return u'#+{}\n{}\n'.format(int(time()), command_script)
|
||||
|
||||
def how_to_configure(self):
|
||||
return {
|
||||
'content': 'eval `thefuck --alias`',
|
||||
'path': '~/.tcshrc',
|
||||
'reload': 'tcsh',
|
||||
}
|
||||
return self._create_shell_configuration(
|
||||
content='eval `thefuck --alias`',
|
||||
path='~/.tcshrc',
|
||||
reload='tcsh')
|
||||
|
||||
@@ -45,8 +45,7 @@ class Zsh(Generic):
|
||||
return ''
|
||||
|
||||
def how_to_configure(self):
|
||||
return {
|
||||
'content': 'eval $(thefuck --alias)',
|
||||
'path': '~/.zshrc',
|
||||
'reload': 'source ~/.zshrc',
|
||||
}
|
||||
return self._create_shell_configuration(
|
||||
content='eval $(thefuck --alias)',
|
||||
path='~/.zshrc',
|
||||
reload='source ~/.zshrc')
|
||||
|
||||
Reference in New Issue
Block a user