batipanel 0.4.30 → 0.4.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/VERSION +1 -1
- package/install.sh +186 -34
- package/lib/layout.sh +48 -23
- package/lib/session.sh +3 -2
- package/lib/shell-setup.sh +17 -8
- package/lib/themes-bash.sh +3 -2
- package/lib/themes.sh +49 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -445,10 +445,22 @@ All optional tools are auto-installed when possible. Missing tools gracefully fa
|
|
|
445
445
|
|
|
446
446
|
| Platform | Supported Terminals |
|
|
447
447
|
|----------|---------------------|
|
|
448
|
-
| **macOS** |
|
|
448
|
+
| **macOS** | Terminal.app, iTerm2, Alacritty, Kitty, WezTerm, Warp |
|
|
449
449
|
| **Linux** | GNOME Terminal, Konsole, Alacritty, Kitty, WezTerm, xterm |
|
|
450
450
|
| **Windows** | Windows Terminal + WSL2 |
|
|
451
451
|
|
|
452
|
+
### macOS Terminal.app (built-in)
|
|
453
|
+
|
|
454
|
+
batipanel works out of the box with macOS's built-in Terminal. The installer automatically:
|
|
455
|
+
|
|
456
|
+
- Installs **Nerd Font** (MesloLGS NF) via Homebrew
|
|
457
|
+
- Sets the font on your Terminal profile via `osascript`
|
|
458
|
+
- Applies **theme colors** (background, text, cursor) to your profile
|
|
459
|
+
|
|
460
|
+
All layouts, panels, keyboard shortcuts, 256-color themes, Powerline arrows, and session resume work fully.
|
|
461
|
+
|
|
462
|
+
> **Want true color (24-bit)?** Use [iTerm2](https://iterm2.com) for the richest color experience. Terminal.app supports 256 colors which covers all themes well.
|
|
463
|
+
|
|
452
464
|
<details>
|
|
453
465
|
<summary><b>Troubleshooting</b></summary>
|
|
454
466
|
|
|
@@ -458,6 +470,8 @@ All optional tools are auto-installed when possible. Missing tools gracefully fa
|
|
|
458
470
|
|
|
459
471
|
**"claude CLI not installed"?** Run `curl -fsSL https://claude.ai/install.sh | bash`. Everything else still works without it.
|
|
460
472
|
|
|
473
|
+
**Powerline arrows showing as ">"?** Make sure your terminal font is set to a Nerd Font (e.g., MesloLGS NF). On macOS, the installer sets this automatically.
|
|
474
|
+
|
|
461
475
|
**WSL clipboard not working?** Run `sudo apt install xclip`.
|
|
462
476
|
|
|
463
477
|
**Navigation**: Use `Alt + h/j/k/l` to switch panels, `Alt + f` to zoom, mouse click to select.
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.4.
|
|
1
|
+
0.4.32
|
package/install.sh
CHANGED
|
@@ -153,6 +153,18 @@ if tmux -f /dev/null new-session -d -s _bp_smoke -x 10 -y 5 2>/dev/null; then
|
|
|
153
153
|
_tmux_smoke_ok=1
|
|
154
154
|
fi
|
|
155
155
|
|
|
156
|
+
# if smoke test failed, clean stale socket and retry (common on macOS)
|
|
157
|
+
if [ "$_tmux_smoke_ok" = "0" ]; then
|
|
158
|
+
tmux kill-server 2>/dev/null || true
|
|
159
|
+
rm -rf "/tmp/tmux-$(id -u)/" "/private/tmp/tmux-$(id -u)/" 2>/dev/null || true
|
|
160
|
+
sleep 0.3
|
|
161
|
+
if tmux -f /dev/null new-session -d -s _bp_smoke -x 10 -y 5 2>/dev/null; then
|
|
162
|
+
tmux kill-session -t _bp_smoke 2>/dev/null || true
|
|
163
|
+
_tmux_smoke_ok=1
|
|
164
|
+
echo " Cleared stale tmux socket — tmux is working now."
|
|
165
|
+
fi
|
|
166
|
+
fi
|
|
167
|
+
|
|
156
168
|
if [ "$_tmux_smoke_ok" = "0" ]; then
|
|
157
169
|
echo ""
|
|
158
170
|
echo "WARNING: tmux is installed but fails to start (server exited unexpectedly)."
|
|
@@ -162,9 +174,9 @@ if [ "$_tmux_smoke_ok" = "0" ]; then
|
|
|
162
174
|
rm -f "$BATIPANEL_HOME/bin/tmux"
|
|
163
175
|
fi
|
|
164
176
|
if [ "$OS" = "Darwin" ]; then
|
|
165
|
-
echo "
|
|
177
|
+
echo " Try: brew reinstall tmux"
|
|
166
178
|
else
|
|
167
|
-
echo "
|
|
179
|
+
echo " Try: sudo apt install --reinstall tmux"
|
|
168
180
|
fi
|
|
169
181
|
# re-check after removing mamba wrapper
|
|
170
182
|
if command -v tmux &>/dev/null && tmux -f /dev/null new-session -d -s _bp_smoke2 -x 10 -y 5 2>/dev/null; then
|
|
@@ -512,6 +524,8 @@ fi
|
|
|
512
524
|
|
|
513
525
|
# kill stale tmux server so new config takes effect
|
|
514
526
|
tmux kill-server 2>/dev/null || true
|
|
527
|
+
# clean stale socket (dead server leaves socket behind, blocks new sessions)
|
|
528
|
+
rm -rf "/tmp/tmux-$(id -u)/" "/private/tmp/tmux-$(id -u)/" 2>/dev/null || true
|
|
515
529
|
|
|
516
530
|
# clean ~/.tmux.conf (remove ALL old batipanel lines, then add fresh)
|
|
517
531
|
BATIPANEL_SOURCE_LINE="source-file $BATIPANEL_HOME/config/tmux.conf"
|
|
@@ -555,7 +569,7 @@ esac
|
|
|
555
569
|
|
|
556
570
|
BATIPANEL_ALIAS="alias batipanel='bash \"$BATIPANEL_HOME/bin/start.sh\"'"
|
|
557
571
|
# b is a function (not alias) so theme changes can auto-reload the prompt
|
|
558
|
-
SHORT_FUNC="b() { bash \"$BATIPANEL_HOME/bin/start.sh\" \"\$@\"; if [[ \"\${1:-}\" == \"theme\" ||
|
|
572
|
+
SHORT_FUNC="b() { bash \"$BATIPANEL_HOME/bin/start.sh\" \"\$@\"; if [[ \"\${1:-}\" == \"theme\" && -n \"\${2:-}\" ]] || [[ \"\${1:-}\" == \"config\" && \"\${2:-}\" == \"theme\" && -n \"\${3:-}\" ]]; then if [ -n \"\${ZSH_VERSION:-}\" ]; then local _pf=\"$BATIPANEL_HOME/config/zsh-prompt.zsh\"; [ -f \"\$_pf\" ] && source \"\$_pf\"; else local _pf=\"$BATIPANEL_HOME/config/bash-prompt.sh\"; [ -f \"\$_pf\" ] && source \"\$_pf\"; fi; fi; }"
|
|
559
573
|
|
|
560
574
|
# Always register 'batipanel' alias
|
|
561
575
|
if grep -q "alias batipanel=" "$SHELL_RC" 2>/dev/null; then
|
|
@@ -614,9 +628,13 @@ if [ "$NEED_LOCAL_BIN_PATH" = "1" ]; then
|
|
|
614
628
|
fi
|
|
615
629
|
|
|
616
630
|
# === 8b. enable powerline glyphs by default ===
|
|
631
|
+
# only auto-enable on terminals known to support Nerd Fonts well
|
|
632
|
+
# Apple Terminal: defer to batipanel profile setup (sets BATIPANEL_ICONS=1 after font confirmed)
|
|
617
633
|
if ! grep -qF 'BATIPANEL_ICONS' "$SHELL_RC" 2>/dev/null; then
|
|
618
|
-
|
|
619
|
-
|
|
634
|
+
if [ "${TERM_PROGRAM:-}" != "Apple_Terminal" ]; then
|
|
635
|
+
echo 'export BATIPANEL_ICONS="1"' >> "$SHELL_RC"
|
|
636
|
+
echo " Enabled powerline glyphs (BATIPANEL_ICONS=1)"
|
|
637
|
+
fi
|
|
620
638
|
fi
|
|
621
639
|
|
|
622
640
|
# === 9. register tab completion ===
|
|
@@ -648,11 +666,41 @@ else
|
|
|
648
666
|
fi
|
|
649
667
|
fi
|
|
650
668
|
|
|
651
|
-
# === 9b. install Nerd Font +
|
|
669
|
+
# === 9b. install Nerd Font + configure terminal ===
|
|
670
|
+
_install_nerd_font_linux() {
|
|
671
|
+
local font_dir="$HOME/.local/share/fonts"
|
|
672
|
+
# skip if already installed
|
|
673
|
+
if ls "$font_dir"/MesloLGS* &>/dev/null 2>&1; then
|
|
674
|
+
return 0
|
|
675
|
+
fi
|
|
676
|
+
echo " Installing Nerd Font (MesloLGS NF) for powerline glyphs..."
|
|
677
|
+
mkdir -p "$font_dir"
|
|
678
|
+
local base_url="https://github.com/romkatv/powerlevel10k-media/raw/master"
|
|
679
|
+
local fonts=(
|
|
680
|
+
"MesloLGS NF Regular.ttf"
|
|
681
|
+
"MesloLGS NF Bold.ttf"
|
|
682
|
+
"MesloLGS NF Italic.ttf"
|
|
683
|
+
"MesloLGS NF Bold Italic.ttf"
|
|
684
|
+
)
|
|
685
|
+
for f in "${fonts[@]}"; do
|
|
686
|
+
local encoded="${f// /%20}"
|
|
687
|
+
curl -fsSL "$base_url/$encoded" -o "$font_dir/$f" 2>/dev/null || true
|
|
688
|
+
done
|
|
689
|
+
# rebuild font cache
|
|
690
|
+
if command -v fc-cache &>/dev/null; then
|
|
691
|
+
fc-cache -f "$font_dir" 2>/dev/null || true
|
|
692
|
+
fi
|
|
693
|
+
echo " Nerd Font installed to $font_dir"
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
if [ "$OS" = "Linux" ]; then
|
|
697
|
+
_install_nerd_font_linux
|
|
698
|
+
fi
|
|
699
|
+
|
|
652
700
|
if [ "$OS" = "Darwin" ]; then
|
|
653
701
|
echo ""
|
|
654
702
|
|
|
655
|
-
# install Nerd Font
|
|
703
|
+
# install Nerd Font via Homebrew
|
|
656
704
|
if command -v brew &>/dev/null; then
|
|
657
705
|
if ! brew list --cask font-meslo-lg-nerd-font &>/dev/null 2>&1; then
|
|
658
706
|
echo "Installing Nerd Font (MesloLGS NF) for powerline glyphs..."
|
|
@@ -660,18 +708,123 @@ if [ "$OS" = "Darwin" ]; then
|
|
|
660
708
|
fi
|
|
661
709
|
fi
|
|
662
710
|
|
|
663
|
-
#
|
|
711
|
+
# auto-configure Apple Terminal: create/update "batipanel" profile
|
|
664
712
|
if [ "${TERM_PROGRAM:-}" = "Apple_Terminal" ]; then
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
713
|
+
_bp_profile="batipanel"
|
|
714
|
+
_current_profile=$(defaults read com.apple.Terminal "Default Window Settings" 2>/dev/null || echo "Basic")
|
|
715
|
+
|
|
716
|
+
# hex to AppleScript RGB helper
|
|
717
|
+
_hex_to_applescript_rgb() {
|
|
718
|
+
local hex="${1#\#}"
|
|
719
|
+
local r=$((16#${hex:0:2}))
|
|
720
|
+
local g=$((16#${hex:2:2}))
|
|
721
|
+
local b=$((16#${hex:4:2}))
|
|
722
|
+
echo "$((r * 257)), $((g * 257)), $((b * 257))"
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
# get theme colors
|
|
726
|
+
_bp_theme="${BATIPANEL_THEME:-default}"
|
|
727
|
+
_bp_term_colors=""
|
|
728
|
+
if declare -f _get_theme_terminal_colors &>/dev/null; then
|
|
729
|
+
_bp_term_colors=$(_get_theme_terminal_colors "$_bp_theme")
|
|
730
|
+
else
|
|
731
|
+
_bp_term_colors="#1e1e2e #cdd6f4 #f5e0dc blue cyan green magenta"
|
|
732
|
+
fi
|
|
733
|
+
read -r _bp_bg _bp_fg _bp_cursor _ <<< "$_bp_term_colors"
|
|
734
|
+
|
|
735
|
+
# create or update the batipanel profile
|
|
736
|
+
_setup_bp_profile() {
|
|
737
|
+
echo " Setting up Apple Terminal profile: ${_bp_profile}..."
|
|
738
|
+
|
|
739
|
+
# create profile by duplicating current one (inherits encoding, shell settings)
|
|
740
|
+
osascript <<APPLESCRIPT 2>/dev/null || true
|
|
741
|
+
tell application "Terminal"
|
|
742
|
+
-- duplicate current profile as base if batipanel doesn't exist yet
|
|
743
|
+
if not (exists settings set "${_bp_profile}") then
|
|
744
|
+
set baseProfile to settings set "${_current_profile}"
|
|
745
|
+
set newProfile to make new settings set with properties {name:"${_bp_profile}"}
|
|
746
|
+
end if
|
|
747
|
+
end tell
|
|
748
|
+
APPLESCRIPT
|
|
749
|
+
|
|
750
|
+
# set Nerd Font (try v3, v2, mono variants)
|
|
751
|
+
local _nf_applied=false
|
|
752
|
+
for _nf_name in "MesloLGSNF-Regular" "MesloLGSNerdFont-Regular" "MesloLGS-NF-Regular"; do
|
|
753
|
+
if osascript -e "tell application \"Terminal\" to set font name of settings set \"${_bp_profile}\" to \"${_nf_name}\"" 2>/dev/null; then
|
|
754
|
+
_nf_applied=true
|
|
755
|
+
break
|
|
756
|
+
fi
|
|
757
|
+
done
|
|
758
|
+
if [ "$_nf_applied" = true ]; then
|
|
759
|
+
# font confirmed — enable powerline glyphs
|
|
760
|
+
if ! grep -qF 'BATIPANEL_ICONS' "$SHELL_RC" 2>/dev/null; then
|
|
761
|
+
echo 'export BATIPANEL_ICONS="1"' >> "$SHELL_RC"
|
|
762
|
+
fi
|
|
670
763
|
else
|
|
671
|
-
echo "
|
|
764
|
+
echo " Warning: Could not set Nerd Font. Powerline glyphs may not render."
|
|
765
|
+
echo " Install manually: brew install --cask font-meslo-lg-nerd-font"
|
|
672
766
|
fi
|
|
767
|
+
osascript -e "tell application \"Terminal\" to set font size of settings set \"${_bp_profile}\" to 13" 2>/dev/null || true
|
|
768
|
+
|
|
769
|
+
# apply theme colors to the batipanel profile
|
|
770
|
+
if [[ "$_bp_bg" =~ ^# ]]; then
|
|
771
|
+
local bg_rgb fg_rgb cursor_rgb
|
|
772
|
+
bg_rgb=$(_hex_to_applescript_rgb "$_bp_bg")
|
|
773
|
+
fg_rgb=$(_hex_to_applescript_rgb "$_bp_fg")
|
|
774
|
+
cursor_rgb=$(_hex_to_applescript_rgb "$_bp_cursor")
|
|
775
|
+
osascript <<APPLESCRIPT 2>/dev/null || true
|
|
776
|
+
tell application "Terminal"
|
|
777
|
+
set background color of settings set "${_bp_profile}" to {${bg_rgb}}
|
|
778
|
+
set normal text color of settings set "${_bp_profile}" to {${fg_rgb}}
|
|
779
|
+
set cursor color of settings set "${_bp_profile}" to {${cursor_rgb}}
|
|
780
|
+
end tell
|
|
781
|
+
APPLESCRIPT
|
|
782
|
+
fi
|
|
783
|
+
|
|
784
|
+
# set as default profile for new windows
|
|
785
|
+
osascript <<APPLESCRIPT 2>/dev/null || true
|
|
786
|
+
tell application "Terminal"
|
|
787
|
+
set default settings to settings set "${_bp_profile}"
|
|
788
|
+
set startup settings to settings set "${_bp_profile}"
|
|
789
|
+
end tell
|
|
790
|
+
APPLESCRIPT
|
|
791
|
+
|
|
792
|
+
# apply to current window
|
|
793
|
+
osascript <<APPLESCRIPT 2>/dev/null || true
|
|
794
|
+
tell application "Terminal"
|
|
795
|
+
set w to front window
|
|
796
|
+
set current settings of w to settings set "${_bp_profile}"
|
|
797
|
+
end tell
|
|
798
|
+
APPLESCRIPT
|
|
799
|
+
echo " Profile '${_bp_profile}' configured and set as default"
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
if [ "$_current_profile" = "$_bp_profile" ]; then
|
|
803
|
+
# already using batipanel profile — update it silently
|
|
804
|
+
_setup_bp_profile
|
|
673
805
|
else
|
|
674
|
-
|
|
806
|
+
# first install or different profile — ask user
|
|
807
|
+
echo ""
|
|
808
|
+
echo " Apple Terminal detected (current profile: ${_current_profile})"
|
|
809
|
+
echo " batipanel can create a dedicated '${_bp_profile}' profile with:"
|
|
810
|
+
echo " - Nerd Font (MesloLGS) for powerline glyphs"
|
|
811
|
+
echo " - Dark theme colors"
|
|
812
|
+
echo ""
|
|
813
|
+
printf " Apply batipanel Terminal profile? [Y/n] "
|
|
814
|
+
_bp_answer=""
|
|
815
|
+
if [ -t 0 ]; then
|
|
816
|
+
read -r _bp_answer
|
|
817
|
+
else
|
|
818
|
+
read -r _bp_answer < /dev/tty 2>/dev/null || _bp_answer="y"
|
|
819
|
+
fi
|
|
820
|
+
case "$_bp_answer" in
|
|
821
|
+
[nN]*)
|
|
822
|
+
echo " Skipped. You can set your font to a Nerd Font manually."
|
|
823
|
+
;;
|
|
824
|
+
*)
|
|
825
|
+
_setup_bp_profile
|
|
826
|
+
;;
|
|
827
|
+
esac
|
|
675
828
|
fi
|
|
676
829
|
fi
|
|
677
830
|
fi
|
|
@@ -745,24 +898,19 @@ echo " b config layout 7panel # Change default layout"
|
|
|
745
898
|
echo " b theme # List/change color themes"
|
|
746
899
|
echo ""
|
|
747
900
|
if [ "${TERM_PROGRAM:-}" = "Apple_Terminal" ]; then
|
|
748
|
-
echo "
|
|
901
|
+
echo "Apple Terminal: using 'batipanel' profile with Nerd Font + theme colors."
|
|
749
902
|
echo ""
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
echo " 3. Type: b"
|
|
755
|
-
else
|
|
756
|
-
echo "Next steps:"
|
|
757
|
-
echo " 1. Install iTerm2:"
|
|
903
|
+
echo "Type: b"
|
|
904
|
+
echo ""
|
|
905
|
+
echo "Tip: For the best experience (true color, native tabs), try iTerm2:"
|
|
906
|
+
if [ ! -d "/Applications/iTerm.app" ]; then
|
|
758
907
|
if command -v brew &>/dev/null; then
|
|
759
|
-
echo "
|
|
908
|
+
echo " brew install --cask iterm2"
|
|
760
909
|
else
|
|
761
|
-
echo "
|
|
910
|
+
echo " https://iterm2.com/downloads.html"
|
|
762
911
|
fi
|
|
763
|
-
|
|
764
|
-
echo "
|
|
765
|
-
echo " 4. Type: b"
|
|
912
|
+
else
|
|
913
|
+
echo " iTerm2 is already installed — open it and type: b"
|
|
766
914
|
fi
|
|
767
915
|
else
|
|
768
916
|
echo "Tip: Set your terminal font to a Nerd Font (e.g. MesloLGS NF)"
|
|
@@ -771,10 +919,14 @@ else
|
|
|
771
919
|
echo "Type: b"
|
|
772
920
|
fi
|
|
773
921
|
|
|
774
|
-
# ===
|
|
775
|
-
#
|
|
776
|
-
if [ -
|
|
922
|
+
# === activate prompt theme ===
|
|
923
|
+
# don't exec $SHELL — it breaks /dev/tty when run from curl|bash or subshells
|
|
924
|
+
if [ -z "${npm_lifecycle_event:-}" ]; then
|
|
925
|
+
echo ""
|
|
926
|
+
echo -e "\033[1;33m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m"
|
|
927
|
+
echo -e "\033[1;33m Activate batipanel (choose one):\033[0m"
|
|
777
928
|
echo ""
|
|
778
|
-
echo "
|
|
779
|
-
|
|
929
|
+
echo -e " \033[1;32m▶ exec \$SHELL -l\033[0m ← paste this"
|
|
930
|
+
echo -e " \033[1;32m▶ restart terminal\033[0m ← or just close & reopen"
|
|
931
|
+
echo -e "\033[1;33m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\033[0m"
|
|
780
932
|
fi
|
package/lib/layout.sh
CHANGED
|
@@ -21,30 +21,55 @@ init_layout() {
|
|
|
21
21
|
local tmux_err
|
|
22
22
|
tmux_err=$(tmux new-session -d -s "$session" -c "$project" -x 220 -y 60 2>&1) || {
|
|
23
23
|
debug_log "init_layout: first attempt failed: $tmux_err"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
debug_log "init_layout:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
24
|
+
|
|
25
|
+
# if "server exited unexpectedly", clean stale socket and retry
|
|
26
|
+
if [[ "$tmux_err" == *"server exited"* ]] || [[ "$tmux_err" == *"server"* ]]; then
|
|
27
|
+
debug_log "init_layout: cleaning stale socket and retrying"
|
|
28
|
+
tmux kill-server 2>/dev/null || true
|
|
29
|
+
rm -rf "/tmp/tmux-$(id -u)/" "/private/tmp/tmux-$(id -u)/" 2>/dev/null || true
|
|
30
|
+
sleep 0.3
|
|
31
|
+
tmux_err=$(tmux new-session -d -s "$session" -c "$project" -x 220 -y 60 2>&1) && {
|
|
32
|
+
debug_log "init_layout: succeeded after socket cleanup"
|
|
33
|
+
# fall through to success path below
|
|
34
|
+
tmux_err=""
|
|
35
|
+
}
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# if still failing, retry with safe TERM
|
|
39
|
+
if [ -n "$tmux_err" ]; then
|
|
40
|
+
debug_log "init_layout: retrying with TERM=xterm-256color"
|
|
41
|
+
tmux_err=$(TERM=xterm-256color tmux new-session -d -s "$session" -c "$project" -x 220 -y 60 2>&1) || {
|
|
42
|
+
debug_log "init_layout: all attempts failed: $tmux_err"
|
|
43
|
+
# check if session was created by a concurrent invocation
|
|
44
|
+
if tmux has-session -t "$session" 2>/dev/null; then
|
|
45
|
+
debug_log "init_layout: session already exists (concurrent creation)"
|
|
46
|
+
return 0
|
|
47
|
+
fi
|
|
48
|
+
echo -e "${RED}Failed to create tmux session '$session'${NC}"
|
|
49
|
+
# provide specific guidance based on error
|
|
50
|
+
if [[ "$tmux_err" == *"open terminal failed"* ]]; then
|
|
51
|
+
echo " Error: open terminal failed (terminfo issue)"
|
|
52
|
+
echo " Try: export TERM=xterm-256color && b $session"
|
|
53
|
+
elif [[ "$tmux_err" == *"server"* ]] || [[ "$tmux_err" == *"socket"* ]]; then
|
|
54
|
+
echo " Stale tmux socket. Tried auto-cleanup but still failing."
|
|
55
|
+
echo " Try: rm -rf /tmp/tmux-\$(id -u)/ && b $session"
|
|
56
|
+
elif [[ "$tmux_err" == *"library"* ]] || [[ "$tmux_err" == *"dylib"* ]]; then
|
|
57
|
+
echo " Library issue — try reinstalling tmux"
|
|
58
|
+
else
|
|
59
|
+
echo " tmux error: $tmux_err"
|
|
60
|
+
fi
|
|
61
|
+
return 1
|
|
62
|
+
}
|
|
63
|
+
fi
|
|
47
64
|
}
|
|
65
|
+
|
|
66
|
+
# pass parent terminal info into tmux so prompts can detect Apple Terminal etc.
|
|
67
|
+
if [ -n "${TERM_PROGRAM:-}" ]; then
|
|
68
|
+
tmux set-environment -t "$session" TERM_PROGRAM "$TERM_PROGRAM"
|
|
69
|
+
fi
|
|
70
|
+
if [ -n "${TERM_PROGRAM_VERSION:-}" ]; then
|
|
71
|
+
tmux set-environment -t "$session" TERM_PROGRAM_VERSION "$TERM_PROGRAM_VERSION"
|
|
72
|
+
fi
|
|
48
73
|
}
|
|
49
74
|
|
|
50
75
|
# Wait for shell init after pane splits
|
package/lib/session.sh
CHANGED
|
@@ -79,8 +79,9 @@ tmux_start() {
|
|
|
79
79
|
fi
|
|
80
80
|
|
|
81
81
|
echo -e " ${YELLOW}Tip:${NC} Detach with Ctrl+b d | Stop with: b stop $SESSION"
|
|
82
|
-
# attach to session (exec
|
|
83
|
-
|
|
82
|
+
# attach to session (exec hands terminal directly to tmux)
|
|
83
|
+
# -CC mode only works in iTerm2 — ignore setting in other terminals
|
|
84
|
+
if [ "${BATIPANEL_ITERM_CC:-0}" = "1" ] && [ "${TERM_PROGRAM:-}" = "iTerm.app" ]; then
|
|
84
85
|
exec tmux -CC attach -t "$SESSION"
|
|
85
86
|
else
|
|
86
87
|
exec tmux attach -t "$SESSION"
|
package/lib/shell-setup.sh
CHANGED
|
@@ -61,11 +61,16 @@ _generate_zsh_prompt() {
|
|
|
61
61
|
_bp_env="$HOME/.batipanel/config/theme-env.sh"
|
|
62
62
|
[[ -f "$_bp_env" ]] && source "$_bp_env"
|
|
63
63
|
|
|
64
|
-
# set terminal colors
|
|
65
|
-
if [[ "$TERM" != "dumb" ]] && [[
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
# set terminal colors
|
|
65
|
+
if [[ "$TERM" != "dumb" ]] && [[ -n "${BP_BG:-}" ]]; then
|
|
66
|
+
if [[ "${TERM_PROGRAM:-}" == "Apple_Terminal" ]]; then
|
|
67
|
+
# Apple Terminal: colors are set via osascript at install/theme-change time
|
|
68
|
+
:
|
|
69
|
+
else
|
|
70
|
+
printf '\e]11;%s\a' "$BP_BG"
|
|
71
|
+
printf '\e]10;%s\a' "$BP_FG"
|
|
72
|
+
printf '\e]12;%s\a' "$BP_CURSOR"
|
|
73
|
+
fi
|
|
69
74
|
fi
|
|
70
75
|
|
|
71
76
|
autoload -U colors && colors
|
|
@@ -81,7 +86,10 @@ _bp_sep='>'
|
|
|
81
86
|
case "${TERM_PROGRAM:-}" in
|
|
82
87
|
iTerm.app|WezTerm|kitty|Hyper|Alacritty|vscode) _bp_sep=$'\uE0B0' ;;
|
|
83
88
|
esac
|
|
84
|
-
|
|
89
|
+
# in tmux, only enable powerline if NOT Apple Terminal (glyphs may not render)
|
|
90
|
+
if [[ -n "${TMUX:-}" ]] && [[ "${TERM_PROGRAM:-}" != "Apple_Terminal" ]]; then
|
|
91
|
+
_bp_sep=$'\uE0B0'
|
|
92
|
+
fi
|
|
85
93
|
[[ "${BATIPANEL_ICONS:-0}" == "1" ]] && _bp_sep=$'\uE0B0'
|
|
86
94
|
|
|
87
95
|
PROMPT="%F{${BP_C_USER:-blue}}%n%f %F{${BP_C_DIR:-cyan}}%~%f\${vcs_info_msg_0_} %F{${BP_C_PROMPT:-magenta}}${_bp_sep}%f "
|
|
@@ -130,7 +138,7 @@ _setup_default_bash_prompt() {
|
|
|
130
138
|
_bp_env="$HOME/.batipanel/config/theme-env.sh"
|
|
131
139
|
[ -f "$_bp_env" ] && source "$_bp_env"
|
|
132
140
|
|
|
133
|
-
# set terminal colors
|
|
141
|
+
# set terminal colors (Apple Terminal uses osascript at install/theme-change time)
|
|
134
142
|
if [[ "$TERM" != "dumb" ]] && [[ "${TERM_PROGRAM:-}" != "Apple_Terminal" ]] && [[ -n "${BP_BG:-}" ]]; then
|
|
135
143
|
printf '\e]11;%s\a' "$BP_BG"
|
|
136
144
|
printf '\e]10;%s\a' "$BP_FG"
|
|
@@ -146,7 +154,8 @@ __batipanel_prompt() {
|
|
|
146
154
|
case "${TERM_PROGRAM:-}" in
|
|
147
155
|
iTerm.app|WezTerm|kitty|Hyper|Alacritty|vscode) _use_pl=1 ;;
|
|
148
156
|
esac
|
|
149
|
-
|
|
157
|
+
# in tmux, only enable powerline if NOT Apple Terminal
|
|
158
|
+
[[ -n "${TMUX:-}" ]] && [[ "${TERM_PROGRAM:-}" != "Apple_Terminal" ]] && _use_pl=1
|
|
150
159
|
[[ "${BATIPANEL_ICONS:-0}" == "1" ]] && _use_pl=1
|
|
151
160
|
if (( _use_pl )); then
|
|
152
161
|
sep=$'\uE0B0'
|
package/lib/themes-bash.sh
CHANGED
|
@@ -127,7 +127,7 @@ _generate_themed_prompt() {
|
|
|
127
127
|
_bp_env="\$HOME/.batipanel/config/theme-env.sh"
|
|
128
128
|
[ -f "\$_bp_env" ] && source "\$_bp_env"
|
|
129
129
|
|
|
130
|
-
# set terminal colors
|
|
130
|
+
# set terminal colors (Apple Terminal uses osascript at install/theme-change time)
|
|
131
131
|
if [[ "\$TERM" != "dumb" ]] && [[ "\${TERM_PROGRAM:-}" != "Apple_Terminal" ]] && [[ -n "\${BP_BG:-}" ]]; then
|
|
132
132
|
printf '\e]11;%s\a' "\$BP_BG"
|
|
133
133
|
printf '\e]10;%s\a' "\$BP_FG"
|
|
@@ -143,7 +143,8 @@ __batipanel_prompt() {
|
|
|
143
143
|
case "\${TERM_PROGRAM:-}" in
|
|
144
144
|
iTerm.app|WezTerm|kitty|Hyper|Alacritty|vscode) _use_pl=1 ;;
|
|
145
145
|
esac
|
|
146
|
-
|
|
146
|
+
# in tmux, only enable powerline if NOT Apple Terminal
|
|
147
|
+
[[ -n "\${TMUX:-}" ]] && [[ "\${TERM_PROGRAM:-}" != "Apple_Terminal" ]] && _use_pl=1
|
|
147
148
|
[[ "\${BATIPANEL_ICONS:-0}" == "1" ]] && _use_pl=1
|
|
148
149
|
if (( _use_pl )); then
|
|
149
150
|
sep=\$'\\uE0B0'
|
package/lib/themes.sh
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
# batipanel themes - color theme system (orchestrator)
|
|
3
3
|
# Sub-modules: themes-data.sh, themes-tmux.sh, themes-bash.sh
|
|
4
4
|
|
|
5
|
+
# apply theme colors to Apple Terminal via osascript
|
|
6
|
+
_apply_apple_terminal_colors() {
|
|
7
|
+
local bg="$1" fg="$2" cursor="$3"
|
|
8
|
+
[[ "$bg" =~ ^# ]] || return 0
|
|
9
|
+
command -v osascript &>/dev/null || return 0
|
|
10
|
+
|
|
11
|
+
# convert hex #RRGGBB to AppleScript RGB {R*257, G*257, B*257}
|
|
12
|
+
_hex_to_as_rgb() {
|
|
13
|
+
local hex="${1#\#}"
|
|
14
|
+
local r=$((16#${hex:0:2}))
|
|
15
|
+
local g=$((16#${hex:2:2}))
|
|
16
|
+
local b=$((16#${hex:4:2}))
|
|
17
|
+
echo "$((r * 257)), $((g * 257)), $((b * 257))"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
local bg_rgb fg_rgb cursor_rgb
|
|
21
|
+
bg_rgb=$(_hex_to_as_rgb "$bg")
|
|
22
|
+
fg_rgb=$(_hex_to_as_rgb "$fg")
|
|
23
|
+
cursor_rgb=$(_hex_to_as_rgb "$cursor")
|
|
24
|
+
|
|
25
|
+
# update batipanel profile if it exists (so new windows also get the colors)
|
|
26
|
+
# then apply to current window for immediate feedback
|
|
27
|
+
osascript <<APPLESCRIPT 2>/dev/null || true
|
|
28
|
+
tell application "Terminal"
|
|
29
|
+
if exists settings set "batipanel" then
|
|
30
|
+
set background color of settings set "batipanel" to {${bg_rgb}}
|
|
31
|
+
set normal text color of settings set "batipanel" to {${fg_rgb}}
|
|
32
|
+
set cursor color of settings set "batipanel" to {${cursor_rgb}}
|
|
33
|
+
end if
|
|
34
|
+
-- also apply to current window immediately
|
|
35
|
+
set w to front window
|
|
36
|
+
set background color of current settings of w to {${bg_rgb}}
|
|
37
|
+
set normal text color of current settings of w to {${fg_rgb}}
|
|
38
|
+
set cursor color of current settings of w to {${cursor_rgb}}
|
|
39
|
+
end tell
|
|
40
|
+
APPLESCRIPT
|
|
41
|
+
}
|
|
42
|
+
|
|
5
43
|
# apply theme: generate files, persist config, live reload
|
|
6
44
|
# shellcheck disable=SC2153 # BATIPANEL_HOME is set by core.sh
|
|
7
45
|
_apply_theme() {
|
|
@@ -47,13 +85,17 @@ _apply_theme() {
|
|
|
47
85
|
tmux source-file "$BATIPANEL_HOME/config/theme.conf" 2>/dev/null || true
|
|
48
86
|
fi
|
|
49
87
|
|
|
50
|
-
# live reload: apply terminal colors immediately
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
88
|
+
# live reload: apply terminal colors immediately
|
|
89
|
+
local term_colors
|
|
90
|
+
term_colors=$(_get_theme_terminal_colors "$theme")
|
|
91
|
+
local bg fg cursor
|
|
92
|
+
read -r bg fg cursor _ <<< "$term_colors"
|
|
93
|
+
|
|
94
|
+
if [[ "${TERM_PROGRAM:-}" == "Apple_Terminal" ]]; then
|
|
95
|
+
# Apple Terminal: use osascript instead of OSC sequences
|
|
96
|
+
_apply_apple_terminal_colors "$bg" "$fg" "$cursor"
|
|
97
|
+
else
|
|
98
|
+
# other terminals: OSC 10/11/12
|
|
57
99
|
printf '\e]11;%s\a' "$bg"
|
|
58
100
|
printf '\e]10;%s\a' "$fg"
|
|
59
101
|
printf '\e]12;%s\a' "$cursor"
|
package/package.json
CHANGED