feat(guards): per-category variable overrides master in __fish_config_op_enabled #41
@@ -178,7 +178,7 @@ Everything opinionated in this config — command shadows, startup side-effects,
|
|||||||
| `__fish_config_op_greeting` | Per-session `fish_greeting` (suppresses distro greetings such as CachyOS fastfetch by overriding with an empty function); first-run welcome banner |
|
| `__fish_config_op_greeting` | Per-session `fish_greeting` (suppresses distro greetings such as CachyOS fastfetch by overriding with an empty function); first-run welcome banner |
|
||||||
| `__fish_config_opinionated` | Master switch — all six categories at once |
|
| `__fish_config_opinionated` | Master switch — all six categories at once |
|
||||||
|
|
||||||
Set any of them to a falsy value (`0`, `false`, `no`, `off`, `n`) to disable; erase the variable to re-enable:
|
Set any of them to a falsy value (`0`, `false`, `no`, `off`, `n`) to disable; erase the variable to re-enable. An explicit per-category truthy value overrides a falsy master switch, so you can disable everything with `__fish_config_opinionated=0` and selectively re-enable individual categories:
|
||||||
|
|
||||||
```fish
|
```fish
|
||||||
# Plain shell: disable everything opinionated
|
# Plain shell: disable everything opinionated
|
||||||
@@ -187,8 +187,13 @@ set -U __fish_config_opinionated 0
|
|||||||
# Or pick a single category, e.g. keep integrations but drop command shadows
|
# Or pick a single category, e.g. keep integrations but drop command shadows
|
||||||
set -U __fish_config_op_aliases off
|
set -U __fish_config_op_aliases off
|
||||||
|
|
||||||
|
# Minimal mode but keep the greeting (per-category overrides master)
|
||||||
|
set -U __fish_config_opinionated 0
|
||||||
|
set -U __fish_config_op_greeting 1
|
||||||
|
|
||||||
# Back to full flavor
|
# Back to full flavor
|
||||||
set -Ue __fish_config_opinionated
|
set -Ue __fish_config_opinionated
|
||||||
|
set -Ue __fish_config_op_greeting
|
||||||
```
|
```
|
||||||
|
|
||||||
Command shadows react immediately; bindings, prompt, and abbreviations take effect in new shells. With aliases disabled, `rm` deletes permanently again instead of trashing. See `help config opinionated` for the full component list.
|
Command shadows react immediately; bindings, prompt, and abbreviations take effect in new shells. With aliases disabled, `rm` deletes permanently again instead of trashing. See `help config opinionated` for the full component list.
|
||||||
|
|||||||
@@ -1387,6 +1387,10 @@ __fish_variable_check. Set a variable to any falsy value (0, false, no,
|
|||||||
off, n) to disable its category; erase it or set a truthy value (1, true,
|
off, n) to disable its category; erase it or set a truthy value (1, true,
|
||||||
yes, on, y) to re-enable. Unset means enabled.
|
yes, on, y) to re-enable. Unset means enabled.
|
||||||
|
|
||||||
|
An explicit per-category truthy value takes precedence over the master
|
||||||
|
switch: setting __fish_config_opinionated=0 disables all unset categories,
|
||||||
|
but a category with an explicit truthy value remains enabled regardless.
|
||||||
|
|
||||||
Variable Disables
|
Variable Disables
|
||||||
------------------------------ ------------------------------------
|
------------------------------ ------------------------------------
|
||||||
__fish_config_op_aliases Command shadows and flag injection:
|
__fish_config_op_aliases Command shadows and flag injection:
|
||||||
@@ -1433,6 +1437,11 @@ Examples:
|
|||||||
# Re-enable everything:
|
# Re-enable everything:
|
||||||
set -Ue __fish_config_opinionated
|
set -Ue __fish_config_opinionated
|
||||||
|
|
||||||
|
# Minimal mode but keep the greeting:
|
||||||
|
set -U __fish_config_opinionated 0
|
||||||
|
set -U __fish_config_op_greeting 1
|
||||||
|
# (erase both to go back to full-flavor defaults)
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
- Command shadows (rm, cat, ls, ...) react immediately; conf.d-level
|
- Command shadows (rm, cat, ls, ...) react immediately; conf.d-level
|
||||||
|
|||||||
@@ -5,14 +5,15 @@
|
|||||||
# __fish_config_op_enabled <category_variable>
|
# __fish_config_op_enabled <category_variable>
|
||||||
#
|
#
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
# Guard predicate for opinionated components (AGENTS.md Task #3). The master
|
# Guard predicate for opinionated components (AGENTS.md Task #3).
|
||||||
# switch __fish_config_opinionated is always evaluated first via
|
# The category variable is evaluated first via __fish_variable_check:
|
||||||
# __fish_variable_check: a falsy master value (0/false/no/off/n) disables
|
# an explicit truthy value (1/true/yes/on/y) enables the component
|
||||||
# every category at once, regardless of the category variable's own value.
|
# regardless of the master switch; an explicit falsy value
|
||||||
# Otherwise the supplied category variable is evaluated the same way.
|
# (0/false/no/off/n) disables it regardless of the master switch.
|
||||||
# Unset or empty variables (status 2) and unrecognized values (status 3)
|
# Only when the category variable is unset or unrecognized (status 2
|
||||||
# leave the component enabled — opinionated components are active by
|
# or 3) does the master switch __fish_config_opinionated apply: a
|
||||||
# default and these variables are pure opt-out knobs.
|
# falsy master disables every unset-category component at once.
|
||||||
|
# Unset master with unset category → enabled (active by default).
|
||||||
#
|
#
|
||||||
# ARGUMENTS
|
# ARGUMENTS
|
||||||
# category_variable Name (without $) of the category opt-out variable:
|
# category_variable Name (without $) of the category opt-out variable:
|
||||||
@@ -23,23 +24,27 @@
|
|||||||
# __fish_config_op_greeting
|
# __fish_config_op_greeting
|
||||||
#
|
#
|
||||||
# RETURNS
|
# RETURNS
|
||||||
# 0 Component enabled (variables truthy, unset, or unrecognized)
|
# 0 Component enabled (category explicitly truthy; or category unset and master not falsy)
|
||||||
# 1 Component disabled (master or category variable is falsy)
|
# 1 Component disabled (category explicitly falsy; or category unset and master falsy; or no argument with falsy master)
|
||||||
#
|
#
|
||||||
# EXAMPLE
|
# EXAMPLE
|
||||||
# if __fish_config_op_enabled __fish_config_op_aliases
|
# if __fish_config_op_enabled __fish_config_op_aliases
|
||||||
# alias grep='grep --color=auto'
|
# alias grep='grep --color=auto'
|
||||||
# end
|
# end
|
||||||
function __fish_config_op_enabled --description 'Check whether an opinionated component category is enabled'
|
function __fish_config_op_enabled --description 'Check whether an opinionated component category is enabled'
|
||||||
# Master switch first: falsy disables all categories unconditionally.
|
__fish_variable_check $argv[1]
|
||||||
__fish_variable_check __fish_config_opinionated
|
set -l cat_status $status
|
||||||
if test $status -eq 1
|
|
||||||
|
if test $cat_status -eq 0
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
if test $cat_status -eq 1
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# Category variable: only an explicit falsy value disables the category.
|
# Status 3 (garbage) defers to master — an unrecognized value is not an opt-out.
|
||||||
# Truthy (0), unset/empty (2), and garbage (3) all keep it enabled.
|
__fish_variable_check __fish_config_opinionated
|
||||||
__fish_variable_check $argv[1]
|
|
||||||
if test $status -eq 1
|
if test $status -eq 1
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user