├── LICENSE ├── README.md ├── _config.yml ├── docs ├── README.md ├── _config.yml ├── _layouts │ └── default.html └── assets │ └── css │ └── style.css ├── tdab-icon.png ├── tdab-logo.png ├── tdab-open-graph.png ├── tdab_example.gif ├── tdab_example.mkv ├── tmux_devour.sh ├── tmux_sidebar.sh └── tmux_topbar.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Steven Saus 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tmux-devours-a-bar 2 | 3 | Create side and top bars in tmux easily, along with a "devour" style command. 4 | 5 | ![TDAB logo](https://github.com/uriel1998/tdab/raw/master/tdab-open-graph.png "logo") 6 | 7 | ![TDAB demo](https://raw.githubusercontent.com/uriel1998/tdab/master/tdab_example.gif "demo") 8 | 9 | You can see a larger version of the demo with the [included MKV file](https://github.com/uriel1998/tdab/blob/master/tdab_example.mkv?raw=true). 10 | 11 | ## Contents 12 | 1. [About](#1-about) 13 | 2. [License](#2-license) 14 | 3. [Prerequisites](#3-prerequisites) 15 | 4. [Installation](#4-installation) 16 | 5. [Usage](#5-usage) 17 | 6. [Examples](#6-examples) 18 | 19 | *** 20 | 21 | ## 1. About 22 | 23 | These three scripts (called `TDAB` for short) will create side or top bars 24 | (or a "devour" style new pane) that run a command inside tmux. See the image 25 | above to get an idea of what this means. 26 | 27 | The name is a play on "A *blank* walks into a bar", because puns. 28 | 29 | ## 2. License 30 | 31 | This project is licensed under the MIT License. For the full license, see `LICENSE`. 32 | 33 | ## 3. Prerequisites 34 | 35 | * tmux 36 | * bash 37 | * bc 38 | 39 | These scripts will *probably* work in other shells, but I don't know for sure. 40 | 41 | ## 4. Installation 42 | 43 | Clone or download the repository. Put the scripts (or symlinks to the scripts) 44 | in your `$PATH`. (In the example above, I've symlinked them to `sidebar`, 45 | `topbar`, and `devour`.) 46 | 47 | ### Tip for `Devour` 48 | 49 | I find a binding like the following *very* useful when using `devour`: 50 | 51 | `bind-key -n C-/ select-pane -R \;\` 52 | `resize-pane -Z` 53 | 54 | This will allow you to cycle among the zoomed panes - and will zoom each as you 55 | go through it. Very nice for programs like [emojin](https://github.com/peterjschroeder/emojin). 56 | 57 | ## 5. Usage 58 | 59 | `SCRIPTNAME [--offset NUMBER] [--hold] [program to run]` 60 | 61 | For example, `tmux-sidebar.sh man man` will show you the man page for man in 62 | the sidebar. 63 | 64 | **The optional command line arguments are POSITIONAL.** 65 | 66 | Resizing the bars can be done with the command line argument --offset which is 67 | expressed in the percentage of the screen you want for the *main* window. This 68 | must be the first and second argument used. For example, to have a main window 69 | taking up 90% of the screen, you would use 70 | 71 | `tmux-topbar.sh --offset 90 man man` 72 | 73 | This works by resizing the *larger* pane from the center line. 74 | 75 | If the *second* argument is either `-h` or `--hold` then TDAB will pause after 76 | executing the program and wait for you to hit a key (necessary for programs that 77 | exit immediately, which triggers the pane closing). 78 | 79 | If you run the scripts outside of tmux, it will just run the command. 80 | 81 | ### tmux_devour.sh 82 | 83 | Launch a process in a new pane, zoom the pane, kill the pane when done. 84 | 85 | ### tmux_sidebar.sh 86 | 87 | Create a sidebar (e.g. for reading manpages) and kill when done. 88 | 89 | ### tmux_topbar.sh 90 | 91 | Create a vertical split and kill when done. 92 | 93 | ## 6. Examples 94 | 95 | Aside from invoking on the command line, I've found a couple of short wrapper scripts 96 | really make a difference, particularly if you want a specific setup. 97 | 98 | To call your editor in a new, full-screen pane (leaving the initial pane alone): 99 | 100 | `/home/steven/bin/tmux_devour.sh /usr/bin/micro "${@}"` 101 | 102 | To bring up [my address book searcher](https://github.com/uriel1998/ppl_virdirsyncer_addysearch) in a small topbar when I'm working in the 103 | main window: 104 | 105 | `/home/steven/bin/tmux_topbar.sh --offset 80 pplsearch -c` 106 | 107 | To bring up newsboat, with a sidebar showing a cheat sheet of things I forget using 108 | [rich-cli](https://github.com/Textualize/rich-cli), then closing it when I'm done. 109 | 110 | 111 | ``` 112 | /home/steven/bin/tmux_sidebar.sh rich -m /home/steven/cheatsheet/newsboat.md --pager 113 | newsboat 114 | sidebarpid=$(ps aux | grep "rich -m /home/steven/cheatsheet/newsboat.md" | grep -v grep | awk '{print $2}') 115 | kill $sidebarpid 116 | ``` 117 | 118 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # tmux-devours-a-bar 2 | 3 | Create side and top bars in tmux easily, along with a "devour" style command. 4 | 5 | ![TDAB logo](https://github.com/uriel1998/tdab/raw/master/tdab-open-graph.png "logo") 6 | 7 | ![TDAB demo](https://raw.githubusercontent.com/uriel1998/tdab/master/tdab_example.gif "demo") 8 | 9 | You can see a larger version of the demo with the [included MKV file](https://github.com/uriel1998/tdab/blob/master/tdab_example.mkv?raw=true). 10 | 11 | ## Contents 12 | 1. [About](#1-about) 13 | 2. [License](#2-license) 14 | 3. [Prerequisites](#3-prerequisites) 15 | 4. [Installation](#4-installation) 16 | 5. [Usage](#5-usage) 17 | 6. [TODO](#6-todo) 18 | 19 | *** 20 | 21 | ## 1. About 22 | 23 | These three scripts (called `TDAB` for short) will create side or top bars 24 | (or a "devour" style new pane) that run a command inside tmux. See the image 25 | above to get an idea of what this means. 26 | 27 | The name is a play on "A *blank* walks into a bar", because puns. 28 | 29 | ## 2. License 30 | 31 | This project is licensed under the MIT License. For the full license, see `LICENSE`. 32 | 33 | ## 3. Prerequisites 34 | 35 | * tmux 36 | * bash 37 | 38 | These scripts will *probably* work in other shells, but I don't know for sure. 39 | 40 | ## 4. Installation 41 | 42 | Clone or download the repository. Put the scripts (or symlinks to the scripts) 43 | in your `$PATH`. (In the example above, I've symlinked them to `sidebar`, 44 | `topbar`, and `devour`.) 45 | 46 | If you wish to change the width or height of the sidebar/topbar, you will 47 | need to edit this line: 48 | 49 | `tmux resize-pane -t "$c_pane" -R 30` 50 | 51 | which actually resizes the *larger* pane from the center line. My screen that 52 | I used for the demo is 194 columns wide, so when it's first split, it's 97/96 53 | columns wide, then resizes it *to the right* an additional 30 columns so that 54 | I end up with a 127/67 split. The same thing goes for the topbar, except it 55 | resizes upward (-U). Adjust so that they work for your terminal size. 56 | 57 | ### Tip for `Devour` 58 | 59 | I find a binding like the following *very* useful when using `devour`: 60 | 61 | `bind-key -n C-/ select-pane -R \;\` 62 | `resize-pane -Z` 63 | 64 | This will allow you to cycle among the zoomed panes - and will zoom each as you 65 | go through it. Very nice for programs like [emojin](https://github.com/peterjschroeder/emojin). 66 | 67 | ## 5. Usage 68 | 69 | `SCRIPTNAME [program to run]` 70 | 71 | For example, `tmux-sidebar.sh man man` will show you the man page for man in 72 | the sidebar. 73 | 74 | If the *first* argument is either `-h` or `--hold` then TDAB will pause after 75 | executing the program and wait for you to hit a key (necessary for programs that 76 | exit immediately, which triggers the pane closing). 77 | 78 | If you run the scripts outside of tmux, it will just run the command. 79 | 80 | ### tmux_devour.sh 81 | 82 | Launch a process in a new pane, zoom the pane, kill the pane when done. 83 | 84 | ### tmux_sidebar.sh 85 | 86 | Create a sidebar (e.g. for reading manpages) and kill when done. 87 | 88 | ### tmux_topbar.sh 89 | 90 | Create a vertical split and kill when done. 91 | 92 | ## 6. TODO 93 | 94 | * Have a configurable size modifier so nobody needs to edit the script. 95 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-midnight -------------------------------------------------------------------------------- /docs/_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {% seo %} 8 | 9 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | 21 | 33 |
34 |
35 |
36 |

{{ site.title | default: site.github.repository_name }}

37 |

{{ site.description | default: site.github.project_tagline }}

38 |
39 | Project maintained by {{ site.github.owner_name }} 40 | Hosted on GitHub Pages — Theme by mattgraham 41 |
42 | 43 | {{ content }} 44 | 45 |
46 |
47 |

Steven Saus injects people with radioactivity for his day job, but only to serve the forces of good.
Mostly.

48 |

49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |

60 |
61 | 62 | {% if site.google_analytics %} 63 | 71 | {% endif %} 72 | 73 | 74 | -------------------------------------------------------------------------------- /docs/assets/css/style.css: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | @import "{{ site.theme }}"; 5 | 6 | #header { 7 | margin: 0 auto !important; 8 | } 9 | 10 | #header > nav { 11 | margin: 0 auto; 12 | background: none !important; 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /tdab-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uriel1998/tdab/22cd54003cb9cd9af0abbc24c18b33a94263d84b/tdab-icon.png -------------------------------------------------------------------------------- /tdab-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uriel1998/tdab/22cd54003cb9cd9af0abbc24c18b33a94263d84b/tdab-logo.png -------------------------------------------------------------------------------- /tdab-open-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uriel1998/tdab/22cd54003cb9cd9af0abbc24c18b33a94263d84b/tdab-open-graph.png -------------------------------------------------------------------------------- /tdab_example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uriel1998/tdab/22cd54003cb9cd9af0abbc24c18b33a94263d84b/tdab_example.gif -------------------------------------------------------------------------------- /tdab_example.mkv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uriel1998/tdab/22cd54003cb9cd9af0abbc24c18b33a94263d84b/tdab_example.mkv -------------------------------------------------------------------------------- /tmux_devour.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ############################################################################## 4 | # 5 | # tmux-devour 6 | # (c) Steven Saus 2020 7 | # Licensed under the MIT license 8 | # 9 | ############################################################################## 10 | 11 | HOLD_VAR="" 12 | if [ "$1" == "--hold" ] || [ "$1" == "-h" ];then 13 | HOLD_VAR="True" 14 | shift 15 | fi 16 | c_tmux=$(env | grep -c TMUX) 17 | if [ $c_tmux -gt 0 ];then 18 | command=$(echo "$@") 19 | o_pane=$(tmux list-panes -F "#D") 20 | tmux split-window -h 21 | c_pane=$(tmux list-panes -F "#D" | grep -v "$o_pane") 22 | printf '\033]2;%s\033\\' 'devour' 23 | tmux resize-pane -t "$c_pane" -R 20 24 | tmux select-pane -m -t "$c_pane" 25 | if [ "$HOLD_VAR" == "True" ];then 26 | command2=$(echo "eval \"${command}\" ; read ; tmux kill-pane -t ${c_pane}") 27 | else 28 | command2=$(echo "eval \"${command}\" ; tmux kill-pane -t ${c_pane}") 29 | fi 30 | tmux resize-pane -Z -t "$c_pane" 31 | tmux send-keys -t "$c_pane" "$command2" C-m 32 | else 33 | eval "$@" 34 | fi 35 | -------------------------------------------------------------------------------- /tmux_sidebar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ############################################################################## 4 | # 5 | # tmux-sidebar 6 | # (c) Steven Saus 2020 7 | # Licensed under the MIT license 8 | # 9 | ############################################################################## 10 | # maybe use these to dynamically change width? 11 | cols=$(tput cols) 12 | 13 | 14 | divide_and_round_up() { 15 | echo "scale=2; ($1 + $2 - 1) / $2" | bc -l | awk '{printf("%d\n",$0+0.5)}' 16 | } 17 | 18 | 19 | # if percent of offset ( 20 | offset=1.5 21 | if [ "$1" == "--offset" ] || [ "$1" == "-o" ];then 22 | shift 23 | offset=$(bc -l <<<"scale=2;(2-$1/50)+1") 24 | shift 25 | fi 26 | 27 | HOLD_VAR="" 28 | if [ "$1" == "--hold" ] || [ "$1" == "-h" ];then 29 | HOLD_VAR="True" 30 | shift 31 | fi 32 | 33 | c_tmux=$(env | grep -c TMUX) 34 | if [ $c_tmux -gt 0 ];then 35 | half_cols=$(divide_and_round_up $cols 2) 36 | one_third=$(divide_and_round_up $cols $offset) 37 | move_width=$(( one_third-half_cols )) 38 | command=$(echo "$@") 39 | o_pane=$(tmux list-panes -F "#D") 40 | tmux split-window -h 41 | c_pane=$(tmux list-panes -F "#D" | grep -v "$o_pane") 42 | # Uncomment for left hand sidebar 43 | #tmux swap-pane -s "$o_pane" -t "$c_pane" 44 | printf '\033]2;%s\033\\' 'sidebar' 45 | tmux resize-pane -t "$c_pane" -R ${move_width} 46 | if [ "$HOLD_VAR" == "True" ];then 47 | command2=$(echo "eval \"${command}\" ; read ;tmux kill-pane -t ${c_pane}") 48 | else 49 | command2=$(echo "eval \"${command}\" ; tmux kill-pane -t ${c_pane}") 50 | fi 51 | tmux send-keys -t "$c_pane" "$command2" C-m 52 | tmux last-pane 53 | else 54 | eval "$@" 55 | fi 56 | 57 | -------------------------------------------------------------------------------- /tmux_topbar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ############################################################################## 4 | # 5 | # tmux-topbar 6 | # (c) Steven Saus 2020 7 | # Licensed under the MIT license 8 | # 9 | ############################################################################## 10 | lines=$(tput lines) 11 | 12 | divide_and_round_up() { 13 | echo "scale=2; ($1 + $2 - 1) / $2" | bc -l | awk '{printf("%d\n",$0+0.5)}' 14 | } 15 | 16 | 17 | # if percent of offset ( 18 | offset=1.4 19 | if [ "$1" == "--offset" ] || [ "$1" == "-o" ];then 20 | shift 21 | offset=$(bc -l <<<"scale=2;(2-$1/50)+1") 22 | shift 23 | fi 24 | 25 | HOLD_VAR="" 26 | if [ "$1" == "--hold" ] || [ "$1" == "-h" ];then 27 | HOLD_VAR="True" 28 | shift 29 | fi 30 | 31 | 32 | c_tmux=$(env | grep -c TMUX) 33 | if [ $c_tmux -gt 0 ];then 34 | half_lines=$(divide_and_round_up $lines 2) 35 | one_fifth=$(divide_and_round_up $lines $offset) 36 | move_height=$(( one_fifth-half_lines)) 37 | command=$(echo "$@") 38 | o_pane=$(tmux list-panes -F "#D") 39 | tmux split-window -v 40 | c_pane=$(tmux list-panes -F "#D"| grep -v "$o_pane") 41 | tmux swap-pane -s "$o_pane" -t "$c_pane" 42 | printf '\033]2;%s\033\\' 'topbar' 43 | tmux resize-pane -t "$c_pane" -U $move_height 44 | if [ "$HOLD_VAR" == "True" ];then 45 | command2=$(echo "eval \"${command}\" ; read; tmux kill-pane -t ${c_pane}") 46 | else 47 | command2=$(echo "eval \"${command}\" ; read ;tmux kill-pane -t ${c_pane}") 48 | fi 49 | tmux send-keys -t "$c_pane" "$command2" C-m 50 | tmux last-pane 51 | else 52 | eval "$@" 53 | fi 54 | --------------------------------------------------------------------------------