感觉打开 Obsidian 时能选择哪个库还是挺有用的。一些回答提到的用uri的方式也是只能打开特定库,而不是像第一次打开 Obsidian 那样可以选择进入哪个库。
最近按照 官方论坛的这个话题 摸索了一下,可以通过把配置文件中的 "open":true
改成 "open":false
阻止打开上次打开的库,论坛给的方法是powershell,但是总是闪过一个命令行黑框框。后来发现用 VBS 写就没这事;代码如下
file = "C:\Users\YourUserName\AppData\Roaming\obsidian\obsidian.json"
set fso = createobject("scripting.filesystemobject")
' read json
set stream = fso.opentextfile(file,1)
content = stream.readall()
call stream.close()
' replace status string
content = replace(content,"""open"":true","""open"":false")
' save json
set stream = fso.opentextfile(file,2)
call stream.write(content)
call stream.close()
' open obsidian
set shell = CreateObject("WScript.Shell")
shell.Run "powershell ""start obsidian:""",0
新建文本文件,粘贴这些代码,记着把用户文件夹的名字改掉(资源管理器输入%userprofile%打开的就是用户文件夹),然后后缀名改成 .vbs
就能跑了,每次打开都是进入的库选择器。如果觉着不好看就生成一个快捷方式,然后改图标。
更新:如果路径有中文,需要用下面的方式。UTF-8在vbs下是个烦人的东西,还得想办法跳过BOM
file = "C:\Users\YourUserName\AppData\Roaming\obsidian\obsidian.json"
set fso = createobject("scripting.filesystemobject")
' read json
Set stm = CreateObject("Adodb.Stream")
With stm
.Type = 2
.mode = 3
.charset = "utf-8"
.Open
.LoadFromFile file
end With
content = stm.readtext()
stm.close
' save json
Set stm = CreateObject("Adodb.Stream")
With stm
.Type = 2
.mode = 3
.charset = "utf-8"
.Open
.WriteText replace(content,"""open"":true","""open"":false") ' replace status string
.Position = 3
end With
dim newStream:Set newStream = CreateObject("adodb.stream")
With newStream
.Mode = 3
.Type = 1
.Open()
End With
stm.CopyTo(newStream)
newStream.SaveToFile file, 2
stm.flush
stm.close
' open obsidian
set shell = CreateObject("WScript.Shell")
shell.Run "powershell ""start obsidian:""",0