@@ -1,14 +1,14 @@
|
||||
# Appends --all to the brew upgrade command
|
||||
#
|
||||
#
|
||||
# Example:
|
||||
# > brew upgrade
|
||||
# Warning: brew upgrade with no arguments will change behaviour soon!
|
||||
# It currently upgrades all formula but this will soon change to require '--all'.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
return (command.script == 'brew upgrade')
|
||||
return command.script == 'brew upgrade'
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return command.script + ' --all'
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
__author__ = "mmussomele"
|
||||
|
||||
"""Attempts to spellcheck and correct failed cd commands"""
|
||||
|
||||
import os
|
||||
@@ -8,6 +5,8 @@ from difflib import get_close_matches
|
||||
from thefuck.utils import sudo_support
|
||||
from thefuck.rules import cd_mkdir
|
||||
|
||||
__author__ = "mmussomele"
|
||||
|
||||
MAX_ALLOWED_DIFF = 0.6
|
||||
|
||||
|
||||
@@ -28,8 +27,8 @@ def match(command, settings):
|
||||
def get_new_command(command, settings):
|
||||
"""
|
||||
Attempt to rebuild the path string by spellchecking the directories.
|
||||
If it fails (i.e. no directories are a close enough match), then it
|
||||
defaults to the rules of cd_mkdir.
|
||||
If it fails (i.e. no directories are a close enough match), then it
|
||||
defaults to the rules of cd_mkdir.
|
||||
Change sensitivity by changing MAX_ALLOWED_DIFF. Default value is 0.6
|
||||
"""
|
||||
dest = command.script.split()[1].split(os.sep)
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
# > cd..
|
||||
# cd..: command not found
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
return command.script == 'cd..'
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return 'cd ..'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from itertools import dropwhile, takewhile, islice
|
||||
import re
|
||||
import subprocess
|
||||
from thefuck.utils import get_closest, sudo_support, replace_argument, replace_command
|
||||
from thefuck.utils import sudo_support, replace_command
|
||||
|
||||
|
||||
@sudo_support
|
||||
|
||||
+22
-12
@@ -1,9 +1,10 @@
|
||||
import re
|
||||
import os
|
||||
from thefuck.utils import memoize
|
||||
from thefuck.utils import memoize, wrap_settings
|
||||
from thefuck import shells
|
||||
|
||||
|
||||
# order is important: only the first match is considered
|
||||
patterns = (
|
||||
# js, node:
|
||||
'^ at {file}:{line}:{col}',
|
||||
@@ -20,13 +21,13 @@ patterns = (
|
||||
# lua:
|
||||
'^lua: {file}:{line}:',
|
||||
# fish:
|
||||
'^{file} \(line {line}\):',
|
||||
'^{file} \\(line {line}\\):',
|
||||
# bash, sh, ssh:
|
||||
'^{file}: line {line}: ',
|
||||
# cargo, clang, gcc, go, pep8, rustc:
|
||||
'^{file}:{line}:{col}',
|
||||
# ghc, make, ruby, zsh:
|
||||
'^{file}:{line}:',
|
||||
# cargo, clang, gcc, go, rustc:
|
||||
'^{file}:{line}:{col}',
|
||||
# perl:
|
||||
'at {file} line {line}',
|
||||
)
|
||||
@@ -45,7 +46,7 @@ patterns = [_make_pattern(p) for p in patterns]
|
||||
def _search(stderr):
|
||||
for pattern in patterns:
|
||||
m = re.search(pattern, stderr)
|
||||
if m:
|
||||
if m and os.path.isfile(m.group('file')):
|
||||
return m
|
||||
|
||||
|
||||
@@ -53,15 +54,24 @@ def match(command, settings):
|
||||
if 'EDITOR' not in os.environ:
|
||||
return False
|
||||
|
||||
m = _search(command.stderr)
|
||||
|
||||
return m and os.path.isfile(m.group('file'))
|
||||
return _search(command.stderr) or _search(command.stdout)
|
||||
|
||||
|
||||
@wrap_settings({'fixlinecmd': '{editor} {file} +{line}',
|
||||
'fixcolcmd': None})
|
||||
def get_new_command(command, settings):
|
||||
m = _search(command.stderr)
|
||||
m = _search(command.stderr) or _search(command.stdout)
|
||||
|
||||
# Note: there does not seem to be a standard for columns, so they are just
|
||||
# ignored for now
|
||||
return shells.and_('{} {} +{}'.format(os.environ['EDITOR'], m.group('file'), m.group('line')),
|
||||
command.script)
|
||||
# ignored by default
|
||||
if settings.fixcolcmd and 'col' in m.groupdict():
|
||||
editor_call = settings.fixcolcmd.format(editor=os.environ['EDITOR'],
|
||||
file=m.group('file'),
|
||||
line=m.group('line'),
|
||||
col=m.group('col'))
|
||||
else:
|
||||
editor_call = settings.fixlinecmd.format(editor=os.environ['EDITOR'],
|
||||
file=m.group('file'),
|
||||
line=m.group('line'))
|
||||
|
||||
return shells.and_(editor_call, command.script)
|
||||
|
||||
@@ -12,7 +12,7 @@ def match(command, settings):
|
||||
def get_new_command(command, settings):
|
||||
missing_file = re.findall(
|
||||
r"error: pathspec '([^']*)' "
|
||||
"did not match any file\(s\) known to git.", command.stderr)[0]
|
||||
r"did not match any file\(s\) known to git.", command.stderr)[0]
|
||||
|
||||
formatme = shells.and_('git add -- {}', '{}')
|
||||
return formatme.format(missing_file, command.script)
|
||||
|
||||
@@ -27,7 +27,7 @@ def get_branches():
|
||||
def get_new_command(command, settings):
|
||||
missing_file = re.findall(
|
||||
r"error: pathspec '([^']*)' "
|
||||
"did not match any file\(s\) known to git.", command.stderr)[0]
|
||||
r"did not match any file\(s\) known to git.", command.stderr)[0]
|
||||
closest_branch = utils.get_closest(missing_file, get_branches(),
|
||||
fallback_to_first=False)
|
||||
if closest_branch:
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# Appends .go when compiling go files
|
||||
#
|
||||
#
|
||||
# Example:
|
||||
# > go run foo
|
||||
# error: go run: no go files listed
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
return (command.script.startswith ('go run ')
|
||||
return (command.script.startswith('go run ')
|
||||
and not command.script.endswith('.go'))
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return command.script + '.go'
|
||||
|
||||
@@ -11,4 +11,3 @@ def match(command, settings):
|
||||
@sudo_support
|
||||
def get_new_command(command, settings):
|
||||
return u'./{}'.format(command.script)
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ def _history_of_exists_without_current(command):
|
||||
if not line.startswith(tf_alias) and not line == command.script
|
||||
and line.split(' ')[0] in executables]
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
return len(get_close_matches(command.script,
|
||||
_history_of_exists_without_current(command)))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# > javac foo
|
||||
# error: Class names, 'foo', are only accepted if annotation
|
||||
# processing is explicitly requested
|
||||
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
return (command.script.startswith('javac ')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
def match(command, settings):
|
||||
return (command.script == 'ls'
|
||||
or command.script.startswith('ls ')
|
||||
and not ('ls -' in command.script))
|
||||
and 'ls -' not in command.script)
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
|
||||
@@ -23,4 +23,4 @@ def match(command, settings):
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return 'open http://' + command.script[5:]
|
||||
return command.script.replace('open ', 'open http://')
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
# Fixes careless " and ' usage
|
||||
#
|
||||
#
|
||||
# Example:
|
||||
# > git commit -m 'My Message"
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
return ('\'' in command.script
|
||||
and '\"' in command.script)
|
||||
return '\'' in command.script and '\"' in command.script
|
||||
|
||||
|
||||
def get_new_command(command, settings):
|
||||
return command.script.replace ('\'', '\"')
|
||||
return command.script.replace('\'', '\"')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from thefuck.utils import get_closest, replace_command
|
||||
from thefuck.utils import replace_command
|
||||
import re
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import re
|
||||
from thefuck.utils import (get_closest, replace_argument,
|
||||
get_all_matched_commands, replace_command)
|
||||
from thefuck.utils import get_all_matched_commands, replace_command
|
||||
|
||||
|
||||
def match(command, settings):
|
||||
@@ -14,4 +13,3 @@ def get_new_command(command, settings):
|
||||
command.stderr)[0]
|
||||
return replace_command(command, broken_cmd,
|
||||
get_all_matched_commands(command.stderr))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user