feat(config-settings): add Dots link toggle for user-dots symlink
Extract the user-dots symlink logic into the __fish_user_dots_link helper and add a dedicated __fish_user_dots_symlink toggle, surfaced as a 'Dots link' bool row on the config-settings Paths page. Unlike the opinionated categories it has no universal/session split — it acts on a literal path. Setting it falsy (or toggling off) stops symlink generation and removes any existing link immediately, honoured regardless of the C2 master switch. Creation remains a C2 startup side-effect. config.fish now calls the helper. Docs: README, fish-config.md (C2 table, Paths page, machine-local section), and fish-config.index updated.
This commit is contained in:
@@ -57,10 +57,10 @@ function __config_settings_draw_value
|
||||
else
|
||||
set title "Path Settings"
|
||||
set active_idx 3
|
||||
set vars __fish_scrollback_history_dir __fish_scrollback_history_max_files __fish_user_dots_path
|
||||
set labels "Log dir" "Log max" "Dots path"
|
||||
set types path int path
|
||||
set hints "~/.terminal_history" 100 "(default)"
|
||||
set vars __fish_scrollback_history_dir __fish_scrollback_history_max_files __fish_user_dots_path __fish_user_dots_symlink
|
||||
set labels "Log dir" "Log max" "Dots path" "Dots link"
|
||||
set types path int path bool
|
||||
set hints "~/.terminal_history" 100 "(default)" on
|
||||
end
|
||||
set -l nrows (count $vars)
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# SYNOPSIS
|
||||
# __fish_user_dots_link
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Manages the git-ignored `user-dots` convenience symlink in the fish config
|
||||
# directory ($__fish_config_dir/user-dots), pointing it at the resolved
|
||||
# $__fish_user_dots_path so the private overlay can be browsed from
|
||||
# ~/.config/fish/.
|
||||
#
|
||||
# Behaviour is controlled by the __fish_user_dots_symlink toggle:
|
||||
# - explicit falsy (0/false/…) — remove our symlink if present and stop.
|
||||
# Honoured regardless of C2, so opting out always cleans up.
|
||||
# - unset or truthy (default) — create the link if missing and repoint it
|
||||
# if the target changed. This is a C2 startup side-effect, so it only
|
||||
# creates when __fish_config_op_autoexec is enabled.
|
||||
#
|
||||
# Only ever manages a symlink; a real file or directory at that path is left
|
||||
# untouched.
|
||||
#
|
||||
# ARGUMENTS
|
||||
# (none)
|
||||
#
|
||||
# RETURNS
|
||||
# 0 Always
|
||||
#
|
||||
# EXAMPLE
|
||||
# __fish_user_dots_link
|
||||
function __fish_user_dots_link --description 'Manage the user-dots convenience symlink'
|
||||
set -l link "$__fish_config_dir/user-dots"
|
||||
set -q __fish_user_dots_path
|
||||
or set -l __fish_user_dots_path "$XDG_CONFIG_HOME/.user-dots/fish"
|
||||
|
||||
# Explicit opt-out: remove our symlink (never a real file/dir) and stop.
|
||||
__fish_variable_check __fish_user_dots_symlink
|
||||
if test $status -eq 1
|
||||
test -L "$link"; and rm -f "$link"
|
||||
return 0
|
||||
end
|
||||
|
||||
# Enabled: creation is a C2 startup side-effect.
|
||||
__fish_config_op_enabled __fish_config_op_autoexec; or return 0
|
||||
|
||||
test -d "$__fish_user_dots_path"; or return 0
|
||||
if test -L "$link"
|
||||
test (readlink "$link") != "$__fish_user_dots_path"
|
||||
and ln -sfn "$__fish_user_dots_path" "$link"
|
||||
else if not test -e "$link"
|
||||
ln -s "$__fish_user_dots_path" "$link"
|
||||
end
|
||||
end
|
||||
@@ -80,9 +80,9 @@ function config-settings --description 'Interactive TUI for managing fish config
|
||||
set -l sponge_vars sponge_delay sponge_purge_only_on_exit sponge_allow_previously_successful sponge_successful_exit_codes __fish_sponge_extra_sensitive
|
||||
set -l sponge_types int bool bool list list
|
||||
set -l sponge_labels Delay "Purge@exit" "Allow prev" "OK codes" "Extra secret"
|
||||
set -l paths_vars __fish_scrollback_history_dir __fish_scrollback_history_max_files __fish_user_dots_path
|
||||
set -l paths_types path int path
|
||||
set -l paths_labels "Log dir" "Log max" "Dots path"
|
||||
set -l paths_vars __fish_scrollback_history_dir __fish_scrollback_history_max_files __fish_user_dots_path __fish_user_dots_symlink
|
||||
set -l paths_types path int path bool
|
||||
set -l paths_labels "Log dir" "Log max" "Dots path" "Dots link"
|
||||
|
||||
# Reset/blank-edit target for each value row. A non-empty entry is written
|
||||
# verbatim (sponge reads sponge_delay / sponge_successful_exit_codes with no
|
||||
@@ -91,10 +91,10 @@ function config-settings --description 'Interactive TUI for managing fish config
|
||||
# extra-sensitive list all tolerate being unset). Bool rows are not reset
|
||||
# through this path — they are a 2-state true/false with no unset state.
|
||||
set -l sponge_defaults 2 '' '' 0 ''
|
||||
set -l paths_defaults '' '' ''
|
||||
set -l paths_defaults '' '' '' ''
|
||||
|
||||
# Rows per page index 0..3
|
||||
set -l page_rows 7 7 5 3
|
||||
set -l page_rows 7 7 5 4
|
||||
|
||||
set -l cur_page 0 # 0=Universal 1=Session 2=Sponge 3=Paths
|
||||
set -l cur_row 0
|
||||
@@ -162,12 +162,21 @@ function config-settings --description 'Interactive TUI for managing fish config
|
||||
set -l next_val on
|
||||
test "$cur_val" = off; and set next_val DEFAULT
|
||||
__config_settings_apply $varname $scope $next_val
|
||||
else if test $cur_page -eq 2
|
||||
# Sponge bool rows are 2-state (true/false) with no unset
|
||||
# state — sponge reads them with no fallback. → sets true.
|
||||
else
|
||||
# Value pages: bool rows are 2-state (true/false). → sets
|
||||
# true. Sponge reads its bools with no fallback; the Paths
|
||||
# "Dots link" bool drives __fish_user_dots_link on change.
|
||||
set -l v_vars $sponge_vars
|
||||
set -l v_types $sponge_types
|
||||
if test $cur_page -eq 3
|
||||
set v_vars $paths_vars
|
||||
set v_types $paths_types
|
||||
end
|
||||
set -l ridx (math $cur_row + 1)
|
||||
if test "$sponge_types[$ridx]" = bool
|
||||
set -U $sponge_vars[$ridx] true 2>/dev/null
|
||||
if test "$v_types[$ridx]" = bool
|
||||
set -U $v_vars[$ridx] true 2>/dev/null
|
||||
test "$v_vars[$ridx]" = __fish_user_dots_symlink
|
||||
and __fish_user_dots_link
|
||||
end
|
||||
end
|
||||
case left h
|
||||
@@ -196,6 +205,8 @@ function config-settings --description 'Interactive TUI for managing fish config
|
||||
set -l vtype $v_types[$ridx]
|
||||
if test "$vtype" = bool
|
||||
set -U $varname false 2>/dev/null
|
||||
test "$varname" = __fish_user_dots_symlink
|
||||
and __fish_user_dots_link
|
||||
else
|
||||
__config_settings_set_value $varname $vtype "$v_defaults[$ridx]"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user