{"id":22901254,"url":"https://github.com/mooerslab/tmux-bashed","last_synced_at":"2025-04-01T05:41:54.798Z","repository":{"id":263641199,"uuid":"891033526","full_name":"MooersLab/tmux-bashed","owner":"MooersLab","description":"Bash function to automate the setting up of tmux sessions, windows, and panes.","archived":false,"fork":false,"pushed_at":"2024-11-30T15:16:27.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T03:41:56.709Z","etag":null,"topics":["automation","bash-scripting","daily-setup","tmux","workflow"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MooersLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-19T15:58:42.000Z","updated_at":"2024-11-30T15:16:30.000Z","dependencies_parsed_at":"2024-12-14T01:32:42.309Z","dependency_job_id":"c888bb55-3c4e-41ea-8768-01541eb73656","html_url":"https://github.com/MooersLab/tmux-bashed","commit_stats":null,"previous_names":["mooerslab/tmux-bashed"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MooersLab%2Ftmux-bashed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MooersLab%2Ftmux-bashed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MooersLab%2Ftmux-bashed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MooersLab%2Ftmux-bashed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MooersLab","download_url":"https://codeload.github.com/MooersLab/tmux-bashed/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246591782,"owners_count":20801984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bash-scripting","daily-setup","tmux","workflow"],"created_at":"2024-12-14T01:32:31.688Z","updated_at":"2025-04-01T05:41:54.779Z","avatar_url":"https://github.com/MooersLab.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Version](https://img.shields.io/static/v1?label=tmux-bashed\u0026message=0.2\u0026color=brightcolor)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n\n# Automated opening of iterm2 tabs and the setup of tmux sessions, windows, and panes\n\n## The problem\n\nSave the time lost to rebuilding the same tmux sessions.\nThe bash function in the script above takes about two minutes to run.\nThe manual building of my setup may take ten to 20 minutes.\nThe time savings are significant.\nMay I do something significant with my freed time!\n\n## The solution\n\nA bash function called `wf`, **w**ork **f**low. \nEnter `wf` and go get some coffee while your computer prepares your workflow for the day.\nThis approach could save 50-200 keystrokes per day.\n\n\n## Usage\n\n```bash\nchmod +x tmux.sh\nsource ./tmux.sh # add to your .zshrc file eventually.\nwf\n```\n\n## Precaution\n\nThis supplied function serves as a template.\nIt will not work entirely on your system because it calls aliases or functions defined elsewhere.\n\n\n## Requirements\n\n- Willingness to customize for your workflow.\n- Mac OS but adaptable to other platforms.\n- iterm2\n- `advanced-tmux.config` from the [MooersLab/tmux-rocks](https://github.com/MooersLab/tmux-rocks) repo.\n- Current version of tmux (install with home brew).\n- Current version of tmux-plugin-manager.\n- AppleScript\n- A text editor to customize the `tmux.sh`.\n\n## Example of autogenerated ten tmux windows in one iterm2 tab\n\n![10windowsWeather](https://github.com/user-attachments/assets/8a649d6f-aaf6-455e-a78a-ab66606035f9)\n\nFive iterm2 tabs were created and populated with five tmux sessions.\nThe current window is the highlighted tmux tab.\nThere is a ten-window limit per iterm2 tab.\nThe color scheme is imposed by the selected profile in iterm2.\n\n\n## Tab titles\nThe default tab title in iterm2 will be `tmux`. If you have ten iterm2 tabs open, this row of ten `tmux` is not helpful.\nAfter pasting the following code in your `.zshrc` file, you can change the title of an iterm2 tab by entering `tt`. \nI modified the bash function by adding a `tt` command to each call of applescript to create a new tab.\n\n```zsh\nDISABLE_AUTO_TITLE=\"true\"\ntt () {\n    echo -e \"\\033];$@\\007\"\n}\n```\n\n## Coloring the iterm2 tabs\n\nColoring the iterm2 tab can also enhance your identification of the tab of interest.\nThe following code assigns a random color for the tab each time a new tab is opened.\nAdd this code to your zshrc file.\n\n```zsh\n# randomly color new tabs.\nPRELINE=\"\\r\\033[A\"\n\nfunction random {\n    echo -e \"\\033]6;1;bg;red;brightness;$((1 + $RANDOM % 255))\\a\"$PRELINE\n    echo -e \"\\033]6;1;bg;green;brightness;$((1 + $RANDOM % 255))\\a\"$PRELINE\n    echo -e \"\\033]6;1;bg;blue;brightness;$((1 + $RANDOM % 255))\\a\"$PRELINE\n}\n\nfunction color {\n    case $1 in\n    green)\n    echo -e \"\\033]6;1;bg;red;brightness;57\\a\"$PRELINE\n    echo -e \"\\033]6;1;bg;green;brightness;197\\a\"$PRELINE\n    echo -e \"\\033]6;1;bg;blue;brightness;77\\a\"$PRELINE\n    ;;\n    red)\n    echo -e \"\\033]6;1;bg;red;brightness;270\\a\"$PRELINE\n    echo -e \"\\033]6;1;bg;green;brightness;60\\a\"$PRELINE\n    echo -e \"\\033]6;1;bg;blue;brightness;83\\a\"$PRELINE\n    ;;\n    orange)\n    echo -e \"\\033]6;1;bg;red;brightness;227\\a\"$PRELINE\n    echo -e \"\\033]6;1;bg;green;brightness;143\\a\"$PRELINE\n    echo -e \"\\033]6;1;bg;blue;brightness;10\\a\"$PRELINE\n    ;;\n    *)\n    random\n    esac\n}\n\ncolor\n```\n\nWith `tt` and random coloring enabled, my iterm2 terminal has been enhanced (see image  below).\nThe opened tab is indicated by the white line under the tab.\nThe tabs labeled `zsh` are not tmux sessions or were intended tmux sessions,\nbut a bug in the script failed to launch a tmux session in the iterm2 tab.\nThe `updates` tab had the following command passed, 'brew update \u0026\u0026 brew upgrade \u0026\u0026 msu'.\nThis runs brew update and then an alias to a series of macports commands to update macports and clean up.\n\n\u003cimg width=\"1363\" alt=\"Screenshot 2024-11-30 at 8 12 46 AM\" src=\"https://github.com/user-attachments/assets/569a5ba2-bc12-4d54-80bb-867f6b3fe76e\"\u003e\n\n## Passing commands to applescript\nThe `tt` commands were added to the calls to applescript to open new iterm2 tabs with specified titles.\nThe \n\n## Update history\n\n|Version      | Changes                                                                                                                                   | Date                 |\n|:------------|:------------------------------------------------------------------------------------------------------------------------------------------|:---------------------|\n| Version 0.1 |   Added badges, funding, and update table.  Initial commit.                                                                               | 2024 November 19     |\n| Version 0.2 |   Added code for adding titles to iterm2 tabs and randomly coloring the iterm2 tabs.  Added updates tmux session. Changed function namne from twf to wf. | 2024 November 30     |\n\n\n## Sources of funding\n\n- NIH: R01 CA242845\n- NIH: R01 AI088011\n- NIH: P30 CA225520 (PI: R. Mannel)\n- NIH: P20 GM103640 and P30 GM145423 (PI: A. West)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmooerslab%2Ftmux-bashed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmooerslab%2Ftmux-bashed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmooerslab%2Ftmux-bashed/lists"}