File tree Expand file tree Collapse file tree
src/plugins/terminal/scripts Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,6 +92,31 @@ export TERM=xterm-256color
9292SHELL=/bin/bash
9393export PIP_BREAK_SYSTEM_PACKAGES=1
9494
95+ # Smart path shortening function (fish-style: ~/p/s/components)
96+ _shorten_path() {
97+ local path="${PWD/#$HOME/\~}"
98+ [[ "$path" == "~" ]] && echo "~" && return
99+
100+ local parts result=""
101+ IFS='/' read -ra parts <<< "$path"
102+ local len=${#parts[@]}
103+
104+ for ((i=0; i<len; i++)); do
105+ [[ -z "${parts[i]}" ]] && continue
106+ if [[ $i -lt $((len-1)) ]]; then
107+ result+="${parts[i]:0:1}/"
108+ else
109+ result+="${parts[i]}"
110+ fi
111+ done
112+
113+ [[ "$path" == /* ]] && echo "/$result" || echo "$result"
114+ }
115+
116+ # Update prompt vars before each command
117+ PROMPT_COMMAND='_PS1_PATH=$(_shorten_path); _PS1_EXIT=$?'
118+
119+
95120# Display MOTD if available
96121if [ -s /etc/acode_motd ]; then
97122 cat /etc/acode_motd
120145
121146# Add PS1 only if not already present
122147if ! grep -q ' PS1=' " $PREFIX /alpine/initrc" ; then
123- echo ' PS1="\[\033[1;32m\]\u\[\033[0m\]@localhost \w \$ "' >> " $PREFIX /alpine/initrc"
148+ echo ' PS1="\[\033[1;32m\]\u\[\033[0m\]@localhost \[\033[1;34m\]\$_PS1_PATH\[\033[0m\] \[\$([ \$_PS1_EXIT -ne 0 ] && echo \"\033[31m\")\]\$\[\033[0m\] "' >> " $PREFIX /alpine/initrc"
124149fi
125150
126151chmod +x " $PREFIX /alpine/initrc"
127152
128- # actual souce
153+ # actual source
129154# everytime a terminal is started initrc will run
130155" $PREFIX /axs" -c " bash --rcfile /initrc -i"
131156
You can’t perform that action at this time.
0 commit comments