Merge branch 'master' into flake8
This commit is contained in:
@@ -14,7 +14,7 @@ class Bash(Generic):
|
||||
" eval $TF_CMD".format(fuck)
|
||||
|
||||
if settings.alter_history:
|
||||
return alias + " && history -s $TF_CMD'"
|
||||
return alias + "; history -s $TF_CMD'"
|
||||
else:
|
||||
return alias + "'"
|
||||
|
||||
@@ -44,4 +44,9 @@ class Bash(Generic):
|
||||
config = '~/.bashrc'
|
||||
else:
|
||||
config = 'bash config'
|
||||
return 'eval $(thefuck --alias)', config
|
||||
|
||||
return {
|
||||
'content': 'eval $(thefuck --alias)',
|
||||
'path': config,
|
||||
'reload': u'source {}'.format(config),
|
||||
}
|
||||
|
||||
@@ -20,8 +20,9 @@ class Fish(Generic):
|
||||
|
||||
def app_alias(self, fuck):
|
||||
if settings.alter_history:
|
||||
alter_history = (' history --delete $fucked_up_command\n'
|
||||
' history --merge ^ /dev/null\n')
|
||||
alter_history = (' builtin history delete --exact'
|
||||
' --case-sensitive -- $fucked_up_command\n'
|
||||
' builtin history merge ^ /dev/null\n')
|
||||
else:
|
||||
alter_history = ''
|
||||
# It is VERY important to have the variables declared WITHIN the alias
|
||||
@@ -66,8 +67,11 @@ class Fish(Generic):
|
||||
return u'; and '.join(commands)
|
||||
|
||||
def how_to_configure(self):
|
||||
return (r"eval (thefuck --alias | tr '\n' ';')",
|
||||
'~/.config/fish/config.fish')
|
||||
return {
|
||||
'content': r"eval (thefuck --alias | tr '\n' ';')",
|
||||
'path': '~/.config/fish/config.fish',
|
||||
'reload': 'fish',
|
||||
}
|
||||
|
||||
def put_to_history(self, command):
|
||||
try:
|
||||
|
||||
@@ -65,9 +65,19 @@ class Generic(object):
|
||||
|
||||
def split_command(self, command):
|
||||
"""Split the command using shell-like syntax."""
|
||||
encoded = self.encode_utf8(command)
|
||||
splitted = shlex.split(encoded)
|
||||
return self.decode_utf8(splitted)
|
||||
|
||||
def encode_utf8(self, command):
|
||||
if six.PY2:
|
||||
return [s.decode('utf8') for s in shlex.split(command.encode('utf8'))]
|
||||
return shlex.split(command)
|
||||
return command.encode('utf8')
|
||||
return command
|
||||
|
||||
def decode_utf8(self, command_parts):
|
||||
if six.PY2:
|
||||
return [s.decode('utf8') for s in command_parts]
|
||||
return command_parts
|
||||
|
||||
def quote(self, s):
|
||||
"""Return a shell-escaped version of the string s."""
|
||||
|
||||
@@ -3,11 +3,14 @@ from .generic import Generic
|
||||
|
||||
class Powershell(Generic):
|
||||
def app_alias(self, fuck):
|
||||
return 'function ' + fuck + ' { \n' \
|
||||
' $fuck = $(thefuck (Get-History -Count 1).CommandLine);\n' \
|
||||
' if (-not [string]::IsNullOrWhiteSpace($fuck)) {\n' \
|
||||
' if ($fuck.StartsWith("echo")) { $fuck = $fuck.Substring(5); }\n' \
|
||||
' else { iex "$fuck"; }\n' \
|
||||
return 'function ' + fuck + ' {\n' \
|
||||
' $history = (Get-History -Count 1).CommandLine;\n' \
|
||||
' if (-not [string]::IsNullOrWhiteSpace($history)) {\n' \
|
||||
' $fuck = $(thefuck $history);\n' \
|
||||
' if (-not [string]::IsNullOrWhiteSpace($fuck)) {\n' \
|
||||
' if ($fuck.StartsWith("echo")) { $fuck = $fuck.Substring(5); }\n' \
|
||||
' else { iex "$fuck"; }\n' \
|
||||
' }\n' \
|
||||
' }\n' \
|
||||
'}\n'
|
||||
|
||||
@@ -15,4 +18,8 @@ class Powershell(Generic):
|
||||
return u' -and '.join('({0})'.format(c) for c in commands)
|
||||
|
||||
def how_to_configure(self):
|
||||
return 'iex "thefuck --alias"', '$profile'
|
||||
return {
|
||||
'content': 'iex "thefuck --alias"',
|
||||
'path': '$profile',
|
||||
'reload': '& $profile',
|
||||
}
|
||||
|
||||
@@ -31,4 +31,8 @@ class Tcsh(Generic):
|
||||
return u'#+{}\n{}\n'.format(int(time()), command_script)
|
||||
|
||||
def how_to_configure(self):
|
||||
return 'eval `thefuck --alias`', '~/.tcshrc'
|
||||
return {
|
||||
'content': 'eval `thefuck --alias`',
|
||||
'path': '~/.tcshrc',
|
||||
'reload': 'tcsh',
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class Zsh(Generic):
|
||||
" eval $TF_CMD".format(alias_name)
|
||||
|
||||
if settings.alter_history:
|
||||
return alias + " && print -s $TF_CMD'"
|
||||
return alias + " ; test -n \"$TF_CMD\" && print -s $TF_CMD'"
|
||||
else:
|
||||
return alias + "'"
|
||||
|
||||
@@ -45,4 +45,8 @@ class Zsh(Generic):
|
||||
return ''
|
||||
|
||||
def how_to_configure(self):
|
||||
return 'eval $(thefuck --alias)', '~/.zshrc'
|
||||
return {
|
||||
'content': 'eval $(thefuck --alias)',
|
||||
'path': '~/.zshrc',
|
||||
'reload': 'source ~/.zshrc',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user