From 564731072471ae75d94d145632108605abd4a767 Mon Sep 17 00:00:00 2001 From: Daniel Kongsgaard Date: Sun, 24 Sep 2023 01:04:28 +0200 Subject: [PATCH] Fixed a typo and fixed formatting. --- docs/config/lua/wezterm/basename.md | 2 +- docs/config/lua/wezterm/canonical_path.md | 12 ++++++++++-- docs/config/lua/wezterm/dirname.md | 4 ++-- lua-api-crates/filesystem/src/lib.rs | 6 +++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/config/lua/wezterm/basename.md b/docs/config/lua/wezterm/basename.md index 9ca5addebab..86429d34709 100644 --- a/docs/config/lua/wezterm/basename.md +++ b/docs/config/lua/wezterm/basename.md @@ -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). diff --git a/docs/config/lua/wezterm/canonical_path.md b/docs/config/lua/wezterm/canonical_path.md index f931cba5fe6..c63829a4e17 100644 --- a/docs/config/lua/wezterm/canonical_path.md +++ b/docs/config/lua/wezterm/canonical_path.md @@ -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). diff --git a/docs/config/lua/wezterm/dirname.md b/docs/config/lua/wezterm/dirname.md index 0b9412e3d11..813be2997f6 100644 --- a/docs/config/lua/wezterm/dirname.md +++ b/docs/config/lua/wezterm/dirname.md @@ -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 @@ -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). diff --git a/lua-api-crates/filesystem/src/lib.rs b/lua-api-crates/filesystem/src/lib.rs index 2fb131c2dfd..d0294b3300b 100644 --- a/lua-api-crates/filesystem/src/lib.rs +++ b/lua-api-crates/filesystem/src/lib.rs @@ -64,9 +64,9 @@ async fn dirname<'lua>(_: &'lua Lua, path: String) -> mlua::Result { 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