1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-11-01 15:42:06 +00:00

Compare commits

...

12 Commits

Author SHA1 Message Date
nvbn
0fcc35c227 #380 merge cd_mkdir and cd_correction rules 2015-10-12 17:52:44 +08:00
nvbn
3da26192cb Bump to 3.1 2015-10-08 10:30:38 +08:00
Vladimir Iakovlev
11c133523a Merge pull request #375 from jab/patch-1
rm -f $eval_script
2015-10-03 10:24:39 +08:00
Vladimir Iakovlev
4b3e6a1448 Merge pull request #374 from mcarton/python3.5
Test on python 3.5
2015-10-03 10:23:41 +08:00
jab
09d9f63c98 use /bin/rm rather than rm -f 2015-10-02 10:12:50 -04:00
jab
e8883429c6 rm -f $eval_script
Without this change, users who have "rm" aliased to "rm -i"
have to confirm removal of the file after running fuck. This
change allows such users to run fuck without having to do
the superfluous rm confirmation.
2015-10-02 10:09:19 -04:00
nvbn
c1b67f2514 Show python version in --version 2015-09-28 16:47:54 +08:00
mcarton
3d6e7b17db Test on python 3.5 2015-09-15 02:17:56 +02:00
Vladimir Iakovlev
75ef866214 Merge pull request #373 from grammaright/master
Add j, k key for arrow action at read_actions
2015-09-13 12:38:55 +03:00
grammaright
5021d16cea Add j, k key for arrow action at read_actions 2015-09-13 01:27:21 +09:00
Vladimir Iakovlev
af259846b4 Merge pull request #370 from nvbn/369-git-fix-stash-fails
#369 Fix `git_fix_stash` fails when script is just `git`
2015-09-10 15:11:34 +03:00
nvbn
213791d3c2 #369 Fix git_fix_stash fails when script is just git 2015-09-10 14:28:22 +03:00
11 changed files with 29 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
language: python
sudo: false
python:
- "3.5"
- "3.4"
- "3.3"
- "2.7"

View File

@@ -141,8 +141,8 @@ using the matched rule and runs it. Rules enabled by default are as follows:
* `cargo` – runs `cargo build` instead of `cargo`;
* `cargo_no_command` – fixes wrongs commands like `cargo buid`;
* `cd_correction` – spellchecks and correct failed cd commands;
* `cd_mkdir` – creates directories before cd'ing into them;
* `cd_correction` – spellchecks and correct failed cd commands, when it's not possible
creates directories before cd'ing into them;
* `cd_parent` – changes `cd..` to `cd ..`;
* `composer_not_command` – fixes composer command name;
* `cp_omitting_directory` – adds `-a` when you `cp` directory;

View File

@@ -20,7 +20,7 @@ elif (3, 0) < version < (3, 3):
' ({}.{} detected).'.format(*version))
sys.exit(-1)
VERSION = '3.0'
VERSION = '3.1'
install_requires = ['psutil', 'colorama', 'six', 'decorator']
extras_require = {':python_version<"3.4"': ['pathlib']}

View File

@@ -1,5 +1,5 @@
import pytest
from thefuck.rules.cd_mkdir import match, get_new_command
from thefuck.rules.cd_correction import match, get_new_command
from tests.utils import Command

View File

@@ -23,6 +23,10 @@ def test_match(wrong):
assert match(Command(wrong, stderr=git_stash_err))
def test_not_match():
assert not match(Command("git", stderr=git_stash_err))
@pytest.mark.parametrize('wrong,fixed', [
('git stash opp', 'git stash pop'),
('git stash Some message', 'git stash save Some message'),

View File

@@ -59,9 +59,11 @@ def how_to_configure_alias():
def main():
parser = ArgumentParser(prog='thefuck')
version = get_installation_info().version
parser.add_argument('-v', '--version',
action='version',
version='%(prog)s {}'.format(version))
parser.add_argument(
'-v', '--version',
action='version',
version='The Fuck {} using Python {}'.format(
version, sys.version.split()[0]))
parser.add_argument('-a', '--alias',
action='store_true',
help='[custom-alias-name] prints alias for current shell')

View File

@@ -2,9 +2,10 @@
import os
from difflib import get_close_matches
import re
from thefuck.specific.sudo import sudo_support
from thefuck.rules import cd_mkdir
from thefuck.utils import for_app
from thefuck import shells
__author__ = "mmussomele"
@@ -43,11 +44,13 @@ def get_new_command(command):
elif directory == "..":
cwd = os.path.split(cwd)[0]
continue
best_matches = get_close_matches(directory, _get_sub_dirs(cwd), cutoff=MAX_ALLOWED_DIFF)
best_matches = get_close_matches(
directory, _get_sub_dirs(cwd), cutoff=MAX_ALLOWED_DIFF)
if best_matches:
cwd = os.path.join(cwd, best_matches[0])
else:
return cd_mkdir.get_new_command(command)
repl = shells.and_('mkdir -p \\1', 'cd \\1')
return re.sub(r'^cd (.*)', repl, command.script)
return 'cd "{0}"'.format(cwd)

View File

@@ -1,17 +0,0 @@
import re
from thefuck import shells
from thefuck.utils import for_app
from thefuck.specific.sudo import sudo_support
@sudo_support
@for_app('cd')
def match(command):
return (('no such file or directory' in command.stderr.lower()
or 'cd: can\'t cd to' in command.stderr.lower()))
@sudo_support
def get_new_command(command):
repl = shells.and_('mkdir -p \\1', 'cd \\1')
return re.sub(r'^cd (.*)', repl, command.script)

View File

@@ -5,8 +5,12 @@ from thefuck.specific.git import git_support
@git_support
def match(command):
return (command.script.split()[1] == 'stash'
and 'usage:' in command.stderr)
splited_script = command.script.split()
if len(splited_script) > 1:
return (splited_script[1] == 'stash'
and 'usage:' in command.stderr)
else:
return False
# git's output here is too complicated to be parsed (see the test file)
stash_commands = (

View File

@@ -134,7 +134,7 @@ class Fish(Generic):
" set -l fucked_up_command $history[1]\n"
" thefuck $fucked_up_command > $eval_script\n"
" . $eval_script\n"
" rm $eval_script\n"
" /bin/rm $eval_script\n"
" if test $exit_code -ne 0\n"
" history --delete $fucked_up_command\n"
" end\n"

View File

@@ -44,9 +44,9 @@ def read_actions():
buffer.append(ch)
buffer = buffer[-3:]
if buffer == ['\x1b', '[', 'A']: # ↑
if buffer == ['\x1b', '[', 'A'] or ch == 'k': # ↑
yield PREVIOUS
elif buffer == ['\x1b', '[', 'B']: # ↓
elif buffer == ['\x1b', '[', 'B'] or ch == 'j': # ↓
yield NEXT