From 4ae8de8bddfa10612347335615d2b6dfe5f4cec2 Mon Sep 17 00:00:00 2001 From: Anand Sudhir Prayaga Date: Tue, 24 Jul 2018 12:59:21 +0200 Subject: [PATCH] Make openFileUtil configurable Let user configure the command/utility to use to open a file or URL from within a WTF widget --- _site/content/posts/configuration/attributes.md | 4 ++++ docs/index.xml | 2 +- docs/posts/configuration/attributes/index.html | 4 ++++ docs/posts/index.xml | 2 +- wtf/utils.go | 3 ++- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/_site/content/posts/configuration/attributes.md b/_site/content/posts/configuration/attributes.md index 2850875e..1f4a8a96 100644 --- a/_site/content/posts/configuration/attributes.md +++ b/_site/content/posts/configuration/attributes.md @@ -24,6 +24,7 @@ wtf: # that support ten line of text, one of three lines, and one of four rows: [10, 10, 10, 10, 10, 3, 4] # The app redraws itself once a second + openFileUtil: open refreshInterval: 1 term: "xterm-256color" ``` @@ -65,6 +66,9 @@ An array that defines the heights of all the rows.
Values: See tview's Grid for details. +`openFileUtil`
+Command to use to open a file or URL + `refreshInterval`
How often, in seconds, the UI refreshes itself.
**Note:** This implementation is probably wrong and buggy and likely to diff --git a/docs/index.xml b/docs/index.xml index ded9f42a..d8030ada 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -299,7 +299,7 @@ cmd The terminal command to be run, withouth the arguments. Ie: ping, whoami, cu https://wtfutil.com/posts/configuration/attributes/ The following top-level attributes are configurable in config.yml. See this example config file for more details. -wtf:colors:background:"red"border:Focusable:"darkslateblue"focused:"orange"normal:"gray"grid:# How _wide_ the columns are, in terminal characters. In this case we have# six columns, each of which are 35 characters widecolumns:[35,35,35,35,35,35]# How _high_ the rows are, in terminal lines. In this case we have five rows# that support ten line of text, one of three lines, and one of fourrows:[10,10,10,10,10,3,4]# The app redraws itself once a secondrefreshInterval:1term:"xterm-256color" Attributes colors. +wtf:colors:background:"red"border:Focusable:"darkslateblue"focused:"orange"normal:"gray"grid:# How _wide_ the columns are, in terminal characters. In this case we have# six columns, each of which are 35 characters widecolumns:[35,35,35,35,35,35]# How _high_ the rows are, in terminal lines. In this case we have five rows# that support ten line of text, one of three lines, and one of fourrows:[10,10,10,10,10,3,4]# The app redraws itself once a secondopenFileUtil:openrefreshInterval:1term:"xterm-256color" Attributes colors. diff --git a/docs/posts/configuration/attributes/index.html b/docs/posts/configuration/attributes/index.html index 126d33cb..c8dfe1c4 100644 --- a/docs/posts/configuration/attributes/index.html +++ b/docs/posts/configuration/attributes/index.html @@ -154,6 +154,7 @@ See this # that support ten line of text, one of three lines, and one of four rows: [10, 10, 10, 10, 10, 3, 4] # The app redraws itself once a second + openFileUtil: open refreshInterval: 1 term: "xterm-256color"

Attributes

@@ -193,6 +194,9 @@ An array that defines the heights of all the rows.
Values: See
tview’s Grid for details.

+

openFileUtil
+Command to use to open a file or URL

+

refreshInterval
How often, in seconds, the UI refreshes itself.
Note: This implementation is probably wrong and buggy and likely to diff --git a/docs/posts/index.xml b/docs/posts/index.xml index ef7fb26f..971ef72b 100644 --- a/docs/posts/index.xml +++ b/docs/posts/index.xml @@ -299,7 +299,7 @@ cmd The terminal command to be run, withouth the arguments. Ie: ping, whoami, cu https://wtfutil.com/posts/configuration/attributes/ The following top-level attributes are configurable in config.yml. See this example config file for more details. -wtf:colors:background:"red"border:Focusable:"darkslateblue"focused:"orange"normal:"gray"grid:# How _wide_ the columns are, in terminal characters. In this case we have# six columns, each of which are 35 characters widecolumns:[35,35,35,35,35,35]# How _high_ the rows are, in terminal lines. In this case we have five rows# that support ten line of text, one of three lines, and one of fourrows:[10,10,10,10,10,3,4]# The app redraws itself once a secondrefreshInterval:1term:"xterm-256color" Attributes colors. +wtf:colors:background:"red"border:Focusable:"darkslateblue"focused:"orange"normal:"gray"grid:# How _wide_ the columns are, in terminal characters. In this case we have# six columns, each of which are 35 characters widecolumns:[35,35,35,35,35,35]# How _high_ the rows are, in terminal lines. In this case we have five rows# that support ten line of text, one of three lines, and one of fourrows:[10,10,10,10,10,3,4]# The app redraws itself once a secondopenFileUtil:openrefreshInterval:1term:"xterm-256color" Attributes colors. diff --git a/wtf/utils.go b/wtf/utils.go index 971bb51d..4d859a6b 100644 --- a/wtf/utils.go +++ b/wtf/utils.go @@ -81,7 +81,8 @@ func NamesFromEmails(emails []string) []string { // OpenFile opens the file defined in `path` via the operating system func OpenFile(path string) { filePath, _ := ExpandHomeDir(path) - cmd := exec.Command("open", filePath) + openFileUtil := Config.UString("wtf.openFileUtil", "open") + cmd := exec.Command(openFileUtil, filePath) ExecuteCommand(cmd) }