batipanel 0.4.13 → 0.4.15

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.13
1
+ 0.4.15
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # batipanel shell-setup - powerline fonts, prompt theme, hostname hiding
2
+ # batipanel shell-setup - prompt theme, terminal colors, powerline fonts
3
3
 
4
4
  BATIPANEL_HOME="${BATIPANEL_HOME:-$HOME/.batipanel}"
5
5
 
@@ -26,57 +26,18 @@ install_powerline_fonts() {
26
26
  OS="$(uname -s)"
27
27
 
28
28
  # check if already installed
29
- if fc-list 2>/dev/null | grep -qi "powerline\|nerd"; then
29
+ if [ "$OS" = "Darwin" ] && [ -d "$HOME/Library/Fonts" ]; then
30
+ if ls "$HOME/Library/Fonts/"*owerline* &>/dev/null 2>&1 \
31
+ || ls "$HOME/Library/Fonts/"*erd* &>/dev/null 2>&1; then
32
+ echo " Powerline-compatible fonts already installed"
33
+ return 0
34
+ fi
35
+ elif fc-list 2>/dev/null | grep -qi "powerline\|nerd"; then
30
36
  echo " Powerline-compatible fonts already installed"
31
37
  return 0
32
38
  fi
33
39
 
34
- case "$OS" in
35
- Darwin)
36
- if has_cmd brew; then
37
- # install Nerd Font (includes powerline glyphs)
38
- brew tap homebrew/cask-fonts 2>/dev/null || true
39
- if brew install --cask font-meslo-lg-nerd-font 2>/dev/null; then
40
- echo " Installed MesloLGS Nerd Font (macOS)"
41
- else
42
- echo " Font install via brew failed, trying powerline-fonts..."
43
- _install_powerline_fonts_git
44
- fi
45
- else
46
- _install_powerline_fonts_git
47
- fi
48
- ;;
49
- Linux)
50
- if has_cmd apt-get; then
51
- if sudo apt-get install -y -qq fonts-powerline 2>/dev/null; then
52
- echo " Installed fonts-powerline (apt)"
53
- else
54
- _install_powerline_fonts_git
55
- fi
56
- elif has_cmd dnf; then
57
- if sudo dnf install -y powerline-fonts 2>/dev/null; then
58
- echo " Installed powerline-fonts (dnf)"
59
- else
60
- _install_powerline_fonts_git
61
- fi
62
- elif has_cmd pacman; then
63
- if sudo pacman -S --noconfirm powerline-fonts 2>/dev/null; then
64
- echo " Installed powerline-fonts (pacman)"
65
- else
66
- _install_powerline_fonts_git
67
- fi
68
- else
69
- _install_powerline_fonts_git
70
- fi
71
- ;;
72
- *)
73
- _install_powerline_fonts_git
74
- ;;
75
- esac
76
- }
77
-
78
- # fallback: clone and install powerline fonts from GitHub
79
- _install_powerline_fonts_git() {
40
+ # clone and install powerline fonts from GitHub (works on all platforms)
80
41
  if ! has_cmd git; then
81
42
  echo " git not found, skipping font install"
82
43
  return 1
@@ -86,98 +47,118 @@ _install_powerline_fonts_git() {
86
47
  tmpdir=$(mktemp -d)
87
48
  if git clone --depth=1 https://github.com/powerline/fonts.git "$tmpdir/fonts" 2>/dev/null; then
88
49
  bash "$tmpdir/fonts/install.sh" 2>/dev/null || true
89
- echo " Installed powerline fonts from GitHub"
50
+ echo " Installed powerline fonts"
90
51
  else
91
- echo " Failed to clone powerline fonts"
52
+ echo " Failed to download powerline fonts (optional)"
92
53
  fi
93
54
  rm -rf "$tmpdir"
94
55
  }
95
56
 
96
- # === 2. Setup zsh with Oh My Zsh + agnoster ===
57
+ # === 2. Generate zsh prompt config file ===
58
+ # Writes a standalone zsh prompt config that works WITHOUT Oh My Zsh
59
+ _generate_zsh_prompt() {
60
+ local prompt_file="$BATIPANEL_HOME/config/zsh-prompt.zsh"
61
+ mkdir -p "$BATIPANEL_HOME/config"
62
+
63
+ cat > "$prompt_file" << 'ZSH_PROMPT_EOF'
64
+ # batipanel zsh prompt (no Oh My Zsh needed)
65
+ # This file is sourced from .zshrc
66
+
67
+ # enable colors
68
+ autoload -U colors && colors
69
+
70
+ # enable git info
71
+ autoload -Uz vcs_info
72
+ precmd() { vcs_info }
73
+ zstyle ':vcs_info:git:*' formats ' %F{black}%K{green} ⎇ %b %k%F{green}▸%f'
74
+ zstyle ':vcs_info:*' enable git
75
+
76
+ # enable prompt substitution
77
+ setopt PROMPT_SUBST
78
+
79
+ # dark terminal colors via OSC escape sequences (works immediately)
80
+ if [[ "$TERM" != "dumb" ]]; then
81
+ printf '\e]11;#1e1e2e\a' # background: dark blue-grey
82
+ printf '\e]10;#cdd6f4\a' # foreground: light grey
83
+ printf '\e]12;#f5e0dc\a' # cursor: pink
84
+ fi
85
+
86
+ # prompt: user > directory > git branch
87
+ PROMPT='%K{blue}%F{white} %n %f%k%F{blue}%K{240}▸%f%F{white} %~ %f%k%F{240}${vcs_info_msg_0_:-%F{240}▸}%f '
88
+ RPROMPT='%(?..%F{red}✘ %?%f)'
89
+ ZSH_PROMPT_EOF
90
+ }
91
+
92
+ # === 3. Setup zsh prompt (direct, no Oh My Zsh) ===
97
93
  setup_zsh_theme() {
98
94
  local shell_rc="$1"
99
95
 
100
- echo " Configuring zsh theme..."
101
-
102
- # install Oh My Zsh if not present
103
- if [ ! -d "$HOME/.oh-my-zsh" ]; then
104
- echo " Installing Oh My Zsh..."
105
- if has_cmd curl; then
106
- RUNZSH=no CHSH=no KEEP_ZSHRC=yes \
107
- sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" 2>/dev/null || true
108
- elif has_cmd wget; then
109
- RUNZSH=no CHSH=no KEEP_ZSHRC=yes \
110
- sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" 2>/dev/null || true
111
- else
112
- echo " curl/wget not found, skipping Oh My Zsh"
113
- return 1
114
- fi
115
- fi
96
+ echo " Configuring zsh prompt..."
116
97
 
117
- if [ ! -d "$HOME/.oh-my-zsh" ]; then
118
- echo " Oh My Zsh installation failed"
119
- return 1
120
- fi
98
+ # generate the prompt file
99
+ _generate_zsh_prompt
100
+
101
+ # add source line to .zshrc if not present
102
+ local prompt_file="$BATIPANEL_HOME/config/zsh-prompt.zsh"
103
+ local source_line="[[ -f \"$prompt_file\" ]] && source \"$prompt_file\""
121
104
 
122
- # set agnoster theme
123
105
  if [ -f "$shell_rc" ]; then
124
- if grep -q 'ZSH_THEME=' "$shell_rc" 2>/dev/null; then
125
- _sed_i 's/^ZSH_THEME=.*/ZSH_THEME="agnoster"/' "$shell_rc"
126
- else
127
- echo 'ZSH_THEME="agnoster"' >> "$shell_rc"
106
+ if ! grep -qF "zsh-prompt.zsh" "$shell_rc" 2>/dev/null; then
107
+ {
108
+ echo ""
109
+ echo "# batipanel prompt theme"
110
+ echo "$source_line"
111
+ } >> "$shell_rc"
128
112
  fi
113
+ else
114
+ echo "$source_line" > "$shell_rc"
129
115
  fi
130
116
 
131
- # hide hostname: set DEFAULT_USER to current user
132
- _add_line_if_missing "$shell_rc" "DEFAULT_USER" \
133
- "DEFAULT_USER=\"\$(whoami)\""
134
-
135
- echo " Set agnoster theme with hostname hidden"
117
+ echo " Set powerline-style prompt"
136
118
  }
137
119
 
138
- # fallback prompt generator (when themes.sh is not loaded)
120
+ # === 4. Bash prompt (fallback) ===
139
121
  _setup_default_bash_prompt() {
140
122
  local prompt_file="$BATIPANEL_HOME/config/bash-prompt.sh"
141
123
  mkdir -p "$BATIPANEL_HOME/config"
142
124
  cat > "$prompt_file" << 'FALLBACK_EOF'
143
125
  #!/usr/bin/env bash
144
- # batipanel bash prompt - default theme (fallback)
126
+ # batipanel bash prompt - powerline style
127
+
128
+ # dark terminal colors via OSC
129
+ if [[ "$TERM" != "dumb" ]]; then
130
+ printf '\e]11;#1e1e2e\a'
131
+ printf '\e]10;#cdd6f4\a'
132
+ printf '\e]12;#f5e0dc\a'
133
+ fi
134
+
145
135
  __batipanel_prompt() {
146
136
  local exit_code=$?
147
- local sep=$'\uE0B0'
148
137
  local bg_user="\[\e[44m\]"
149
138
  local fg_user="\[\e[97m\]"
150
139
  local bg_dir="\[\e[48;5;240m\]"
151
140
  local fg_dir="\[\e[97m\]"
152
141
  local bg_git="\[\e[42m\]"
153
142
  local fg_git="\[\e[30m\]"
154
- local bg_err="\[\e[41m\]"
155
- local fg_err="\[\e[97m\]"
156
143
  local reset="\[\e[0m\]"
157
- local t_user_dir="\[\e[34;48;5;240m\]"
158
- local t_dir_git="\[\e[38;5;240;42m\]"
159
- local t_dir_end="\[\e[38;5;240m\]"
160
- local t_git_end="\[\e[32m\]"
161
- local t_err_dir="\[\e[31;48;5;240m\]"
144
+ local t_user="\[\e[34;48;5;240m\]"
145
+ local t_dir="\[\e[38;5;240;42m\]"
146
+ local t_end="\[\e[38;5;240m\]"
147
+ local t_git="\[\e[32m\]"
162
148
  local ps=""
163
149
  if [ "$exit_code" -ne 0 ]; then
164
- ps+="${bg_err}${fg_err} ✘ ${exit_code} "
165
- ps+="${t_err_dir}${sep}"
150
+ ps+="\[\e[41m\]\[\e[97m\] ✘ ${exit_code} \[\e[31;48;5;240m\]▸"
166
151
  fi
167
- ps+="${bg_user}${fg_user} \\u "
168
- ps+="${t_user_dir}${sep}"
152
+ ps+="${bg_user}${fg_user} \\u ${t_user}▸"
169
153
  ps+="${bg_dir}${fg_dir} \\w "
170
154
  local git_branch=""
171
155
  if command -v git &>/dev/null; then
172
156
  git_branch="$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)"
173
157
  fi
174
158
  if [ -n "$git_branch" ]; then
175
- ps+="${t_dir_git}${sep}"
176
- local git_icon=$'\uE0A0'
177
- ps+="${bg_git}${fg_git} ${git_icon} ${git_branch} "
178
- ps+="${reset}${t_git_end}${sep}${reset} "
159
+ ps+="${t_dir}▸${bg_git}${fg_git} ⎇ ${git_branch} ${reset}${t_git}▸${reset} "
179
160
  else
180
- ps+="${reset}${t_dir_end}${sep}${reset} "
161
+ ps+="${reset}${t_end}▸${reset} "
181
162
  fi
182
163
  PS1="$ps"
183
164
  }
@@ -185,27 +166,23 @@ PROMPT_COMMAND="__batipanel_prompt"
185
166
  FALLBACK_EOF
186
167
  }
187
168
 
188
- # === 3. Setup bash powerline prompt ===
189
169
  setup_bash_prompt() {
190
170
  local shell_rc="$1"
191
171
 
192
172
  echo " Configuring bash prompt..."
193
173
 
194
- # generate prompt with current theme (uses _generate_themed_prompt from themes.sh)
195
174
  local current_theme="${BATIPANEL_THEME:-default}"
196
175
  if declare -f _generate_themed_prompt &>/dev/null; then
197
176
  _generate_themed_prompt "$current_theme"
198
177
  else
199
- # fallback: generate default prompt directly (standalone install without themes.sh)
200
178
  _setup_default_bash_prompt
201
179
  fi
202
180
 
203
- # source prompt from shell RC
204
181
  local prompt_file="$BATIPANEL_HOME/config/bash-prompt.sh"
205
182
  local source_line="source \"$prompt_file\""
206
183
  _add_line_if_missing "$shell_rc" "bash-prompt.sh" "$source_line"
207
184
 
208
- echo " Set powerline-style prompt (hostname hidden)"
185
+ echo " Set powerline-style prompt"
209
186
  }
210
187
 
211
188
  # === Helper: add line to RC if not already present ===
@@ -228,21 +205,6 @@ _add_line_if_missing() {
228
205
  fi
229
206
  }
230
207
 
231
- # === 4. macOS Terminal.app dark profile ===
232
- setup_macos_terminal_profile() {
233
- [ "$(uname -s)" = "Darwin" ] || return 0
234
-
235
- echo " Setting up Terminal.app dark theme..."
236
-
237
- # set macOS built-in "Pro" dark profile as default
238
- if defaults read com.apple.Terminal &>/dev/null 2>&1; then
239
- defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
240
- defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"
241
- echo " Set Terminal.app to dark theme (Pro)"
242
- echo " Open a new Terminal window to see the change"
243
- fi
244
- }
245
-
246
208
  # === Main entry point ===
247
209
  setup_shell_environment() {
248
210
  local user_shell="$1"
@@ -267,8 +229,5 @@ setup_shell_environment() {
267
229
  ;;
268
230
  esac
269
231
 
270
- # macOS: set Terminal.app to dark theme
271
- setup_macos_terminal_profile
272
-
273
232
  echo " Shell environment setup complete"
274
233
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "batipanel",
3
- "version": "0.4.13",
3
+ "version": "0.4.15",
4
4
  "description": "AI-powered terminal workspace manager — multi-panel tmux layouts with Claude Code, git, monitoring, and more",
5
5
  "bin": {
6
6
  "batipanel": "./bin/cli.sh"