Merge branch 'master' of github.com:nvbn/thefuck into pacman
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from thefuck import shells
|
||||
|
||||
try:
|
||||
import CommandNotFound
|
||||
except ImportError:
|
||||
@@ -20,4 +22,5 @@ def get_new_command(command, settings):
|
||||
c = CommandNotFound.CommandNotFound()
|
||||
pkgs = c.getPackages(command.script.split(" ")[0])
|
||||
name, _ = pkgs[0]
|
||||
return "sudo apt-get install {} && {}".format(name, command.script)
|
||||
formatme = shells.and_('sudo apt-get install {}', '{}')
|
||||
return formatme.format(name, command.script)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import re
|
||||
from thefuck import shells
|
||||
from thefuck.utils import sudo_support
|
||||
|
||||
|
||||
@@ -11,4 +12,5 @@ def match(command, settings):
|
||||
|
||||
@sudo_support
|
||||
def get_new_command(command, settings):
|
||||
return re.sub(r'^cd (.*)', 'mkdir -p \\1 && cd \\1', command.script)
|
||||
repl = shells.and_('mkdir -p \\1', 'cd \\1')
|
||||
return re.sub(r'^cd (.*)', repl, command.script)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import re
|
||||
from thefuck import shells
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
@@ -12,4 +13,5 @@ def get_new_command(command, settings):
|
||||
r"error: pathspec '([^']*)' "
|
||||
"did not match any file\(s\) known to git.", command.stderr)[0]
|
||||
|
||||
return 'git add -- {} && {}'.format(missing_file, command.script)
|
||||
formatme = shells.and_('git add -- {}', '{}')
|
||||
return formatme.format(missing_file, command.script)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import re
|
||||
from thefuck import shells
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
@@ -12,4 +13,5 @@ def get_new_command(command, settings):
|
||||
r"error: pathspec '([^']*)' "
|
||||
"did not match any file\(s\) known to git.", command.stderr)[0]
|
||||
|
||||
return 'git branch {} && {}'.format(missing_file, command.script)
|
||||
formatme = shells.and_('git branch {}', '{}')
|
||||
return formatme.format(missing_file, command.script)
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from thefuck import shells
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
# catches "Please commit or stash them" and "Please, commit your changes or
|
||||
# stash them before you can switch branches."
|
||||
@@ -5,4 +8,5 @@ def match(command, settings):
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return 'git stash && ' + command.script
|
||||
formatme = shells.and_('git stash', '{}')
|
||||
return formatme.format(command.script)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import re
|
||||
from thefuck import shells
|
||||
|
||||
|
||||
patterns = (
|
||||
@@ -25,4 +26,5 @@ def get_new_command(command, settings):
|
||||
file = file[0]
|
||||
dir = file[0:file.rfind('/')]
|
||||
|
||||
return 'mkdir -p {} && {}'.format(dir, command.script)
|
||||
formatme = shells.and_('mkdir -p {}', '{}')
|
||||
return formatme.format(dir, command.script)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import subprocess
|
||||
from thefuck.utils import DEVNULL, which
|
||||
from thefuck import shells
|
||||
|
||||
|
||||
def __get_pkgfile(command):
|
||||
@@ -19,7 +20,8 @@ def match(command, settings):
|
||||
def get_new_command(command, settings):
|
||||
package = __get_pkgfile(command)[0]
|
||||
|
||||
return '{} -S {} && {}'.format(pacman, package, command.script)
|
||||
formatme = shells.and_('{} -S {}', '{}')
|
||||
return formatme.format(pacman, package, command.script)
|
||||
|
||||
|
||||
if not which('pkgfile'):
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from urllib.parse import urlparse
|
||||
# -*- encoding: utf-8 -*-
|
||||
from six.moves.urllib.parse import urlparse
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
|
||||
@@ -47,8 +47,14 @@ class Generic(object):
|
||||
with open(history_file_name, 'a') as history:
|
||||
history.write(self._get_history_line(command_script))
|
||||
|
||||
def and_(self, *commands):
|
||||
return ' && '.join(commands)
|
||||
|
||||
|
||||
class Bash(Generic):
|
||||
def app_alias(self):
|
||||
return "\nalias fuck='eval $(thefuck $(fc -ln -1)); history -r'\n"
|
||||
|
||||
def _parse_alias(self, alias):
|
||||
name, value = alias.replace('alias ', '', 1).split('=', 1)
|
||||
if value[0] == value[-1] == '"' or value[0] == value[-1] == "'":
|
||||
@@ -71,6 +77,9 @@ class Bash(Generic):
|
||||
|
||||
|
||||
class Zsh(Generic):
|
||||
def app_alias(self):
|
||||
return "\nalias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R'\n"
|
||||
|
||||
def _parse_alias(self, alias):
|
||||
name, value = alias.split('=', 1)
|
||||
if value[0] == value[-1] == '"' or value[0] == value[-1] == "'":
|
||||
@@ -144,3 +153,7 @@ def app_alias():
|
||||
|
||||
def put_to_history(command):
|
||||
return _get_shell().put_to_history(command)
|
||||
|
||||
|
||||
def and_(*commands):
|
||||
return _get_shell().and_(*commands)
|
||||
|
||||
Reference in New Issue
Block a user