Created
November 8, 2014 16:11
-
-
Save bazbt3/cd4a5851e550850422ed to your computer and use it in GitHub Desktop.
I want to refresh all windows & panes in a Tmux session. Stumped. (Followup.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In essence I want a shell script menu option to refresh Tmux windows & panes. | |
(There is no user tmux.conf file - I use Tmuxinator to setup Tmux {it's easier} - thus it's not going to be as easy as this Linux noob thinks!) | |
I have 3 files (none yet in a public repo): | |
1. ~/Documents/ayadn_run.sh - calls up a Tmuxinator file, | |
2. ~/.tmuxinator/ayadn.yml - which starts a Tmux session and in turn calls up | |
3. ~/Documents/ayadn_shell.sh - the shell script menu running inside the Tmux session. | |
ayadn_shell.sh: | |
Menu option 8 should export REFRESH=1 then kill the Tmux session, thus returning to ayadn_run. | |
Menu option 0 should export REFRESH=0 then kill the Tmux server, thus returning to ayadn_run. | |
ayadn_run.sh: | |
With REFRESH=1 variable RUNAYADN should let the while..do re-run 'mux ayadn' thus starting the whole thing off again. | |
With REFRESH=0 variable RUNAYADN should let the while..do exit back to the command prompt. | |
I can only get the 2 options to either refresh or exit - not behaving as intended. | |
Did I mention I'm a Linux noob yet? | |
The files: | |
---------- | |
ayadn_run.sh (commented!) follows: | |
---------- | |
#!/bin/bash | |
# ~/Documents/ayadn_run.sh | |
clear | |
RUNAYADN=1 | |
while [ "$RUNAYADN" = 1 ] | |
do | |
mux ayadn | |
RUNAYADN=1 | |
# RUNAYADN=1 substituted for the next line | |
# I can't get the REFRESH variable to 'export' from ayadn_shell | |
# RUNAYADN=$REFRESH | |
done | |
echo "Press a key" | |
read KEYPRESS | |
echo "Done." | |
exit | |
---------- | |
ayadn.yml follows: | |
---------- | |
# ~/.tmuxinator/ayadn.yml | |
# A Tmuxinator layout for the Ayadn App.net command line client | |
# Prerequisites: | |
# 1. Ruby and Tmux and Tmuxinator must be installed. It's non-trivial but brings its own, peculiar, rewards. | |
# 2. An understanding that I'm new to Linux - I'm pretty sure this code won't break anything but be careful if you wish to modify it. | |
# 3. An understanding that, because I'm new to Linux I've created about 13 documents thus far. All in ~/Documents - easy. | |
name: ayadn | |
root: ~/ | |
windows: | |
- Main: | |
layout: tiled | |
panes: | |
- ~/Documents/ayadn_shell.sh | |
- ayadn messages_unread -z | |
- ayadn mentions @bazbt3 | |
- ayadn interactions | |
- Mentions: | |
layout: main-vertical | |
panes: | |
- ~/Documents/ayadn_shell.sh | |
- ayadn mentions bazbt3 | |
- Messages: | |
layout: main-vertical | |
panes: | |
- ~/Documents/ayadn_shell.sh | |
- ayadn messages_unread -z | |
- Timeline: | |
layout: main-vertical | |
panes: | |
- ~/Documents/ayadn_shell.sh | |
- ayadn timeline -s | |
- Multipurpose: | |
layout: main-vertical | |
panes: | |
- ~/Documents/ayadn_shell.sh | |
- clear && echo "" && echo "To shift focus to this pane, press [ctrl-b] [right-cursor]" && echo "" | |
---------- | |
ayadn.shell.sh follows | |
---------- | |
#!/bin/bash | |
# ~/Documents/ayadn_shell.sh | |
# ( Adapted from: http://code.activestate.com/recipes/577437-basic-linux-menu/ ) | |
# Prerequisites: | |
# 1. Ruby and Tmux and Tmuxinator must be installed. It's non-trivial but brings its own, peculiar, rewards. | |
# 2. An understanding that I'm new to Linux - I'm pretty sure this code won't break anything but be careful if you wish to modify it. | |
# 3. An understanding that, because I'm new to Linux I've created about 13 documents thus far. All in ~/Documents - easy. | |
clear | |
CHOICE= | |
until [ "$CHOICE" = "0" ]; | |
do | |
echo "" | |
echo "AYADN MENU" | |
echo "" | |
echo "1 - ayadn write" | |
echo "2 - ayadn reply" | |
echo "3 - ayadn pm [channel/alias]" | |
echo "4 - ayadn convo [post number]" | |
echo "5 - ayadn repost [post number]" | |
echo "" | |
echo "8 - Refresh all" | |
echo "9 - Next window" | |
echo "" | |
echo "0 - Exit session" | |
echo "" | |
echo -n "Enter Selection:" | |
read CHOICE | |
echo "" | |
case $CHOICE | |
in | |
1 ) clear | |
echo "Compose a multiline post:" | |
echo "" | |
ayadn write;; | |
2 ) clear | |
echo "Compose a reply:" | |
echo "" | |
echo "Reply [post number]?" | |
read post | |
ayadn reply $post;; | |
3 ) clear | |
echo "Compose a PM:" | |
echo "" | |
echo "PM [channel number/alias?]" | |
read channel | |
ayadn pm $channel;; | |
4 ) clear | |
echo "Display a conversation:" | |
echo "" | |
echo "Conversation [post number]?" | |
read post | |
ayadn convo $post | |
read -p "Press [Enter] to return to menu.";; | |
5 ) clear | |
echo "Repost:" | |
echo "" | |
echo "Post [post]?" | |
read post | |
ayadn repost $post;; | |
8 ) export REFRESH=1 | |
tmux kill-session;; | |
9 ) clear | |
tmux next-window;; | |
0 ) export REFRESH=0 | |
tmux kill-server;; | |
* ) echo "Please enter 1,2,3,4,5,8,9 or 0." | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oops - I could have added files!
Anyway, I suspect that 'export REFRESH=1' and 'export REFRESH=0' are not exporting out of the killed Tmux session to the shell script calling it. Maybe I need to get into Tmux rather than taking the easy option?