Skip to content

Commit

Permalink
Fixed a typo and fixed formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Kongsgaard authored and Daniel Kongsgaard committed Sep 23, 2023
1 parent 47ab375 commit 5647310
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/config/lua/wezterm/basename.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ from Rust's [`std::path::PathBuf`](https://doc.rust-lang.org/nightly/std/path/st
local wezterm = require 'wezterm'
local basename = wezterm.basename

wezterm.log_info( 'baz.txt = ' .. basename '/foo/bar/baz.txt' )
wezterm.log_info('baz.txt = ' .. basename '/foo/bar/baz.txt')
```

See also [dirname](dirname.md).
12 changes: 10 additions & 2 deletions docs/config/lua/wezterm/canonical_path.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,25 @@ in a different format.
local wezterm = require 'wezterm'
local canonical_path = wezterm.canonical_path

wezterm.log_error( wezterm.home_dir .. ' = ' canonical_path( wezterm.home_dir .. "/.") )
wezterm.log_error(
wezterm.home_dir .. ' = ' .. canonical_path(wezterm.home_dir .. '/.')
)
```

Another common use case is to find the absolute path of a symlink. E.g., Dropbox is usually
symlinked to `$HOME/Dropbox` on macOS, but is located at `$HOME/Library/CloudStorage/Dropbox`.
```lua
-- macOS only:
local wezterm = require 'wezterm'
local canonical_path = wezterm.canonical_path
local home_dir = wezterm.home_dir

wezterm.log_error( home_dir .. '/Library/CloudStorage/Dropbox' .. ' = ' .. canonical_path( home_dir .. "/Dropbox") )
wezterm.log_error(
home_dir
.. '/Library/CloudStorage/Dropbox'
.. ' = '
.. canonical_path(home_dir .. '/Dropbox')
)
```

See also [glob](glob.md).
4 changes: 2 additions & 2 deletions docs/config/lua/wezterm/dirname.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ behave slightly different in some edge case.
local wezterm = require 'wezterm'
local dirname = wezterm.dirname

wezterm.log_error( '/foo/bar = ' .. dirname '/foo/bar/baz.txt' )
wezterm.log_error('/foo/bar = ' .. dirname '/foo/bar/baz.txt')
```

If you want only the directory name and not the full path, you can use
Expand All @@ -31,7 +31,7 @@ local wezterm = require 'wezterm'
local basename = wezterm.basename
local dirname = wezterm.dirname

wezterm.log_error( 'bar = ' .. basename(dirname '/foo/bar/baz.txt') )
wezterm.log_error('bar = ' .. basename(dirname '/foo/bar/baz.txt'))
```

See also [basename](basename.md).
6 changes: 3 additions & 3 deletions lua-api-crates/filesystem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ async fn dirname<'lua>(_: &'lua Lua, path: String) -> mlua::Result<String> {
Ok(utf8.to_string())
} else {
return Err(mlua::Error::external(anyhow!(
"path entry {} is not representable as utf8",
path.display()
)));
"path entry {} is not representable as utf8",
path.display()
)));
}
} else {
// parent returns None if the path terminates in a root or prefix
Expand Down

0 comments on commit 5647310

Please sign in to comment.