1 |
Some drive-by after-the-fact comments: |
2 |
|
3 |
On 12/6/21 4:03 PM, Frank Steinmetzger wrote: |
4 |
> [ "$MC_SID" ] && PS1_JOBS_COUNT="${PS1_JOBS_COUNT}MC " |
5 |
> [ "$RANGER_LEVEL" ] && PS1_JOBS_COUNT="${PS1_JOBS_COUNT}R " |
6 |
|
7 |
I've taken to using things like the following: |
8 |
|
9 |
PS1_JOBS_COUNT="${PS1_JOBS_COUNT}${MC_SID:+MC }${RANGER_LEVEL:+R }" |
10 |
|
11 |
Leverage Bash's (and Zsh's) expansion conditional. If the variable is |
12 |
set, then expand it to a different value. |
13 |
|
14 |
${VARIABLE:+alternate text to show if VARIABLE is set} |
15 |
|
16 |
> if [[ -z "$PROMPT_COMMAND" ]]; then |
17 |
> PROMPT_COMMAND=__jobsprompt |
18 |
> else |
19 |
> PROMPT_COMMAND="$PROMPT_COMMAND ; __jobsprompt" |
20 |
> fi |
21 |
|
22 |
Is there a reason to not simply do the following, eliminating the if |
23 |
conditional: |
24 |
|
25 |
PROMPT_COMMAND=${PROMPT_COMMAND:+${PROMPT_COMMAND} ; __jobsprompt} |
26 |
|
27 |
|
28 |
|
29 |
-- |
30 |
Grant. . . . |
31 |
unix || die |