add 'source' command to read a configuration file

Related #97
This commit is contained in:
Gokcehan 2018-06-28 17:13:43 +03:00
parent 5d5d00e30b
commit 6c319316e2
4 changed files with 9 additions and 0 deletions

View File

@ -49,6 +49,7 @@ var (
"echo",
"cd",
"select",
"source",
"push",
}

1
doc.go
View File

@ -50,6 +50,7 @@ The following commands are provided by lf without default keybindings:
echo prints its arguments to the message line
cd changes working directory to its argument
select changes current file selection to its argument
source reads the configuration file in its argument
push simulate key pushes given in its argument
The following command line commands are provided by lf with default

View File

@ -54,6 +54,7 @@ The following commands are provided by lf without default keybindings:
echo prints its arguments to the message line
cd changes working directory to its argument
select changes current file selection to its argument
source reads and evaluates the file in its argument
push simulate key pushes given in its argument
The following command line commands are provided by lf with default

View File

@ -464,6 +464,12 @@ func (e *callExpr) eval(app *app, args []string) {
}
app.ui.loadFile(app.nav)
app.ui.loadFileInfo(app.nav)
case "source":
if len(e.args) != 1 {
app.ui.print("source: requires an argument")
return
}
app.readFile(strings.Replace(e.args[0], "~", gUser.HomeDir, -1))
case "push":
if len(e.args) != 1 {
app.ui.print("push: requires an argument")