Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F170630613
D18663.id52339.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
893 B
Referenced Files
None
Subscribers
None
D18663.id52339.diff
View Options
Index: bin/sh/parser.c
===================================================================
--- bin/sh/parser.c
+++ bin/sh/parser.c
@@ -1978,6 +1978,7 @@
{
static char ps[PROMPTLEN];
const char *fmt;
+ const char *home;
const char *pwd;
int i, trim;
static char internal_error[] = "??";
@@ -2039,8 +2040,19 @@
*pwd == '/' && pwd[1] != '\0')
strlcpy(&ps[i], strrchr(pwd, '/') + 1,
PROMPTLEN - i);
- else
- strlcpy(&ps[i], pwd, PROMPTLEN - i);
+ else {
+ home = lookupvar("HOME");
+ if (home != NULL && strncmp(pwd, home,
+ strlen(home)) == 0) {
+ strlcpy(&ps[i], "~",
+ PROMPTLEN - i);
+ strlcpy(&ps[i + 1],
+ pwd + strlen(home),
+ PROMPTLEN - i);
+ } else {
+ strlcpy(&ps[i], pwd, PROMPTLEN - i);
+ }
+ }
/* Skip to end of path. */
while (ps[i + 1] != '\0')
i++;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Sep 6, 5:38 PM (15 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38392785
Default Alt Text
D18663.id52339.diff (893 B)
Attached To
Mode
D18663: Collapse $HOME into "~" in PS1.
Attached
Detach File
Event Timeline
Log In to Comment