From 63f840efd53912f547794173d370afb988397769 Mon Sep 17 00:00:00 2001 From: Ikuo Degawa Date: Tue, 3 Feb 2026 15:16:07 +0900 Subject: [PATCH 1/4] Make PS1 multiline for narrow terminals Add newline before dollar sign to separate info line from input line. This improves usability when terminal width is limited. Co-Authored-By: Claude Opus 4.5 --- .functions | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.functions b/.functions index f5930bb..984b435 100644 --- a/.functions +++ b/.functions @@ -31,6 +31,9 @@ prompts() { PS1="$(echo "${PS1}" | sed 's/\\\$ /$AWS_PROMPT\\\$ /')" PS1="$(echo "${PS1}" | sed 's/\\\$ /$GC_PROMPT\\\$ /')" + # Add newline before dollar sign (multiline prompt) + PS1="$(echo "${PS1}" | sed 's/\\\$ /\\n\\\$ /')" + # Make dollar yellow PS1="$(echo "${PS1}" | sed 's/\\\$ /\\\[\\e\[33m\\\]\\\$\\\[\\e\[0m\\\] /')" From 92b1ceab5e6376e8b5367fd8bbacd5f46f7f5fb0 Mon Sep 17 00:00:00 2001 From: Ikuo Degawa Date: Tue, 3 Feb 2026 15:23:30 +0900 Subject: [PATCH 2/4] Add styled prompt with separator line and colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add gray horizontal line matching terminal width as separator - Add cyan info line with box symbol (┌─) - Info line shows: directory, git branch, AWS profile, GC config - Yellow dollar sign on separate input line - SSH indicator integrated into info line Co-Authored-By: Claude Opus 4.5 --- .functions | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.functions b/.functions index 984b435..35fdc8b 100644 --- a/.functions +++ b/.functions @@ -1,5 +1,10 @@ #!/usr/bin/env bash +prompt_line() { + # Generate horizontal line matching terminal width (gray) + PROMPT_LINE=$(printf '─%.0s' $(seq 1 "${COLUMNS:-80}")) +} + prompt_aws() { if [[ -n "${AWS_PROFILE}" ]]; then AWS_PROMPT=" " @@ -18,10 +23,11 @@ prompt_gc() { prompts() { if [ -z "$SSH_CLIENT" ]; then - PS1='localhost: \W\$ ' + # Line: gray, Info line: cyan with box symbol + PS1='\[\e[90m\]$PROMPT_LINE\[\e[0m\]\n\[\e[36m\]┌─ localhost: \W\$ ' fi - export PROMPT_COMMAND="prompt_aws;prompt_gc;$PROMPT_COMMAND" + export PROMPT_COMMAND="prompt_line;prompt_aws;prompt_gc;$PROMPT_COMMAND" if [ "$(command -v __git_ps1)" ]; then # shellcheck disable=2016 @@ -31,15 +37,16 @@ prompts() { PS1="$(echo "${PS1}" | sed 's/\\\$ /$AWS_PROMPT\\\$ /')" PS1="$(echo "${PS1}" | sed 's/\\\$ /$GC_PROMPT\\\$ /')" - # Add newline before dollar sign (multiline prompt) - PS1="$(echo "${PS1}" | sed 's/\\\$ /\\n\\\$ /')" + # Add newline before dollar sign (multiline prompt) and reset cyan color + PS1="$(echo "${PS1}" | sed 's/\\\$ /\\\[\\e\[0m\\\]\\n\\\$ /')" # Make dollar yellow PS1="$(echo "${PS1}" | sed 's/\\\$ /\\\[\\e\[33m\\\]\\\$\\\[\\e\[0m\\\] /')" if [ -n "$SSH_CLIENT" ]; then if [ "$PS1" = "${PS1/ssh/}" ]; then - PS1='\[\e[33m\][ssh]\[\e[0m\]'"${PS1}" + # Insert [ssh] after the box symbol (within cyan info line) + PS1="$(echo "${PS1}" | sed 's/┌─ /┌─ [ssh] /')" fi fi } From 8c001e87b28102b3804d6cc46c06220777bddbfe Mon Sep 17 00:00:00 2001 From: Ikuo Degawa Date: Tue, 3 Feb 2026 15:25:25 +0900 Subject: [PATCH 3/4] Remove separator line and colors from prompt Keep multiline layout and box symbol, but remove: - Gray horizontal separator line (breaks on terminal resize) - Cyan color from info line (too subtle) Co-Authored-By: Claude Opus 4.5 --- .functions | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.functions b/.functions index 35fdc8b..21721ea 100644 --- a/.functions +++ b/.functions @@ -1,10 +1,5 @@ #!/usr/bin/env bash -prompt_line() { - # Generate horizontal line matching terminal width (gray) - PROMPT_LINE=$(printf '─%.0s' $(seq 1 "${COLUMNS:-80}")) -} - prompt_aws() { if [[ -n "${AWS_PROFILE}" ]]; then AWS_PROMPT=" " @@ -23,11 +18,11 @@ prompt_gc() { prompts() { if [ -z "$SSH_CLIENT" ]; then - # Line: gray, Info line: cyan with box symbol - PS1='\[\e[90m\]$PROMPT_LINE\[\e[0m\]\n\[\e[36m\]┌─ localhost: \W\$ ' + # Multiline prompt with box symbol + PS1='\n┌─ localhost: \W\$ ' fi - export PROMPT_COMMAND="prompt_line;prompt_aws;prompt_gc;$PROMPT_COMMAND" + export PROMPT_COMMAND="prompt_aws;prompt_gc;$PROMPT_COMMAND" if [ "$(command -v __git_ps1)" ]; then # shellcheck disable=2016 @@ -37,8 +32,8 @@ prompts() { PS1="$(echo "${PS1}" | sed 's/\\\$ /$AWS_PROMPT\\\$ /')" PS1="$(echo "${PS1}" | sed 's/\\\$ /$GC_PROMPT\\\$ /')" - # Add newline before dollar sign (multiline prompt) and reset cyan color - PS1="$(echo "${PS1}" | sed 's/\\\$ /\\\[\\e\[0m\\\]\\n\\\$ /')" + # Add newline before dollar sign (multiline prompt) + PS1="$(echo "${PS1}" | sed 's/\\\$ /\\n\\\$ /')" # Make dollar yellow PS1="$(echo "${PS1}" | sed 's/\\\$ /\\\[\\e\[33m\\\]\\\$\\\[\\e\[0m\\\] /')" From abf56b142ff08ecdeee648b3362add6039e450b5 Mon Sep 17 00:00:00 2001 From: Ikuo Degawa Date: Wed, 4 Feb 2026 14:36:30 +0900 Subject: [PATCH 4/4] Add short_git_ps1 to truncate long branch names Long branch names are truncated to max 20 characters: - Prefix (feature/, fix/, etc.) is kept intact - Name part is shortened: beginning..end Example: feature/implement-new-auth -> feature/imp..auth Co-Authored-By: Claude Opus 4.5 --- .functions | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.functions b/.functions index 21721ea..92e63b5 100644 --- a/.functions +++ b/.functions @@ -16,6 +16,34 @@ prompt_gc() { fi } +short_git_ps1() { + local branch max_len prefix name available half short_name + branch=$(__git_ps1 "%s") + [ -z "$branch" ] && return + + max_len=20 + if [ ${#branch} -le $max_len ]; then + echo " ($branch)" + return + fi + + # Separate prefix (feature/, fix/, etc.) from name + if [[ "$branch" == */* ]]; then + prefix="${branch%%/*}/" + name="${branch#*/}" + else + prefix="" + name="$branch" + fi + + # Shorten name part (keep beginning and end, replace middle with ..) + available=$((max_len - ${#prefix} - 2)) # 2 is for ".." + half=$((available / 2)) + short_name="${name:0:$half}..${name: -$half}" + + echo " ($prefix$short_name)" +} + prompts() { if [ -z "$SSH_CLIENT" ]; then # Multiline prompt with box symbol @@ -26,7 +54,7 @@ prompts() { if [ "$(command -v __git_ps1)" ]; then # shellcheck disable=2016 - PS1="$(echo "${PS1}" | sed 's/\\\$ /$(__git_ps1)\\\$ /')" + PS1="$(echo "${PS1}" | sed 's/\\\$ /$(short_git_ps1)\\\$ /')" fi PS1="$(echo "${PS1}" | sed 's/\\\$ /$AWS_PROMPT\\\$ /')"