mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Merge pull request #1036 from jasonLaster/add-cd-home
Update ShellCommand so that `.cd` autocompletes to `.cd ~`
This commit is contained in:
commit
dacafb80a8
2 changed files with 9 additions and 1 deletions
|
@ -16,7 +16,7 @@ class Pry
|
|||
BANNER
|
||||
|
||||
def process(cmd)
|
||||
if cmd =~ /^cd\s+(.+)/i
|
||||
if cmd =~ /^cd\s*(.*)/i
|
||||
process_cd parse_destination($1)
|
||||
else
|
||||
pass_block(cmd)
|
||||
|
@ -36,6 +36,7 @@ class Pry
|
|||
private
|
||||
|
||||
def parse_destination(dest)
|
||||
return "~" if dest.empty?
|
||||
return dest unless dest == "-"
|
||||
state.old_pwd || raise(CommandError, "No prior directory available")
|
||||
end
|
||||
|
|
|
@ -31,6 +31,13 @@ describe "Command::ShellCommand" do
|
|||
end
|
||||
end
|
||||
|
||||
describe "given an empty string" do
|
||||
it "sends ~ to File.expand_path" do
|
||||
Dir.expects(:chdir).with(File.expand_path("~"))
|
||||
@t.eval ".cd "
|
||||
end
|
||||
end
|
||||
|
||||
describe "given a dash" do
|
||||
describe "given no prior directory" do
|
||||
it "raises the correct error" do
|
||||
|
|
Loading…
Reference in a new issue