Mercurial > dotfiles
annotate .zshrc @ 526:852565046ed0 default tip
zsh: fidget with screen/tmux message
This should speed things up very slightly by avoiding some `grep` action
in the common case of no detached screens/tmuxes.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Mon, 14 Nov 2022 11:02:35 -0500 |
parents | b78aa03c0c00 |
children |
rev | line source |
---|---|
0 | 1 # Augie Fackler's zshrc file |
2 | |
39
62bfb554ab85
Reorganize zsh files so that bash can work as well.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
3 for file in $(ls $HOME/.shell.d/*.{,z}sh) ; do |
62bfb554ab85
Reorganize zsh files so that bash can work as well.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
4 source $file |
0 | 5 done |
6 | |
7 # Login greeting ------------------ | |
8 | |
9 if [ ! "$SHOWED_SCREEN_MESSAGE" = "true" ]; then | |
307
e37b00236907
zshrc: work around my shell function that turns on utf8 in screen
Augie Fackler <raf@durin42.com>
parents:
286
diff
changeset
|
10 # Use /bin/which explicitly because we have a shell function |
e37b00236907
zshrc: work around my shell function that turns on utf8 in screen
Augie Fackler <raf@durin42.com>
parents:
286
diff
changeset
|
11 # that confuses the zsh built-in which. |
505
b78aa03c0c00
zshrc: silence noisy which(1) implementations
Augie Fackler <raf@durin42.com>
parents:
322
diff
changeset
|
12 if sh -c 'which screen' 2> /dev/null > /dev/null; then |
526
852565046ed0
zsh: fidget with screen/tmux message
Augie Fackler <raf@durin42.com>
parents:
505
diff
changeset
|
13 SCREENS_OUTPUT="$(screen -list)" |
852565046ed0
zsh: fidget with screen/tmux message
Augie Fackler <raf@durin42.com>
parents:
505
diff
changeset
|
14 if [[ "${SCREENS_OUTPUT}" =~ Detached ]] ; then |
852565046ed0
zsh: fidget with screen/tmux message
Augie Fackler <raf@durin42.com>
parents:
505
diff
changeset
|
15 detached_screens=`echo "${SCREENS_OUTPUT}" | grep Detached | sed -e 's/ (Detached)//'` |
39
62bfb554ab85
Reorganize zsh files so that bash can work as well.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
16 echo "+---------------------------------------+" |
62bfb554ab85
Reorganize zsh files so that bash can work as well.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
17 echo "| Detached screens are available: |" |
62bfb554ab85
Reorganize zsh files so that bash can work as well.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
18 echo "$detached_screens" |
62bfb554ab85
Reorganize zsh files so that bash can work as well.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
19 echo "+---------------------------------------+" |
62bfb554ab85
Reorganize zsh files so that bash can work as well.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
20 fi |
526
852565046ed0
zsh: fidget with screen/tmux message
Augie Fackler <raf@durin42.com>
parents:
505
diff
changeset
|
21 unset SCREENS_OUTPUT |
852565046ed0
zsh: fidget with screen/tmux message
Augie Fackler <raf@durin42.com>
parents:
505
diff
changeset
|
22 unset detached_screens |
39
62bfb554ab85
Reorganize zsh files so that bash can work as well.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
23 fi |
62bfb554ab85
Reorganize zsh files so that bash can work as well.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
24 export SHOWED_SCREEN_MESSAGE="true" |
0 | 25 fi |
26 | |
278
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
27 if [ ! "$SHOWED_TMUX_MESSAGE" = "true" ]; then |
505
b78aa03c0c00
zshrc: silence noisy which(1) implementations
Augie Fackler <raf@durin42.com>
parents:
322
diff
changeset
|
28 if which tmux 2> /dev/null > /dev/null; then |
526
852565046ed0
zsh: fidget with screen/tmux message
Augie Fackler <raf@durin42.com>
parents:
505
diff
changeset
|
29 detached_screens="$(tmux ls 2> /dev/null)" |
852565046ed0
zsh: fidget with screen/tmux message
Augie Fackler <raf@durin42.com>
parents:
505
diff
changeset
|
30 if [ ! -z "$detached_screens" ]; then |
852565046ed0
zsh: fidget with screen/tmux message
Augie Fackler <raf@durin42.com>
parents:
505
diff
changeset
|
31 detached_screens="$(echo "$detached_screens" | grep -v attached)" |
852565046ed0
zsh: fidget with screen/tmux message
Augie Fackler <raf@durin42.com>
parents:
505
diff
changeset
|
32 fi |
278
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
33 if [ ! -z "$detached_screens" ]; then |
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
34 echo "+-----------------------------------------------------------+" |
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
35 echo "| Detached tmux sessions are available: |" |
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
36 echo "$detached_screens" |
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
37 echo "+-----------------------------------------------------------+" |
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
38 fi |
526
852565046ed0
zsh: fidget with screen/tmux message
Augie Fackler <raf@durin42.com>
parents:
505
diff
changeset
|
39 unset detached_screens |
278
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
40 fi |
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
41 export SHOWED_TMUX_MESSAGE="true" |
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
42 fi |
c65cc71d7ba1
zshrc: add a tmux variant of the detached screens message
Augie Fackler <raf@durin42.com>
parents:
39
diff
changeset
|
43 |
0 | 44 # If available, source private extensions stored in a different repo |
45 if [[ -a ~/.private/zshrc ]]; then | |
46 source ~/.private/zshrc | |
47 fi | |
48 | |
49 if [[ -a ~/.zshrc-machine ]]; then | |
39
62bfb554ab85
Reorganize zsh files so that bash can work as well.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
50 source ~/.zshrc-machine |
0 | 51 fi |