Skip to content

Commit

Permalink
Merge pull request #7617 from garborg/tilde
Browse files Browse the repository at this point in the history
Tilde expansion in REPL shell completion
  • Loading branch information
StefanKarpinski committed Mar 27, 2015
2 parents 2af6a9a + b302459 commit b046860
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion base/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ function complete_keyword(s::ByteString)
end

function complete_path(path::AbstractString, pos)
if ismatch(r"^~(?:/|$)", path)
path = homedir() * path[2:end]
end
dir, prefix = splitdir(path)
local files
try
Expand Down Expand Up @@ -354,7 +357,7 @@ function shell_completions(string, pos)
isempty(args.args[end].args) && return UTF8String[], 0:-1, false
arg = args.args[end].args[end]
if all(map(s -> isa(s, AbstractString), args.args[end].args))
# Treat this as a path (perhaps give a list of comands in the future as well?)
# Treat this as a path (perhaps give a list of commands in the future as well?)
return complete_path(join(args.args[end].args), pos)
elseif isexpr(arg, :escape) && (isexpr(arg.args[1], :incomplete) || isexpr(arg.args[1], :error))
r = first(last_parse):prevind(last_parse, last(last_parse))
Expand Down

0 comments on commit b046860

Please sign in to comment.