diff --git a/CHANGELOG.md b/CHANGELOG.md index 22ece95d0..70e56ad58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Changes: * `wm.detectPlugin` now defaults to `true` (WM) Features: -* Adds `{cwd-tilde}` for custom title formatting, which prints the current working directory (Title) +* Adds `{cwd}` for custom title formatting, which prints the current working directory (Title) * Adds support for detecting the Zed version (#2200, Editor) * Adds support for detecting `moss` packages (Packages, Linux) * Adds support for detecting komorebi, FancyWM, and GlazeWM (WM, Windows) diff --git a/doc/json_schema.json b/doc/json_schema.json index 9f4adaa0d..8627d3223 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -498,7 +498,7 @@ "type": "string" }, "titleFormat": { - "description": "Output format of the module `Title`. See Wiki for formatting syntax\n 1. {user-name}: User name\n 2. {host-name}: Host name\n 3. {home-dir}: Home directory\n 4. {exe-path}: Executable path of current process\n 5. {user-shell}: User's default shell\n 6. {user-name-colored}: User name (colored)\n 7. {at-symbol-colored}: @ symbol (colored)\n 8. {host-name-colored}: Host name (colored)\n 9. {full-user-name}: Full user name\n 10. {user-id}: UID (*nix) / SID (Windows)\n 11. {pid}: PID of current process\n 12. {cwd}: Current working directory\n 13. {cwd-tilde}: CWD with home dir replaced by `~`, and trims trailing `/`", + "description": "Output format of the module `Title`. See Wiki for formatting syntax\n 1. {user-name}: User name\n 2. {host-name}: Host name\n 3. {home-dir}: Home directory\n 4. {exe-path}: Executable path of current process\n 5. {user-shell}: User's default shell\n 6. {user-name-colored}: User name (colored)\n 7. {at-symbol-colored}: @ symbol (colored)\n 8. {host-name-colored}: Host name (colored)\n 9. {full-user-name}: Full user name\n 10. {user-id}: UID (*nix) / SID (Windows)\n 11. {pid}: PID of current process\n 12. {cwd}: CWD with home dir replaced by `~`", "type": "string" }, "themeFormat": { diff --git a/presets/examples/32.jsonc b/presets/examples/32.jsonc index e0cc49d8a..ff69333b2 100644 --- a/presets/examples/32.jsonc +++ b/presets/examples/32.jsonc @@ -1,6 +1,6 @@ // Inspired by microfetch { - "$schema": "file:///C:/msys64/home/zhang/fastfetch/doc/json_schema.json", + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", "logo": { "type": "small" }, @@ -17,7 +17,7 @@ "modules": [ { "type": "title", - "format": "{user-name-colored}{#light_red}@{host-name-colored} {#}{cwd-tilde}" + "format": "{user-name-colored}{#light_red}@{host-name-colored} {#}{cwd}" }, { "type": "os", diff --git a/src/detection/disk/disk_windows.c b/src/detection/disk/disk_windows.c index 64014e1cf..200b0e56d 100644 --- a/src/detection/disk/disk_windows.c +++ b/src/detection/disk/disk_windows.c @@ -18,7 +18,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) // For cross-platform portability; used by `presets/examples/13.jsonc` if (options->folders.length == 1 && options->folders.chars[0] == '/') { - wchar_t path[16]; + wchar_t path[PATH_MAX]; GetSystemWindowsDirectoryW(path, ARRAY_SIZE(path)); // Loads from KernelBaseGlobalData, very fast options->folders.chars[0] = (char) path[0]; ffStrbufAppendS(&options->folders, ":\\"); diff --git a/src/modules/title/title.c b/src/modules/title/title.c index dcd765f48..89320a32c 100644 --- a/src/modules/title/title.c +++ b/src/modules/title/title.c @@ -68,7 +68,7 @@ bool ffPrintTitle(FFTitleOptions* options) } else ffStrbufSet(&cwdTilde, &instance.state.platform.cwd); - ffStrbufTrimRight(&cwdTilde, '/'); + if (cwdTilde.length > 1) ffStrbufTrimRight(&cwdTilde, '/'); FF_PRINT_FORMAT_CHECKED(FF_TITLE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, ((FFformatarg[]){ FF_FORMAT_ARG(instance.state.platform.userName, "user-name"), @@ -86,8 +86,7 @@ bool ffPrintTitle(FFTitleOptions* options) FF_FORMAT_ARG(instance.state.platform.sid, "user-id"), #endif FF_FORMAT_ARG(instance.state.platform.pid, "pid"), - FF_FORMAT_ARG(instance.state.platform.cwd, "cwd"), - FF_FORMAT_ARG(cwdTilde, "cwd-tilde"), + FF_FORMAT_ARG(cwdTilde, "cwd"), })); } @@ -202,7 +201,6 @@ FFModuleBaseInfo ffTitleModuleInfo = { {"Full user name", "full-user-name"}, {"UID (*nix) / SID (Windows)", "user-id"}, {"PID of current process", "pid"}, - {"Current working directory", "cwd"}, - {"CWD with home dir replaced by `~`, and trims trailing `/`", "cwd-tilde"}, + {"CWD with home dir replaced by `~`", "cwd"}, })) };