Create empty directories and files on interactive startup (#7796)

Closes #7402
This commit is contained in:
Ilan Cosman 2021-03-23 13:01:00 -07:00 committed by GitHub
parent 76af09a507
commit bcbfd70d41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -19,6 +19,8 @@ Interactive improvements
- Commands that wrap ``cd`` (using ``complete --wraps cd``) get the same completions as ``cd`` (:issue:`4693`). - 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`). - 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 New or improved bindings
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -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 __update_cwd_osc # Run once because we might have already inherited a PWD from an old tab
end 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. # 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. # The universal variable __fish_initialized is initialized in share/config.fish.
set __fish_initialized 3100 set __fish_initialized 3100