I noticed the default location for nushell's configuration files on Mac OS is ~/Library/Application Support/nushell/
, is it possible to change it to another location?
4 Answers
Issuing nu --help
gives the option
--config <String> - start with an alternate config file
So, starting it with nu --config another/location/config.nu
should do it.
Only symbolic link worked for me on macos m1:
mv ~/Library/Application\ Support/nushell ~/.config/
ln -s ~/.config/nushell ~/Library/Application\ Support/
I think it's better to set the NU_CONFIG_DIR
environment variable to the desired directory path,so if you are using bash open nano ~/.bash_profile
or if you are using zsh open nano ~/.zprofile
and put this line into it :
export NU_CONFIG_DIR=/path/to/custom/location
now save and exit then apply the changes to your current shell session like below if you are under bash :
source ~/.bash_profile
and if you are under zsh
source ~/.zprofile
that's it,nushell will use the specified directory (/path/to/custom/location
) as the location for its configuration files, such as config.toml
and history.txt
!
-
may I ask what is
config.toml
for? It wasn't mentioned in the configuration.– JianCommented Aug 2, 2023 at 8:02 -
sure,
config.toml
file is a configuration file used by nushell, a modern shell for the command-line interface and it allows you to define and modify settings, but it's important to note that it is optional, and nushell will use default settings if the file is not present or if specific settings are not defined within it.– FreemanCommented Aug 2, 2023 at 8:11 -
1
Nushell now supports using the XDG_CONFIG_HOME
environment variable to specify the location for config files. The variable must be set before Nushell is launched.
I'm not a macOS user, so I hope my process and terminology are correct here. I believe there are several ways to set these variables:
From this Stack Overflow answer, use
launchctl setenv XDG_CONFIG_HOME <path>
.If that doesn't, work, a user on the Nushell Discord server reported that they needed to create a LaunchAgent in their user-level
~/Library/LaunchAgents
like:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>me.oscarvarto.environment</string> <key>ProgramArguments</key> <array> <string>/bin/sh</string> <string>-c</string> <string> launchctl setenv XDG_CONFIG_HOME /Users/oscarvarto/.config && launchctl setenv XDG_CACHE_HOME /Users/oscarvarto/.cache && launchctl setenv XDG_DATA_HOME /Users/oscarvarto/.local/share && launchctl setenv XDG_STATE_HOME /Users/oscarvarto/.local/state && launchctl setenv XDG_RUNTIME_DIR /Users/oscarvarto/.local/run && launchctl setenv XDG_BIN_HOME /Users/oscarvarto/.local/bin </string> </array> <key>RunAtLoad</key> <true/> <key>ServiceIPC</key> <false/> </dict> </plist>