4

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 4

2

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.

1

Only symbolic link worked for me on macos m1:

mv ~/Library/Application\ Support/nushell ~/.config/
ln -s ~/.config/nushell ~/Library/Application\ Support/
0

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!

3
  • may I ask what is config.toml for? It wasn't mentioned in the configuration.
    – Jian
    Commented 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.
    – Freeman
    Commented Aug 2, 2023 at 8:11
  • 1
    does not work on macos
    – rofrol
    Commented Jan 24 at 10:41
0

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:

  1. From this Stack Overflow answer, use launchctl setenv XDG_CONFIG_HOME <path>.

  2. 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>
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .