[vim ] 如何檢查OS是否有安裝特定軟體或檔案

看板Editor作者 (一步一腳印)時間13年前 (2011/07/08 08:55), 編輯推噓0(006)
留言6則, 1人參與, 最新討論串1/1
if has('unix') "檢查OS有沒有安裝特定軟體, ex: wmctrl, xfce4-terminal " 或某字型檔, ex: Droid Sans Mono endif 請問該怎麼寫比較好?感謝回答~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.31.149

07/08 10:54, , 1F
findfile ?
07/08 10:54, 1F

07/08 11:04, , 2F
filereadable()
07/08 11:04, 2F

07/08 11:12, , 3F
executable()
07/08 11:12, 3F

07/08 13:23, , 4F
if executable("software_name") ...
07/08 13:23, 4F
再補充一個作法: let has_wmctrl=(strlen(system('which wmctrl'))>0) if has_wmctrl " wmctrl is installed endif

07/08 13:41, , 5F
if getfontname("font_name") ...
07/08 13:41, 5F
help中提到: "Only works when the GUI is running, thus ...(略)" 但我只用vim...只好另尋他法

07/09 09:54, , 6F
system("fc-list|grep font_name") ?
07/09 09:54, 6F
fc-list不錯用! ※ 編輯: Holocaust123 來自: 140.112.31.149 (07/09 11:57)
文章代碼(AID): #1E5bLzQE (Editor)