Skip to content

add opts.app_path to set Obsidian.app path on MacOS #821

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added `opts.follow_img_func` option for customizing how to handle image paths.
- Added better handling for undefined template fields, which will now be prompted for.
- Added `opts.app_path` to set the path to the Obsidian.app (MacOS only)

### Changed

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ This is a complete list of all of the options that can be passed to `require("ob
-- https://github.com/Vinzent03/obsidian-advanced-uri
use_advanced_uri = false,

-- Optional, set to the path of Obsidian.app (MacOS only)
app_path = "/path/to/Obsidian.app",

-- Optional, set to true to force ':ObsidianOpen' to bring the app to the foreground.
open_app_foreground = false,

Expand Down
4 changes: 2 additions & 2 deletions lua/obsidian/commands/open.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ local function open_in_app(client, path)
elseif this_os == util.OSType.Darwin then
cmd = "open"
if client.opts.open_app_foreground then
args = { "-a", "/Applications/Obsidian.app", uri }
args = { "-a", client.opts.app_path ~= nil and "\"" ..client.opts.app_path.."\"" or "/Applications/Obsidian.app", uri }
else
args = { "-a", "/Applications/Obsidian.app", "--background", uri }
args = { "-a", client.opts.app_path ~= nil and "\""..client.opts.app_path.."\"" or "/Applications/Obsidian.app", "--background", uri }
end
else
log.err("open command does not support OS type '" .. this_os .. "'")
Expand Down
2 changes: 2 additions & 0 deletions lua/obsidian/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ local config = {}
---@field picker obsidian.config.PickerOpts
---@field daily_notes obsidian.config.DailyNotesOpts
---@field use_advanced_uri boolean|?
---@field app_path string|?
---@field open_app_foreground boolean|?
---@field sort_by obsidian.config.SortBy|?
---@field sort_reversed boolean|?
Expand Down Expand Up @@ -57,6 +58,7 @@ config.ClientOpts.default = function()
picker = config.PickerOpts.default(),
daily_notes = config.DailyNotesOpts.default(),
use_advanced_uri = nil,
app_path = nil,
open_app_foreground = false,
sort_by = "modified",
sort_reversed = true,
Expand Down
Loading