git://git.iain.cx/iain
/
profile.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Easier to read blue colour in terminals.
[profile.git]
/
.profile.d
/
ps1.bashrc
diff --git
a/.profile.d/ps1.bashrc
b/.profile.d/ps1.bashrc
index
0667d0f
..
991095b
100644
(file)
--- a/
.profile.d/ps1.bashrc
+++ b/
.profile.d/ps1.bashrc
@@
-200,27
+200,29
@@
function __ps1_colon() {
}
function __ps1_short() {
}
function __ps1_short() {
+ local home=${HOME%%/}
+ local pwd=${PWD/#$home/\~}
local dirtrim=${PROMPT_DIRTRIM//[^0-9]/}
if [ "${dirtrim:0:1}" = "0" ]; then
local dirtrim=${PROMPT_DIRTRIM//[^0-9]/}
if [ "${dirtrim:0:1}" = "0" ]; then
- echo "$
PWD
"
+ echo "$
pwd
"
return $1
fi
dirtrim=${dirtrim##0}
if [ -z "$dirtrim" ]; then
return $1
fi
dirtrim=${dirtrim##0}
if [ -z "$dirtrim" ]; then
- local prompt="$USER$HOSTNAME$
PWD
"
+ local prompt="$USER$HOSTNAME$
pwd
"
local width=$(((COLUMNS*2)/3))
if [ ${#prompt} -le ${width:-53} ]; then
local width=$(((COLUMNS*2)/3))
if [ ${#prompt} -le ${width:-53} ]; then
- echo "$
PWD
"
+ echo "$
pwd
"
return $1
else
dirtrim=1
fi
fi
return $1
else
dirtrim=1
fi
fi
- local dirname=${
PWD
##*/}
- local basename=${
PWD
%/$dirname}
+ local dirname=${
pwd
##*/}
+ local basename=${
pwd
%/$dirname}
local reversed=
local component
for component in ${basename//\// }; do
local reversed=
local component
for component in ${basename//\// }; do
@@
-229,14
+231,16
@@
function __ps1_short() {
local n=1
local short=
for component in $reversed; do
local n=1
local short=
for component in $reversed; do
+ [ $n = 1 -a "$PWD" = "$pwd" ] || short="/$short"
if [ $n -ge $dirtrim ]; then
if [ $n -ge $dirtrim ]; then
- short="
/
${component:0:1}$short"
+ short="${component:0:1}$short"
else
else
- short="
/
$component$short"
+ short="$component$short"
fi
n=$((n+1))
done
fi
n=$((n+1))
done
+ [ "${short:0:1}" = "~" ] || short="/$short"
echo "$short/$dirname"
return $1
}
echo "$short/$dirname"
return $1
}