Fossil SCM
fossil shell prompt now contains project name, if any, per request in [https://fossil-scm.org/forum/forumpost/c0a0123fb8|forumpost/c0a0123fb8].
Commit
ce6eaf0fb0444a9b3139054dacd9fca033b6bce3d6632ae6d1ad78e32e0b147c
Parent
9aca02b73c2f4ee…
1 file changed
+4
-1
+4
-1
| --- src/fshell.c | ||
| +++ src/fshell.c | ||
| @@ -57,16 +57,18 @@ | ||
| 57 | 57 | int n, i; |
| 58 | 58 | char **azArg = 0; |
| 59 | 59 | int fDebug; |
| 60 | 60 | pid_t childPid; |
| 61 | 61 | char *zLine = 0; |
| 62 | + char *zPrompt = 0; | |
| 62 | 63 | fDebug = find_option("debug", 0, 0)!=0; |
| 63 | 64 | db_find_and_open_repository(OPEN_ANY_SCHEMA|OPEN_OK_NOT_FOUND, 0); |
| 65 | + zPrompt = mprintf("fossil (%z)> ", db_get("project-name","no repo")); | |
| 64 | 66 | db_close(0); |
| 65 | 67 | sqlite3_shutdown(); |
| 66 | 68 | linenoiseSetMultiLine(1); |
| 67 | - while( (free(zLine), zLine = linenoise("fossil> ")) ){ | |
| 69 | + while( (free(zLine), zLine = linenoise(zPrompt)) ){ | |
| 68 | 70 | /* Remember shell history within the current session */ |
| 69 | 71 | linenoiseHistoryAdd(zLine); |
| 70 | 72 | |
| 71 | 73 | /* Parse the line of input */ |
| 72 | 74 | n = (int)strlen(zLine); |
| @@ -117,7 +119,8 @@ | ||
| 117 | 119 | /* The parent process */ |
| 118 | 120 | int status; |
| 119 | 121 | waitpid(childPid, &status, 0); |
| 120 | 122 | } |
| 121 | 123 | } |
| 124 | + free(zPrompt); | |
| 122 | 125 | #endif |
| 123 | 126 | } |
| 124 | 127 |
| --- src/fshell.c | |
| +++ src/fshell.c | |
| @@ -57,16 +57,18 @@ | |
| 57 | int n, i; |
| 58 | char **azArg = 0; |
| 59 | int fDebug; |
| 60 | pid_t childPid; |
| 61 | char *zLine = 0; |
| 62 | fDebug = find_option("debug", 0, 0)!=0; |
| 63 | db_find_and_open_repository(OPEN_ANY_SCHEMA|OPEN_OK_NOT_FOUND, 0); |
| 64 | db_close(0); |
| 65 | sqlite3_shutdown(); |
| 66 | linenoiseSetMultiLine(1); |
| 67 | while( (free(zLine), zLine = linenoise("fossil> ")) ){ |
| 68 | /* Remember shell history within the current session */ |
| 69 | linenoiseHistoryAdd(zLine); |
| 70 | |
| 71 | /* Parse the line of input */ |
| 72 | n = (int)strlen(zLine); |
| @@ -117,7 +119,8 @@ | |
| 117 | /* The parent process */ |
| 118 | int status; |
| 119 | waitpid(childPid, &status, 0); |
| 120 | } |
| 121 | } |
| 122 | #endif |
| 123 | } |
| 124 |
| --- src/fshell.c | |
| +++ src/fshell.c | |
| @@ -57,16 +57,18 @@ | |
| 57 | int n, i; |
| 58 | char **azArg = 0; |
| 59 | int fDebug; |
| 60 | pid_t childPid; |
| 61 | char *zLine = 0; |
| 62 | char *zPrompt = 0; |
| 63 | fDebug = find_option("debug", 0, 0)!=0; |
| 64 | db_find_and_open_repository(OPEN_ANY_SCHEMA|OPEN_OK_NOT_FOUND, 0); |
| 65 | zPrompt = mprintf("fossil (%z)> ", db_get("project-name","no repo")); |
| 66 | db_close(0); |
| 67 | sqlite3_shutdown(); |
| 68 | linenoiseSetMultiLine(1); |
| 69 | while( (free(zLine), zLine = linenoise(zPrompt)) ){ |
| 70 | /* Remember shell history within the current session */ |
| 71 | linenoiseHistoryAdd(zLine); |
| 72 | |
| 73 | /* Parse the line of input */ |
| 74 | n = (int)strlen(zLine); |
| @@ -117,7 +119,8 @@ | |
| 119 | /* The parent process */ |
| 120 | int status; |
| 121 | waitpid(childPid, &status, 0); |
| 122 | } |
| 123 | } |
| 124 | free(zPrompt); |
| 125 | #endif |
| 126 | } |
| 127 |