Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ following rules are enabled by default:
* `cargo_no_command` – fixes wrongs commands like `cargo buid`;
* `cat_dir` – replaces `cat` with `ls` when you try to `cat` a directory;
* `cd_correction` – spellchecks and correct failed cd commands;
* `cd_cs` – changes `cs` to `cd`;
* `cd_mkdir` – creates directories before cd'ing into them;
* `cd_parent` – changes `cd..` to `cd ..`;
* `chmod_x` – add execution bit;
Expand Down
11 changes: 11 additions & 0 deletions tests/rules/test_cd_cs.py
Original file line number Diff line number Diff line change
@@ -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/'
19 changes: 19 additions & 0 deletions thefuck/rules/cd_cs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Redirects cs to cd when there is a typo
# Due to the proximity of the keys - d and s - this seems like a common typo
# ~ > cs /etc/
# cs: command not found
# ~ > fuck
# cd /etc/ [enter/↑/↓/ctrl+c]
# /etc >


def match(command):
if command.script_parts[0] == 'cs':
return True


def get_new_command(command):
return 'cd' + ''.join(command.script[2:])


priority = 900