diff --git a/cg-Xlib b/cg-Xlib index be34447..ec2a5c0 100755 --- a/cg-Xlib +++ b/cg-Xlib @@ -307,17 +307,26 @@ columns_print() local fmt= cols= cols=() while [ $# -gt 0 ]; do - cols[${#cols[@]}]="$1"; shift + local col="$1"; shift local width="$1"; shift local tab= + local trim= if [ x"${width:0:1}" = x"t" ]; then tab=1; width="${width:1}" fi + if [ x"${width:0:1}" = x"m" ]; then + trim=1; width="${width:1}" + fi if [ x"$width" = x"-" ]; then fmt="$fmt%s" else fmt="$fmt%-${width}s" + if [ -n "$trim" ] && [ ${#col} -gt "$width" ]; then + width=$((width - 3)) + col="${col:0:$width}..." + fi fi + cols[${#cols[@]}]="$col" [ -z "$tab" ] || fmt="$fmt\t"; done printf "$fmt\n" "${cols[@]}" diff --git a/cg-status b/cg-status index 7b09fd9..cb6c4c5 100755 --- a/cg-status +++ b/cg-status @@ -165,12 +165,13 @@ if [ "$gitstatus" ]; then find "$_git/refs/heads" -name '*' -a ! -type d | sort | while read head; do headsha1="$(cat "$head")" headname="${head#$_git/refs/heads/}" + headlog="$(git-log --max-count=1 --pretty=oneline "$headsha1" | sed 's/^[^ ]* //')" [ "$headname" = "cg-seek-point" ] && continue cf=" "; rf=" "; sf=" "; [ "$headname" = "$_git_head" ] && cf=">" [ -s "$_git/branches/$headname" ] && rf="R" [ -s "$_git/refs/heads/.cg-shelve-$headname" ] && sf="s" - columns_print " $sf$rf$cf" - "$headname" t$maxlen "$headsha1" - + columns_print " $sf$rf$cf" - "$headname" t$maxlen "$headsha1" t- "$headlog" m30 done if [ -s "$_git/merging" ]; then