Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give unquoted full path string to os.isdir() (resolve #11 and #15) #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
16 changes: 14 additions & 2 deletions zoxide.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ end
-- Define aliases.
--

-- remove double quotes
function unquote(s)
local unquoted = string.match(s, '^"(.*)"$')
if unquoted then
return unquoted
end
return s
end

-- 'z' alias
local function __zoxide_z(keywords)
if #keywords == 0 then
Expand All @@ -106,8 +115,11 @@ local function __zoxide_z(keywords)
local keyword = keywords[1]
if keyword == '-' then
return __zoxide_cd '-'
elseif os.isdir(keyword) then
return __zoxide_cd(keyword)
else
local path = os.getfullpathname(unquote(keyword))
if path and os.isdir(path) then
return __zoxide_cd(path)
end
end
end

Expand Down