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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 # Augie Fackler's zshrc file
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
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
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 done
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 # Login greeting ------------------
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
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
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
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
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 # If available, source private extensions stored in a different repo
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 if [[ -a ~/.private/zshrc ]]; then
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 source ~/.private/zshrc
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47 fi
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
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
c30d68fbd368 Initial import from svn.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 fi