diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d0b094c5b..cec3bf591 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -19,6 +19,8 @@ Interactive improvements - Commands that wrap ``cd`` (using ``complete --wraps cd``) get the same completions as ``cd`` (:issue:`4693`). - Arguments longer than 1024 characters no longer trigger excessive CPU usage on Mac (:issue:`7837`). +- Fish now automatically creates ``config.fish`` and the configuration directories in ``$XDG_CONFIG_HOME/fish`` (by default ``~/.config/fish``) if they do not already exist. + New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index cb17dc58c..0b3bb6195 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -266,6 +266,16 @@ function __fish_config_interactive -d "Initializations that should be performed __update_cwd_osc # Run once because we might have already inherited a PWD from an old tab end + # Create empty configuration directores if they do not already exist + test -e $__fish_config_dir/completions/ -a -e $__fish_config_dir/conf.d/ -a -e $__fish_config_dir/functions/ || + mkdir -p $__fish_config_dir/{completions, conf.d, functions} + + # Create config.fish with some boilerplate if it does not exist + test -e $__fish_config_dir/config.fish || echo "\ +if status is-interactive + # Commands to run in interactive sessions can go here +end" >$__fish_config_dir/config.fish + # Bump this whenever some code below needs to run once when upgrading to a new version. # The universal variable __fish_initialized is initialized in share/config.fish. set __fish_initialized 3100