Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced by interactive shells: never set shell options here.
if command -v eza >/dev/null 2>&1; then
alias ls='eza --icons=always --group-directories-first'
alias ll='eza --icons=always --group-directories-first --long --git'
Expand Down
10 changes: 8 additions & 2 deletions DreamcoderShell/.zshrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Dreamcoder interactive Zsh ergonomics.
set -euo pipefail
# No errexit/nounset here: in an interactive shell they close the terminal on
# the first failing command and break plugins and the Starship init.
[[ -o interactive ]] || return

export EDITOR="nvim" VISUAL="nvim" COLORTERM="${COLORTERM:-truecolor}"
Expand All @@ -12,7 +13,12 @@ export BUN_INSTALL

# ── Dreamcoder Theme Hooks ─────────────────────────────────────
# Source shell-level theme snippets based on current mode.
_dc_mode="${DREAMCODER_THEME_MODE:-light}"
# The persisted live mode wins over an inherited value, which a long-lived
# parent (e.g. a Herdr server started before the last switch) may carry stale.
_dc_mode_cache="${XDG_CACHE_HOME:-${HOME}/.cache}/dreamcoder/cursor-cli.env"
_dc_mode="$([[ -r "${_dc_mode_cache}" ]] && sed -nE 's/^(export )?DREAMCODER_THEME_MODE="?(light|dark)"?$/\2/p' "${_dc_mode_cache}" | tail -n1)"
_dc_mode="${_dc_mode:-${DREAMCODER_THEME_MODE:-dark}}"
export DREAMCODER_THEME_MODE="${_dc_mode}"
_dc_theme_dir="${DREAMCODER_DOTS_DIR:-${HOME}/Documents/PROYECTOS/dreamcoder-dots}/themes/dreamcoder"

[[ -f "${_dc_theme_dir}/ls-colors-dreamcoder-${_dc_mode}.sh" ]] && source "${_dc_theme_dir}/ls-colors-dreamcoder-${_dc_mode}.sh"
Expand Down
2 changes: 1 addition & 1 deletion DreamcoderThemes/bat-dreamcoder.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Dark — Bat theme; run 'bat cache --build' after installing the tmTheme.
export BAT_THEME="Dreamcoder-Dark"
export BAT_STYLE="auto,changes,header,grid"
Expand Down
2 changes: 1 addition & 1 deletion DreamcoderThemes/dreamcoder/bat-dreamcoder-dark.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Dark — Bat theme; run 'bat cache --build' after installing the tmTheme.
export BAT_THEME="Dreamcoder-Dark"
export BAT_STYLE="auto,changes,header,grid"
Expand Down
2 changes: 1 addition & 1 deletion DreamcoderThemes/dreamcoder/bat-dreamcoder-light.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Light — Bat theme; run 'bat cache --build' after installing the tmTheme.
export BAT_THEME="Dreamcoder-Light"
export BAT_STYLE="auto,changes,header,grid"
Expand Down
2 changes: 1 addition & 1 deletion DreamcoderThemes/dreamcoder/bat-dreamcoder-night.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Dark Night — Bat theme; run 'bat cache --build' after installing the tmTheme.
export BAT_THEME="Dreamcoder-Night"
export BAT_STYLE="auto,changes,header,grid"
Expand Down
2 changes: 1 addition & 1 deletion DreamcoderThemes/dreamcoder/fzf-dreamcoder-dark.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Dark — fzf
export FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS:-} --color=bg:#000000,bg+:#0D0D0F,fg:#E6E6E6,fg+:#E6E6E6,hl:#A5B4FC,hl+:#A5B4FC,info:#7DD3FC,marker:#34D399,prompt:#A5B4FC,spinner:#D4B5FD,pointer:#D4B5FD,header:#C7C7C7,border:#6B6B6B,label:#C7C7C7,query:#E6E6E6,gutter:#0D0D0F,scrollbar:#6B6B6B,separator:#6B6B6B,preview-bg:#0D0D0F,preview-border:#6B6B6B"
2 changes: 1 addition & 1 deletion DreamcoderThemes/dreamcoder/fzf-dreamcoder-light.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Light — fzf
export FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS:-} --color=bg:#f3eadc,bg+:#fff7ea,fg:#17120d,fg+:#17120d,hl:#824f16,hl+:#824f16,info:#0d4a68,marker:#315b31,prompt:#824f16,spinner:#57478b,pointer:#a7471c,header:#352e22,border:#8a7358,label:#352e22,query:#17120d,gutter:#f3eadc,scrollbar:#8a7358,separator:#8a7358,preview-bg:#f3eadc,preview-border:#8a7358"
2 changes: 1 addition & 1 deletion DreamcoderThemes/dreamcoder/fzf-dreamcoder-night.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Dark Night — fzf
export FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS:-} --color=bg:#000000,bg+:#0b0b0d,fg:#c6c6c6,fg+:#c6c6c6,hl:#a4afee,hl+:#a4afee,info:#62b9e2,marker:#43b48b,prompt:#a4afee,spinner:#b48ce9,pointer:#b48ce9,header:#ababab,border:#5c5c5c,label:#ababab,query:#c6c6c6,gutter:#0b0b0d,scrollbar:#5c5c5c,separator:#5c5c5c,preview-bg:#0b0b0d,preview-border:#5c5c5c"
2 changes: 1 addition & 1 deletion DreamcoderThemes/dreamcoder/ls-colors-dreamcoder-dark.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Dark — LS_COLORS / eza
export LS_COLORS='di=38;2;165;180;252:ex=38;2;212;181;253:ln=38;2;125;211;252:or=48;2;251;191;36;38;2;0;0;0:so=38;2;52;211;153:pi=38;2;251;191;36:bd=38;2;251;133;133:cd=38;2;251;133;133:su=48;2;0;0;0;38;2;212;181;253:sg=48;2;0;0;0;38;2;212;181;253:tw=38;2;165;180;252;48;2;11;11;11:ow=38;2;165;180;252;48;2;11;11;11:st=38;2;165;180;252;48;2;11;11;11:*.sh=38;2;212;181;253:*.bash=38;2;212;181;253:*.zsh=38;2;212;181;253:*.fish=38;2;212;181;253:*.py=38;2;212;181;253:*.rb=38;2;212;181;253:*.rs=38;2;212;181;253:*.go=38;2;212;181;253:*.ts=38;2;212;181;253:*.js=38;2;212;181;253:*.jpg=38;2;216;180;254:*.jpeg=38;2;216;180;254:*.png=38;2;216;180;254:*.gif=38;2;216;180;254:*.bmp=38;2;216;180;254:*.svg=38;2;216;180;254:*.webp=38;2;216;180;254:*.ico=38;2;216;180;254:*.mp3=38;2;216;180;254:*.wav=38;2;216;180;254:*.flac=38;2;216;180;254:*.ogg=38;2;216;180;254:*.m4a=38;2;216;180;254:*.mp4=38;2;216;180;254:*.mkv=38;2;216;180;254:*.webm=38;2;216;180;254:*.mov=38;2;216;180;254:*.pdf=38;2;199;199;199:*.doc=38;2;199;199;199:*.docx=38;2;199;199;199:*.odt=38;2;199;199;199:*.xls=38;2;199;199;199:*.xlsx=38;2;199;199;199:*.ppt=38;2;199;199;199:*.pptx=38;2;199;199;199:*.txt=38;2;199;199;199:*.cfg=38;2;199;199;199:*.conf=38;2;199;199;199:*.json=38;2;199;199;199:*.yaml=38;2;199;199;199:*.yml=38;2;199;199;199:*.toml=38;2;199;199;199:*.xml=38;2;199;199;199:*.css=38;2;199;199;199:*.html=38;2;199;199;199:*.c=38;2;199;199;199:*.h=38;2;199;199;199:*.cpp=38;2;199;199;199:*.hpp=38;2;199;199;199:*.swp=38;2;199;199;199:*.swo=38;2;199;199;199:*.bak=38;2;199;199;199:*.orig=38;2;199;199;199:*.md=#A5B4FC'
export EZA_COLORS='di=38;2;165;180;252:ex=38;2;212;181;253:ln=38;2;125;211;252:so=38;2;52;211;153:pi=38;2;251;191;36:bd=38;2;251;133;133:cd=38;2;251;133;133:uw=38;2;251;191;36:ux=38;2;251;133;133:gwx=38;2;251;191;36:*.md=#A5B4FC'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Light — LS_COLORS / eza
export LS_COLORS='di=38;2;130;79;22:ex=38;2;167;71;28:ln=38;2;13;74;104:or=48;2;101;67;0;38;2;243;234;220:so=38;2;49;91;49:pi=38;2;101;67;0:bd=38;2;132;47;36:cd=38;2;132;47;36:su=48;2;243;234;220;38;2;167;71;28:sg=48;2;243;234;220;38;2;167;71;28:tw=38;2;130;79;22;48;2;255;247;234:ow=38;2;130;79;22;48;2;255;247;234:st=38;2;130;79;22;48;2;255;247;234:*.tar=38;2;87;71;139:*.tgz=38;2;87;71;139:*.gz=38;2;87;71;139:*.bz2=38;2;87;71;139:*.xz=38;2;87;71;139:*.zst=38;2;87;71;139:*.zip=38;2;87;71;139:*.7z=38;2;87;71;139:*.rar=38;2;87;71;139:*.iso=38;2;87;71;139:*.dmg=38;2;87;71;139:*.jpg=38;2;125;62;100:*.jpeg=38;2;125;62;100:*.png=38;2;125;62;100:*.gif=38;2;125;62;100:*.bmp=38;2;125;62;100:*.svg=38;2;125;62;100:*.webp=38;2;125;62;100:*.ico=38;2;125;62;100:*.mp3=38;2;125;62;100:*.wav=38;2;125;62;100:*.flac=38;2;125;62;100:*.ogg=38;2;125;62;100:*.m4a=38;2;125;62;100:*.mp4=38;2;125;62;100:*.mkv=38;2;125;62;100:*.webm=38;2;125;62;100:*.mov=38;2;125;62;100:*.pdf=38;2;53;46;34:*.doc=38;2;53;46;34:*.docx=38;2;53;46;34:*.odt=38;2;53;46;34:*.xls=38;2;53;46;34:*.xlsx=38;2;53;46;34:*.ppt=38;2;53;46;34:*.pptx=38;2;53;46;34:*.txt=38;2;53;46;34:*.cfg=38;2;53;46;34:*.conf=38;2;53;46;34:*.json=38;2;53;46;34:*.yaml=38;2;53;46;34:*.yml=38;2;53;46;34:*.toml=38;2;53;46;34:*.xml=38;2;53;46;34:*.css=38;2;53;46;34:*.html=38;2;53;46;34:*.c=38;2;53;46;34:*.h=38;2;53;46;34:*.cpp=38;2;53;46;34:*.hpp=38;2;53;46;34:*.swp=38;2;53;46;34:*.swo=38;2;53;46;34:*.bak=38;2;53;46;34:*.orig=38;2;53;46;34:*.sh=38;2;167;71;28:*.bash=38;2;167;71;28:*.zsh=38;2;167;71;28:*.fish=38;2;167;71;28:*.py=38;2;167;71;28:*.rb=38;2;167;71;28:*.rs=38;2;167;71;28:*.go=38;2;167;71;28:*.ts=38;2;167;71;28:*.js=38;2;167;71;28:*.md=#824f16'
export EZA_COLORS='di=38;2;130;79;22:ex=38;2;167;71;28:ln=38;2;13;74;104:so=38;2;49;91;49:pi=38;2;101;67;0:bd=38;2;132;47;36:cd=38;2;132;47;36:uw=38;2;101;67;0:ux=38;2;132;47;36:gwx=38;2;101;67;0:*.md=#824f16'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Dark Night — LS_COLORS / eza
export LS_COLORS='di=38;2;164;175;238:ex=38;2;180;140;233:ln=38;2;98;185;226:or=48;2;209;161;38;38;2;0;0;0:so=38;2;67;180;139:pi=38;2;209;161;38:bd=38;2;232;132;132:cd=38;2;232;132;132:su=48;2;0;0;0;38;2;180;140;233:sg=48;2;0;0;0;38;2;180;140;233:tw=38;2;164;175;238;48;2;9;9;9:ow=38;2;164;175;238;48;2;9;9;9:st=38;2;164;175;238;48;2;9;9;9:*.sh=38;2;180;140;233:*.bash=38;2;180;140;233:*.zsh=38;2;180;140;233:*.fish=38;2;180;140;233:*.py=38;2;180;140;233:*.rb=38;2;180;140;233:*.rs=38;2;180;140;233:*.go=38;2;180;140;233:*.ts=38;2;180;140;233:*.js=38;2;180;140;233:*.jpg=38;2;185;139;235:*.jpeg=38;2;185;139;235:*.png=38;2;185;139;235:*.gif=38;2;185;139;235:*.bmp=38;2;185;139;235:*.svg=38;2;185;139;235:*.webp=38;2;185;139;235:*.ico=38;2;185;139;235:*.mp3=38;2;185;139;235:*.wav=38;2;185;139;235:*.flac=38;2;185;139;235:*.ogg=38;2;185;139;235:*.m4a=38;2;185;139;235:*.mp4=38;2;185;139;235:*.mkv=38;2;185;139;235:*.webm=38;2;185;139;235:*.mov=38;2;185;139;235:*.pdf=38;2;171;171;171:*.doc=38;2;171;171;171:*.docx=38;2;171;171;171:*.odt=38;2;171;171;171:*.xls=38;2;171;171;171:*.xlsx=38;2;171;171;171:*.ppt=38;2;171;171;171:*.pptx=38;2;171;171;171:*.txt=38;2;171;171;171:*.cfg=38;2;171;171;171:*.conf=38;2;171;171;171:*.json=38;2;171;171;171:*.yaml=38;2;171;171;171:*.yml=38;2;171;171;171:*.toml=38;2;171;171;171:*.xml=38;2;171;171;171:*.css=38;2;171;171;171:*.html=38;2;171;171;171:*.c=38;2;171;171;171:*.h=38;2;171;171;171:*.cpp=38;2;171;171;171:*.hpp=38;2;171;171;171:*.swp=38;2;171;171;171:*.swo=38;2;171;171;171:*.bak=38;2;171;171;171:*.orig=38;2;171;171;171:*.md=#a4afee'
export EZA_COLORS='di=38;2;164;175;238:ex=38;2;180;140;233:ln=38;2;98;185;226:so=38;2;67;180;139:pi=38;2;209;161;38:bd=38;2;232;132;132:cd=38;2;232;132;132:uw=38;2;209;161;38:ux=38;2;232;132;132:gwx=38;2;209;161;38:*.md=#a4afee'
2 changes: 1 addition & 1 deletion DreamcoderThemes/fzf-dreamcoder.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Dark — fzf
export FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS:-} --color=bg:#000000,bg+:#0D0D0F,fg:#E6E6E6,fg+:#E6E6E6,hl:#A5B4FC,hl+:#A5B4FC,info:#7DD3FC,marker:#34D399,prompt:#A5B4FC,spinner:#D4B5FD,pointer:#D4B5FD,header:#C7C7C7,border:#6B6B6B,label:#C7C7C7,query:#E6E6E6,gutter:#0D0D0F,scrollbar:#6B6B6B,separator:#6B6B6B,preview-bg:#0D0D0F,preview-border:#6B6B6B"
2 changes: 1 addition & 1 deletion DreamcoderThemes/ls-colors-dreamcoder.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
# Sourced snippet: never set shell options here.
# Dreamcoder Dark — LS_COLORS / eza
export LS_COLORS='di=38;2;165;180;252:ex=38;2;212;181;253:ln=38;2;125;211;252:or=48;2;251;191;36;38;2;0;0;0:so=38;2;52;211;153:pi=38;2;251;191;36:bd=38;2;251;133;133:cd=38;2;251;133;133:su=48;2;0;0;0;38;2;212;181;253:sg=48;2;0;0;0;38;2;212;181;253:tw=38;2;165;180;252;48;2;11;11;11:ow=38;2;165;180;252;48;2;11;11;11:st=38;2;165;180;252;48;2;11;11;11:*.sh=38;2;212;181;253:*.bash=38;2;212;181;253:*.zsh=38;2;212;181;253:*.fish=38;2;212;181;253:*.py=38;2;212;181;253:*.rb=38;2;212;181;253:*.rs=38;2;212;181;253:*.go=38;2;212;181;253:*.ts=38;2;212;181;253:*.js=38;2;212;181;253:*.jpg=38;2;216;180;254:*.jpeg=38;2;216;180;254:*.png=38;2;216;180;254:*.gif=38;2;216;180;254:*.bmp=38;2;216;180;254:*.svg=38;2;216;180;254:*.webp=38;2;216;180;254:*.ico=38;2;216;180;254:*.mp3=38;2;216;180;254:*.wav=38;2;216;180;254:*.flac=38;2;216;180;254:*.ogg=38;2;216;180;254:*.m4a=38;2;216;180;254:*.mp4=38;2;216;180;254:*.mkv=38;2;216;180;254:*.webm=38;2;216;180;254:*.mov=38;2;216;180;254:*.pdf=38;2;199;199;199:*.doc=38;2;199;199;199:*.docx=38;2;199;199;199:*.odt=38;2;199;199;199:*.xls=38;2;199;199;199:*.xlsx=38;2;199;199;199:*.ppt=38;2;199;199;199:*.pptx=38;2;199;199;199:*.txt=38;2;199;199;199:*.cfg=38;2;199;199;199:*.conf=38;2;199;199;199:*.json=38;2;199;199;199:*.yaml=38;2;199;199;199:*.yml=38;2;199;199;199:*.toml=38;2;199;199;199:*.xml=38;2;199;199;199:*.css=38;2;199;199;199:*.html=38;2;199;199;199:*.c=38;2;199;199;199:*.h=38;2;199;199;199:*.cpp=38;2;199;199;199:*.hpp=38;2;199;199;199:*.swp=38;2;199;199;199:*.swo=38;2;199;199;199:*.bak=38;2;199;199;199:*.orig=38;2;199;199;199:*.md=#A5B4FC'
export EZA_COLORS='di=38;2;165;180;252:ex=38;2;212;181;253:ln=38;2;125;211;252:so=38;2;52;211;153:pi=38;2;251;191;36:bd=38;2;251;133;133:cd=38;2;251;133;133:uw=38;2;251;191;36:ux=38;2;251;133;133:gwx=38;2;251;191;36:*.md=#A5B4FC'
2 changes: 1 addition & 1 deletion src/dreamcoder_theme/renderers_extra_bat_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def bat_content(c: dict[str, str]) -> str:
theme = f"Dreamcoder-{'Night' if 'Night' in c.get('name', '') else mode_name.title()}"
return (
"#!/usr/bin/env bash\n"
"set -euo pipefail\n"
"# Sourced snippet: never set shell options here.\n"
f"# {c['name']} — Bat theme; run 'bat cache --build' after installing the tmTheme.\n"
f'export BAT_THEME="{theme}"\n'
'export BAT_STYLE="auto,changes,header,grid"\n'
Expand Down
4 changes: 2 additions & 2 deletions src/dreamcoder_theme/renderers_extra_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def g(key: str) -> str:
"gwx": _fg(g("warning")),
"*.md": g("accent"),
}
return f"#!/usr/bin/env bash\nset -euo pipefail\n# {c['name']} — LS_COLORS / eza\nexport LS_COLORS='{':'.join(entries)}'\nexport EZA_COLORS='{':'.join(f'{k}={v}' for k, v in eza.items())}'\n"
return f"#!/usr/bin/env bash\n# Sourced snippet: never set shell options here.\n# {c['name']} — LS_COLORS / eza\nexport LS_COLORS='{':'.join(entries)}'\nexport EZA_COLORS='{':'.join(f'{k}={v}' for k, v in eza.items())}'\n"


def fzf_content(c: dict[str, str]) -> str:
Expand Down Expand Up @@ -218,7 +218,7 @@ def fzf_content(c: dict[str, str]) -> str:
f"preview-bg:{preview_bg}",
f"preview-border:{c['border']}",
]
return f'#!/usr/bin/env bash\nset -euo pipefail\n# {c["name"]} — fzf\nexport FZF_DEFAULT_OPTS="${{FZF_DEFAULT_OPTS:-}} --color={",".join(parts)}"\n'
return f'#!/usr/bin/env bash\n# Sourced snippet: never set shell options here.\n# {c["name"]} — fzf\nexport FZF_DEFAULT_OPTS="${{FZF_DEFAULT_OPTS:-}} --color={",".join(parts)}"\n'


# --- Hexagonal-architecture-v2: adjacent immutable registrations (design §5) ---
Expand Down
11 changes: 11 additions & 0 deletions tests/shell/test_sourced_shell_lib.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bats
# ============================================================================
# Files under DreamcoderShell/.config/shell are sourced by the interactive
# .zshrc and .bashrc; they must never turn on errexit/nounset/pipefail.
# ============================================================================

@test "sourcing every shell lib file leaves bash options untouched" {
run bash -c 'for f in DreamcoderShell/.config/shell/*/*.sh; do source "$f" >/dev/null 2>&1; done
shopt -qo errexit && echo errexit; shopt -qo nounset && echo nounset; shopt -qo pipefail && echo pipefail; echo done'
[ "$output" = "done" ]
}
27 changes: 27 additions & 0 deletions tests/test_sourced_snippets_shell_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Snippets meant to be ``source``d must never change the caller's shell options.

``.zshrc`` sources the LS_COLORS, fzf and bat snippets directly; a
``set -euo pipefail`` inside them turned errexit/nounset on in the interactive
shell, so the first failing command closed the terminal.
"""

from __future__ import annotations

import re

import pytest

from dreamcoder_theme.palette import load_variants
from dreamcoder_theme.palette_tokens import VARIANTS as DEFAULT_VARIANTS
from dreamcoder_theme.renderers_extra_bat_delta import bat_content
from dreamcoder_theme.renderers_extra_shell import fzf_content, ls_colors_content
from dreamcoder_theme.settings import theme_paths

SHELL_OPTION = re.compile(r"^\s*set\s+[-+][a-z]", re.MULTILINE)


@pytest.mark.parametrize("render", [ls_colors_content, fzf_content, bat_content])
@pytest.mark.parametrize("mode", ["light", "dark"])
def test_sourced_snippet_sets_no_shell_options(render, mode):
palette = load_variants(DEFAULT_VARIANTS, theme_paths().tokens_file)[mode]
assert not SHELL_OPTION.search(render(palette))