Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add support for the FOSSIL_COLOR environment variable to define the color VT escape to highlight CLI text, also similar to `ls', `grep' and other utilities. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | standard-cli-colors |
| Files: | files | file ages | folders |
| SHA3-256: |
50e0931bc711da4acd9e9aae1978eeef |
| User & Date: | florian 2025-04-18 07:19:00.000 |
Context
|
2025-04-18
| ||
| 07:20 | Remove documentation of the --highlight option for the search command. The option was broken, anyway, and is now superseded by the global --color option and the FOSSIL_COLOR environment variable. ... (check-in: 5331dfed41 user: florian tags: standard-cli-colors) | |
| 07:19 | Add support for the FOSSIL_COLOR environment variable to define the color VT escape to highlight CLI text, also similar to `ls', `grep' and other utilities. ... (check-in: 50e0931bc7 user: florian tags: standard-cli-colors) | |
| 07:16 | Add the global --color option to control output of color VT escapes to CLI, similar to `ls', `grep' and other utilities. Useful when piping `fossil search' results through a pager utility. ... (check-in: 210b7d2fe0 user: florian tags: standard-cli-colors) | |
Changes
Changes to src/main.c.
| ︙ | ︙ | |||
234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
* applicable when using SEE on Windows or Linux. */
#endif
int useLocalauth; /* No login required if from 127.0.0.1 */
int noPswd; /* Logged in without password (on 127.0.0.1) */
int userUid; /* Integer user id */
int isHuman; /* True if access by a human, not a spider or bot */
int colorOutput; /* Control output of color VT escapes to CLI */
int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
** accessed through get_comment_format(). */
const char *zSockName; /* Name of the unix-domain socket file */
const char *zSockMode; /* File permissions for unix-domain socket */
const char *zSockOwner; /* Owner, or owner:group for unix-domain socket */
/* Information used to populate the RCVFROM table */
| > | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
* applicable when using SEE on Windows or Linux. */
#endif
int useLocalauth; /* No login required if from 127.0.0.1 */
int noPswd; /* Logged in without password (on 127.0.0.1) */
int userUid; /* Integer user id */
int isHuman; /* True if access by a human, not a spider or bot */
int colorOutput; /* Control output of color VT escapes to CLI */
const char *cliColor; /* VT color code for CLI highlight; default: "91" */
int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be
** accessed through get_comment_format(). */
const char *zSockName; /* Name of the unix-domain socket file */
const char *zSockMode; /* File permissions for unix-domain socket */
const char *zSockOwner; /* Owner, or owner:group for unix-domain socket */
/* Information used to populate the RCVFROM table */
|
| ︙ | ︙ | |||
639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
}
fossil_warning("%s", blob_str(&msg));
blob_reset(&msg);
}
/*
** Initialize the g.comFmtFlags and g.colorOutput global variables.
**
** The global command-line options --comfmtflags or --comment-format to
** set the comment format are undocumented and deprecated, and are only
** for backwards compatibility.
**
** If the --color option isn't found, the NO_COLOR environment variable
** may disable colored output (but is otherwise trumped by the option).
| > | 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 |
}
fossil_warning("%s", blob_str(&msg));
blob_reset(&msg);
}
/*
** Initialize the g.comFmtFlags and g.colorOutput global variables.
** Also read the environment variable FOSSIL_COLOR into g.cliColor.
**
** The global command-line options --comfmtflags or --comment-format to
** set the comment format are undocumented and deprecated, and are only
** for backwards compatibility.
**
** If the --color option isn't found, the NO_COLOR environment variable
** may disable colored output (but is otherwise trumped by the option).
|
| ︙ | ︙ | |||
682 683 684 685 686 687 688 689 690 691 692 693 694 695 |
if( zEnvVar ){
if( is_false(zEnvVar) ){
g.colorOutput = COLOR_VT_NEVER;
}
fossil_path_free(zEnvVar);
}
}
}
/*
** Check to see if the Fossil binary contains an appended repository
** file using the appendvfs extension. If so, change command-line arguments
** to cause Fossil to launch with "fossil ui" on that repo.
*/
| > > > > > > > > > > > > > > > > | 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 |
if( zEnvVar ){
if( is_false(zEnvVar) ){
g.colorOutput = COLOR_VT_NEVER;
}
fossil_path_free(zEnvVar);
}
}
g.cliColor = "\033[91m";
zEnvVar = fossil_getenv("FOSSIL_COLOR");
if( zEnvVar ){
if( fossil_strcmp(zEnvVar,"none")==0 &&
g.colorOutput==COLOR_VT_UNSET ){
g.colorOutput = COLOR_VT_NEVER;
}else{
int i, fValid = 1;
/* Rudimentary sanity check: only allow digits and semicolon. */
for( i=0; zEnvVar[i]; i++ ){
if( !strchr("0123456789;",zEnvVar[i]) ) fValid = 0;
}
if( fValid ) g.cliColor = mprintf("\033[%sm",zEnvVar);
}
fossil_path_free(zEnvVar);
}
}
/*
** Check to see if the Fossil binary contains an appended repository
** file using the appendvfs extension. If so, change command-line arguments
** to cause Fossil to launch with "fossil ui" on that repo.
*/
|
| ︙ | ︙ |
Changes to src/wikiformat.c.
| ︙ | ︙ | |||
2530 2531 2532 2533 2534 2535 2536 | } } #if INTERFACE /* ** Allowed flag options for html_to_plaintext(). */ | | | | 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 |
}
}
#if INTERFACE
/*
** Allowed flag options for html_to_plaintext().
*/
#define HTOT_VT100 0x01 /* <mark> becomes ^[[<g.cliColor>m */
#define HTOT_FLOW 0x02 /* Collapse internal whitespace to a single space */
#define HTOT_TRIM 0x04 /* Trim off leading and trailing whitespace */
#endif /* INTERFACE */
/*
** Add <MARK> or </MARK> to the output, or similar VT-100 escape
** codes.
*/
static void addMark(Blob *pOut, int mFlags, int isClose){
const char *az[4] = { "<MARK>", "</MARK>", g.cliColor, "\033[0m" };
int i = 0;
if( isClose ) i++;
if( mFlags & HTOT_VT100 ) i += 2;
blob_append(pOut, az[i], -1);
}
/*
|
| ︙ | ︙ |
Changes to www/env-opts.md.
| ︙ | ︙ | |||
142 143 144 145 146 147 148 149 150 151 152 153 154 155 | `EDITOR`: Name the editor to use for check-in and stash comments. Overridden by the local or global `editor` setting or the `VISUAL` environment variable. `FOSSIL_BREAK`: If set, an opportunity will be created to attach a debugger to the Fossil process prior to any significant work being performed. `FOSSIL_FORCE_TICKET_MODERATION`: If set, *ALL* changes for tickets will be required to go through moderation (even those performed by the local interactive user via the command line). This can be useful for local (or remote) testing of the moderation subsystem and its impact on the contents and status of tickets. | > > > > > | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | `EDITOR`: Name the editor to use for check-in and stash comments. Overridden by the local or global `editor` setting or the `VISUAL` environment variable. `FOSSIL_BREAK`: If set, an opportunity will be created to attach a debugger to the Fossil process prior to any significant work being performed. `FOSSIL_COLOR`: Define the color VT escape to highlight CLI text. For example, if set to `1;4`, call-outs are bold and underlined. With the value `none`, colors are disabled, but note that the `--color=always` option takes precedence. The default is `91` (bright foreground red). `FOSSIL_FORCE_TICKET_MODERATION`: If set, *ALL* changes for tickets will be required to go through moderation (even those performed by the local interactive user via the command line). This can be useful for local (or remote) testing of the moderation subsystem and its impact on the contents and status of tickets. |
| ︙ | ︙ |