How to use the thefuck.shells.shell.and_ function in thefuck

To help you get started, we’ve selected a few thefuck examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nvbn / thefuck / tests / rules / test_git_branch_list.py View on Github external
def test_get_new_command():
    assert (get_new_command(Command('git branch list', '')) ==
            shell.and_('git branch --delete list', 'git branch'))
github nvbn / thefuck / thefuck / rules / open.py View on Github external
def get_new_command(command):
    output = command.output.strip()
    if is_arg_url(command):
        yield command.script.replace('open ', 'open http://')
    elif output.startswith('The file ') and output.endswith(' does not exist.'):
        arg = command.script.split(' ', 1)[1]
        for option in ['touch', 'mkdir']:
            yield shell.and_(u'{} {}'.format(option, arg), command.script)
github nvbn / thefuck / thefuck / rules / git_pull.py View on Github external
def get_new_command(command):
    line = command.output.split('\n')[-3].strip()
    branch = line.split(' ')[-1]
    set_upstream = line.replace('', 'origin')\
                       .replace('', branch)
    return shell.and_(set_upstream, command.script)
github nvbn / thefuck / thefuck / rules / dirty_untar.py View on Github external
def get_new_command(command):
    dir = shell.quote(_tar_file(command.script_parts)[1])
    return shell.and_('mkdir -p {dir}', '{cmd} -C {dir}') \
        .format(dir=dir, cmd=command.script)
github nvbn / thefuck / thefuck / rules / git_pull_uncommitted_changes.py View on Github external
def get_new_command(command):
    return shell.and_('git stash', 'git pull', 'git stash pop')
github nvbn / thefuck / thefuck / rules / chmod_x.py View on Github external
def get_new_command(command):
    return shell.and_(
        'chmod +x {}'.format(command.script_parts[0][2:]),
        command.script)
github nvbn / thefuck / thefuck / rules / touch.py View on Github external
def get_new_command(command):
    path = re.findall(
        r"touch: (?:cannot touch ')?(.+)/.+'?:", command.output)[0]
    return shell.and_(u'mkdir -p {}'.format(path), command.script)
github nvbn / thefuck / thefuck / rules / vagrant_up.py View on Github external
def get_new_command(command):
    cmds = command.script_parts
    machine = None
    if len(cmds) >= 3:
        machine = cmds[2]

    start_all_instances = shell.and_(u"vagrant up", command.script)
    if machine is None:
        return start_all_instances
    else:
        return [shell.and_(u"vagrant up {}".format(machine), command.script),
                start_all_instances]