config: fix wezterm.config_dir, add wezterm.config_file
refs: https://github.com/wez/wezterm/discussions/635#discussioncomment-567968
This commit is contained in:
1 parent
7a17ae833f
commit
b63a949df8
3 files changed
+25
-2
No files matched your search
+10
-2
@@ -37,9 +37,11 @@ use termwiz::surface::change::Change;
|
||||
///
|
||||
/// In addition to this, the lua standard library, except for
|
||||
/// the `debug` module, is also available to the script.
|
||||
pub fn make_lua_context(config_dir: &Path) -> anyhow::Result<Lua> {
|
||||
pub fn make_lua_context(config_file: &Path) -> anyhow::Result<Lua> {
|
||||
let lua = Lua::new();
|
||||
|
||||
let config_dir = config_file.parent().unwrap_or_else(|| Path::new("/"));
|
||||
|
||||
{
|
||||
let globals = lua.globals();
|
||||
// This table will be the `wezterm` module in the script
|
||||
@@ -70,6 +72,12 @@ pub fn make_lua_context(config_dir: &Path) -> anyhow::Result<Lua> {
|
||||
}
|
||||
}
|
||||
|
||||
wezterm_mod.set(
|
||||
"config_file",
|
||||
config_file
|
||||
.to_str()
|
||||
.ok_or_else(|| anyhow!("config file path is not UTF-8"))?,
|
||||
)?;
|
||||
wezterm_mod.set(
|
||||
"config_dir",
|
||||
config_dir
|
||||
@@ -650,7 +658,7 @@ mod test {
|
||||
.filter_level(log::LevelFilter::Trace)
|
||||
.try_init();
|
||||
|
||||
let lua = make_lua_context(&std::env::current_dir()?)?;
|
||||
let lua = make_lua_context(Path::new("testing"))?;
|
||||
|
||||
let total = Arc::new(Mutex::new(0));
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ brief notes about them may accumulate here.
|
||||
* Fixed: macOS: wezterm-gui could linger in the background until the mouse moves after all tabs/panes have closed
|
||||
* Fixed: when using [line_height](config/lua/config/line_height.md), wezterm now vertically centers the cell rather than padding only the top [#582](https://github.com/wez/wezterm/issues/582)
|
||||
* Fixed: macOS: in US layouts, `SUPER+SHIFT+[` was incorrectly recognized as `SUPER+SHIFT+{` instead of `SUPER+{` [#601](https://github.com/wez/wezterm/issues/601)
|
||||
* Fixed: [wezterm.config_dir](config/lua/wezterm/config_dir.md) was returning the config file path instead of the directory!
|
||||
* New: [wezterm.config_file](config/lua/wezterm/config_file.md) which returns the config file path
|
||||
|
||||
### 20210314-114017-04b7cedd
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# `wezterm.config_file`
|
||||
|
||||
*Since: nightly builds only*
|
||||
|
||||
This constant is set to the path to the `wezterm.lua` that is in use.
|
||||
|
||||
```lua
|
||||
local wezterm = require 'wezterm';
|
||||
wezterm.log_info("Config file " .. wezterm.config_file)
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user