Skip to content

Commit

Permalink
add support for LF_CONFIG/DATA_HOME on unix
Browse files Browse the repository at this point in the history
  • Loading branch information
gokcehan committed Jul 3, 2023
1 parent bc0bc6e commit 067ffa8
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 21 deletions.
20 changes: 14 additions & 6 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,24 @@ History file should be located at:
Unix ~/.local/share/lf/history
Windows C:\Users\<user>\AppData\Local\lf\history
You can configure the default values of following variables to change these locations:
You can configure these locations with the following variables given with their order of precedences and their default values:
Unix
$XDG_CONFIG_HOME ~/.config
$XDG_DATA_HOME ~/.local/share
$LF_CONFIG_HOME
$XDG_CONFIG_HOME
~/.config
$LF_DATA_HOME
$XDG_DATA_HOME
~/.local/share
Windows
%ProgramData% C:\ProgramData
%LOCALAPPDATA% C:\Users\<user>\AppData\Local
%LF_CONFIG_HOME% If set, use this value instead of %LOCALAPPDATA%
%ProgramData%
C:\ProgramData
%LF_CONFIG_HOME%
%LOCALAPPDATA%
C:\Users\<user>\AppData\Local
A sample configuration file can be found at
https://github.com/gokcehan/lf/blob/master/etc/lfrc.example
Expand Down
22 changes: 15 additions & 7 deletions docstring.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 18 additions & 6 deletions lf.1
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,31 @@ History file should be located at:
Windows C:\eUsers\e<user>\eAppData\eLocal\elf\ehistory
.EE
.PP
You can configure the default values of following variables to change these locations:
You can configure these locations with the following variables given with their order of precedences and their default values:
.PP
.EX
Unix
$XDG_CONFIG_HOME ~/.config
$XDG_DATA_HOME ~/.local/share
$LF_CONFIG_HOME
$XDG_CONFIG_HOME
~/.config
.EE
.PP
.EX
$LF_DATA_HOME
$XDG_DATA_HOME
~/.local/share
.EE
.PP
.EX
Windows
%ProgramData% C:\eProgramData
%LOCALAPPDATA% C:\eUsers\e<user>\eAppData\eLocal
%LF_CONFIG_HOME% If set, use this value instead of %LOCALAPPDATA%
%ProgramData%
C:\eProgramData
.EE
.PP
.EX
%LF_CONFIG_HOME%
%LOCALAPPDATA%
C:\eUsers\e<user>\eAppData\eLocal
.EE
.PP
A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example
Expand Down
10 changes: 8 additions & 2 deletions os.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func init() {
}
gUser = u

config := os.Getenv("XDG_CONFIG_HOME")
config := os.Getenv("LF_CONFIG_HOME")
if config == "" {
config = os.Getenv("XDG_CONFIG_HOME")
}
if config == "" {
config = filepath.Join(gUser.HomeDir, ".config")
}
Expand All @@ -104,7 +107,10 @@ func init() {
filepath.Join(config, "lf", "icons"),
}

data := os.Getenv("XDG_DATA_HOME")
data := os.Getenv("LF_DATA_HOME")
if data == "" {
data = os.Getenv("XDG_DATA_HOME")
}
if data == "" {
data = filepath.Join(gUser.HomeDir, ".local", "share")
}
Expand Down

0 comments on commit 067ffa8

Please sign in to comment.