From 82a983d93448d1401d9e2313aacd17a2e06da22b Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Sat, 19 Jul 2025 21:32:12 +1000 Subject: [PATCH] Separate config and data files for Windows (#2051) --- doc.md | 13 ++++++------- doc.txt | 13 ++++++------- lf.1 | 15 +++++++-------- os_windows.go | 10 ++++++---- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/doc.md b/doc.md index 2ad629b8..47ed98bb 100644 --- a/doc.md +++ b/doc.md @@ -319,19 +319,19 @@ Configuration files should be located at: OS system-wide user-specific Unix /etc/lf/lfrc ~/.config/lf/lfrc - Windows C:\ProgramData\lf\lfrc C:\Users\\AppData\Local\lf\lfrc + Windows C:\ProgramData\lf\lfrc C:\Users\\AppData\Roaming\lf\lfrc The colors file should be located at: OS system-wide user-specific Unix /etc/lf/colors ~/.config/lf/colors - Windows C:\ProgramData\lf\colors C:\Users\\AppData\Local\lf\colors + Windows C:\ProgramData\lf\colors C:\Users\\AppData\Roaming\lf\colors The icons file should be located at: OS system-wide user-specific Unix /etc/lf/icons ~/.config/lf/icons - Windows C:\ProgramData\lf\icons C:\Users\\AppData\Local\lf\icons + Windows C:\ProgramData\lf\icons C:\Users\\AppData\Roaming\lf\icons The selection file should be located at: @@ -365,12 +365,11 @@ You can configure these locations with the following variables given with their ~/.local/share Windows - %ProgramData% - C:\ProgramData - %LF_CONFIG_HOME% + %APPDATA% + + %LF_DATA_HOME% %LOCALAPPDATA% - C:\Users\\AppData\Local A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example diff --git a/doc.txt b/doc.txt index 4bab1ed7..b3f1e099 100644 --- a/doc.txt +++ b/doc.txt @@ -311,19 +311,19 @@ Configuration files should be located at: OS system-wide user-specific Unix /etc/lf/lfrc ~/.config/lf/lfrc - Windows C:\ProgramData\lf\lfrc C:\Users\\AppData\Local\lf\lfrc + Windows C:\ProgramData\lf\lfrc C:\Users\\AppData\Roaming\lf\lfrc The colors file should be located at: OS system-wide user-specific Unix /etc/lf/colors ~/.config/lf/colors - Windows C:\ProgramData\lf\colors C:\Users\\AppData\Local\lf\colors + Windows C:\ProgramData\lf\colors C:\Users\\AppData\Roaming\lf\colors The icons file should be located at: OS system-wide user-specific Unix /etc/lf/icons ~/.config/lf/icons - Windows C:\ProgramData\lf\icons C:\Users\\AppData\Local\lf\icons + Windows C:\ProgramData\lf\icons C:\Users\\AppData\Roaming\lf\icons The selection file should be located at: @@ -358,12 +358,11 @@ with their order of precedences and their default values: ~/.local/share Windows - %ProgramData% - C:\ProgramData - %LF_CONFIG_HOME% + %APPDATA% + + %LF_DATA_HOME% %LOCALAPPDATA% - C:\Users\\AppData\Local A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example diff --git a/lf.1 b/lf.1 index 22623163..b27518cb 100644 --- a/lf.1 +++ b/lf.1 @@ -1,6 +1,6 @@ .\" Automatically generated by Pandoc 3.7.0.2 .\" -.TH "LF" "1" "2025\-07\-18" "" "DOCUMENTATION" +.TH "LF" "1" "2025\-07\-19" "" "DOCUMENTATION" .SH NAME lf \- terminal file manager .SH SYNOPSIS @@ -336,7 +336,7 @@ Configuration files should be located at: .EX OS system\-wide user\-specific Unix /etc/lf/lfrc \(ti/.config/lf/lfrc -Windows C:\(rsProgramData\(rslf\(rslfrc C:\(rsUsers\(rs\(rsAppData\(rsLocal\(rslf\(rslfrc +Windows C:\(rsProgramData\(rslf\(rslfrc C:\(rsUsers\(rs\(rsAppData\(rsRoaming\(rslf\(rslfrc .EE .PP The colors file should be located at: @@ -344,7 +344,7 @@ The colors file should be located at: .EX OS system\-wide user\-specific Unix /etc/lf/colors \(ti/.config/lf/colors -Windows C:\(rsProgramData\(rslf\(rscolors C:\(rsUsers\(rs\(rsAppData\(rsLocal\(rslf\(rscolors +Windows C:\(rsProgramData\(rslf\(rscolors C:\(rsUsers\(rs\(rsAppData\(rsRoaming\(rslf\(rscolors .EE .PP The icons file should be located at: @@ -352,7 +352,7 @@ The icons file should be located at: .EX OS system\-wide user\-specific Unix /etc/lf/icons \(ti/.config/lf/icons -Windows C:\(rsProgramData\(rslf\(rsicons C:\(rsUsers\(rs\(rsAppData\(rsLocal\(rslf\(rsicons +Windows C:\(rsProgramData\(rslf\(rsicons C:\(rsUsers\(rs\(rsAppData\(rsRoaming\(rslf\(rsicons .EE .PP The selection file should be located at: @@ -397,12 +397,11 @@ Unix \(ti/.local/share Windows - %ProgramData% - C:\(rsProgramData - %LF_CONFIG_HOME% + %APPDATA% + + %LF_DATA_HOME% %LOCALAPPDATA% - C:\(rsUsers\(rs\(rsAppData\(rsLocal .EE .PP A sample configuration file can be found at \c diff --git a/os_windows.go b/os_windows.go index c5f5d41a..ecf14a49 100644 --- a/os_windows.go +++ b/os_windows.go @@ -74,23 +74,25 @@ func init() { Username: username, } - data := cmp.Or(os.Getenv("LF_CONFIG_HOME"), os.Getenv("LOCALAPPDATA")) + config := cmp.Or(os.Getenv("LF_CONFIG_HOME"), os.Getenv("APPDATA")) gConfigPaths = []string{ filepath.Join(os.Getenv("ProgramData"), "lf", "lfrc"), - filepath.Join(data, "lf", "lfrc"), + filepath.Join(config, "lf", "lfrc"), } gColorsPaths = []string{ filepath.Join(os.Getenv("ProgramData"), "lf", "colors"), - filepath.Join(data, "lf", "colors"), + filepath.Join(config, "lf", "colors"), } gIconsPaths = []string{ filepath.Join(os.Getenv("ProgramData"), "lf", "icons"), - filepath.Join(data, "lf", "icons"), + filepath.Join(config, "lf", "icons"), } + data := cmp.Or(os.Getenv("LF_DATA_HOME"), os.Getenv("LOCALAPPDATA")) + gFilesPath = filepath.Join(data, "lf", "files") gMarksPath = filepath.Join(data, "lf", "marks") gTagsPath = filepath.Join(data, "lf", "tags")