diff --git a/thefuck/const.py b/thefuck/const.py index d272f1b2..8b96e727 100644 --- a/thefuck/const.py +++ b/thefuck/const.py @@ -40,6 +40,7 @@ DEFAULT_SETTINGS = {'rules': DEFAULT_RULES, 'wait_slow_command': 15, 'slow_commands': ['lein', 'react-native', 'gradle', './gradlew', 'vagrant'], + 'wraps_commands': {}, 'repeat': False, 'instant_mode': False, 'num_close_matches': 3, diff --git a/thefuck/rules/git_stash.py b/thefuck/rules/git_stash.py index 5c4effa8..ec3b44bf 100644 --- a/thefuck/rules/git_stash.py +++ b/thefuck/rules/git_stash.py @@ -11,5 +11,5 @@ def match(command): @git_support def get_new_command(command): - formatme = shell.and_('git stash', '{}') + formatme = shell.and_('{} stash'.format(command.script_parts[0]), '{}') return formatme.format(command.script) diff --git a/thefuck/rules/git_stash_pop.py b/thefuck/rules/git_stash_pop.py index 0e143ffd..1ec47c2c 100644 --- a/thefuck/rules/git_stash_pop.py +++ b/thefuck/rules/git_stash_pop.py @@ -11,7 +11,8 @@ def match(command): @git_support def get_new_command(command): - return shell.and_('git add --update', 'git stash pop', 'git reset .') + cmd = command.script_parts[0] + return shell.and_('{} add --update'.format(cmd), '{} stash pop'.format(cmd), '{} reset .'.format(cmd)) # make it come before the other applicable rules diff --git a/thefuck/rules/scm_correction.py b/thefuck/rules/scm_correction.py index 78c44949..c2459357 100644 --- a/thefuck/rules/scm_correction.py +++ b/thefuck/rules/scm_correction.py @@ -19,7 +19,7 @@ def _get_actual_scm(): return scm -@for_app(*wrong_scm_patterns.keys()) +@for_app(*wrong_scm_patterns.keys(), strict=True) def match(command): scm = command.script_parts[0] pattern = wrong_scm_patterns[scm] diff --git a/thefuck/utils.py b/thefuck/utils.py index 8d55f372..90ad411b 100644 --- a/thefuck/utils.py +++ b/thefuck/utils.py @@ -167,15 +167,23 @@ def replace_command(command, broken, matched): @memoize -def is_app(command, *app_names, **kwargs): - """Returns `True` if command is call to one of passed app names.""" +def is_app(command, *app_names, strict=False, **kwargs): + """Returns `True` if command is call to one of passed app names. If `strict=True`, skip checking for wrapped commands.""" at_least = kwargs.pop('at_least', 0) if kwargs: raise TypeError("got an unexpected keyword argument '{}'".format(kwargs.keys())) if len(command.script_parts) > at_least: - return command.script_parts[0] in app_names + cmd = command.script_parts[0] + if cmd in app_names: + return True + if not strict: + # allow command to be wrapped as another command + wrapped_cmd = [settings['wraps_commands'].get(a, []) for a in app_names] + for wrapped in wrapped_cmd: + if cmd in wrapped: + return True return False