mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-20 01:28:56 +00:00
adding in files for the cd-cs feature
This commit is contained in:
parent
0e34c2343e
commit
020a162973
@ -179,6 +179,7 @@ following rules are enabled by default:
|
|||||||
* `cargo_no_command` – fixes wrongs commands like `cargo buid`;
|
* `cargo_no_command` – fixes wrongs commands like `cargo buid`;
|
||||||
* `cat_dir` – replaces `cat` with `ls` when you try to `cat` a directory;
|
* `cat_dir` – replaces `cat` with `ls` when you try to `cat` a directory;
|
||||||
* `cd_correction` – spellchecks and correct failed cd commands;
|
* `cd_correction` – spellchecks and correct failed cd commands;
|
||||||
|
* `cd_cs` – changes `cs` to `cd`;
|
||||||
* `cd_mkdir` – creates directories before cd'ing into them;
|
* `cd_mkdir` – creates directories before cd'ing into them;
|
||||||
* `cd_parent` – changes `cd..` to `cd ..`;
|
* `cd_parent` – changes `cd..` to `cd ..`;
|
||||||
* `chmod_x` – add execution bit;
|
* `chmod_x` – add execution bit;
|
||||||
|
11
tests/rules/test_cd_cs.py
Normal file
11
tests/rules/test_cd_cs.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from thefuck.rules.cd_cs import match, get_new_command
|
||||||
|
from thefuck.types import Command
|
||||||
|
|
||||||
|
|
||||||
|
def test_match():
|
||||||
|
assert match(Command('cs', 'cs: command not found'))
|
||||||
|
assert match(Command('cs /etc/', 'cs: command not found'))
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_new_command():
|
||||||
|
assert get_new_command(Command('cs /etc/', 'cs: command not found')) == 'cd /etc/'
|
16
thefuck/rules/cd_cs.py
Normal file
16
thefuck/rules/cd_cs.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Redirects cs to cd when there is a typo
|
||||||
|
# Due to the proximity of the keys - d and s, I found this to be a common problem for me
|
||||||
|
# > cs /etc/
|
||||||
|
# cs: command not found
|
||||||
|
|
||||||
|
|
||||||
|
def match(command):
|
||||||
|
if command.script_parts[0] == 'cs':
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def get_new_command(command):
|
||||||
|
return 'cd' + ''.join(command.script[2:])
|
||||||
|
|
||||||
|
|
||||||
|
priority = 900
|
Loading…
x
Reference in New Issue
Block a user