From bcbfd70d413155152ce1261f925a62b678c83d32 Mon Sep 17 00:00:00 2001 From: Ilan Cosman Date: Tue, 23 Mar 2021 13:01:00 -0700 Subject: [PATCH] Create empty directories and files on interactive startup (#7796) Closes #7402 --- CHANGELOG.rst | 2 ++ share/functions/__fish_config_interactive.fish | 10 ++++++++++ 2 files changed, 12 insertions(+) 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