Skip to content

Instantly share code, notes, and snippets.

@juboba
Last active September 5, 2020 15:11
Show Gist options
  • Save juboba/83ee3fa643ecf30c404e261b9fa5be0a to your computer and use it in GitHub Desktop.
Save juboba/83ee3fa643ecf30c404e261b9fa5be0a to your computer and use it in GitHub Desktop.
tmux + oh-my-tmux + tmuxp installer with nix
#!/bin/sh
#
# @name: tmux with tmuxp sessions with oh-my-tmux config
# @author: juboba@genial.ly
# @description: pretty self explanatory
#
GENIALLY_SESSION_CONFIG="$HOME/.tmuxp/genially.yml"
TMUX_CONF="$HOME/.tmux.conf"
TMUX_CONF_LOCAL="$HOME/.tmux.conf.local"
clear
echo '
```...```
`--:::///::/::.`
`.--/shmNNNNNmdyo+/:` Welcome to tmux bundle install for the Genially team
`--/hNNy+:...-/mNNds++- =====================================================
.--sNNs. `/ossosNNNNNh++:
`--oNNo oNNNNNNNNNNNNNy++. This script will try to install the following software in your system:
.--dNN` /NNNNNhoyNNNmNNm++:
.::dNN` :NNNNm- `hd``yNm++: - nix: package manager (for installing tmux and tmuxp)
`::oNNs` /mNNNNdmy. -mNy++. https://nixos.org/nix/manual/
.::sNNh: -/++:. `omNho+:
.::+dNNds+:-:/oyNNdso+- - tmux: terminal multiplexer (the main dish)
`-:/+sdmNNNNNmdyo++:` https://github.com/tmux/tmux/wiki
`.:///+++++++/:-`
``.....`` - oh-my-tmux: configuration for tmux (for colors and bindings).
https://github.com/gpakosz/.tmux
- tmuxp: tmux session helper
https://tmuxp.git-pull.com/
'
orange() {
echo "\033[38;2;232;130;13m$1\033[m"
}
red() {
echo "\033[38;2;255;10;10m$1\033[m"
}
printf "Shall I continue? [y/N] "
IFS= read -r confirm
[ "$confirm" != "y" ] && exit 1
echo "Installing $(red nix) for your user..."
curl -L https://nixos.org/nix/install | sh -
# Load the nix-profile in the current shell session
. $HOME/.nix-profile/etc/profile.d/nix.sh
echo "Installing $(red tmux) and $(red tmuxp) with nix..."
nix-env -i tmux tmuxp
echo "Creating ~/.tmuxp..."
mkdir $HOME/.tmuxp
echo "Getting oh-my-tmux..."
git clone https://github.com/gpakosz/.tmux.git $HOME/.tmux
echo "Creating configs..."
([ -L $TMUX_CONF ] && echo "$TMUX_CONF exists, skipping...") || ln -s $HOME/.tmux/.tmux.conf $TMUX_CONF
([ -f $TMUX_CONF_LOCAL ] && echo "$TMUX_CONF_LOCAL exists, skipping...") || cp $HOME/.tmux/.tmux.conf.local $TMUX_CONF_LOCAL
echo "Where should I look for the mono-repo?
(full path, e.g.: ~/work/mono-repo, empty for not creating a session config) "
IFS= read -r monoRepoPath
if ([ "$monoRepoPath" ])
then
echo "
session_name: Genially
start_directory: $monoRepoPath
windows:
- window_name: New Api
panes:
- yarn new-api
- window_name: Old Api
panes:
- yarn api
- window_name: Panel
panes:
- yarn panel
- window_name: Editor
panes:
- yarn editor
- window_name: View
panes:
- shell_command:
- yarn view:api
- shell_command:
- yarn view:client
" > $GENIALLY_SESSION_CONFIG
echo "Path to the web (full path, empty for not adding entry): "
IFS= read -r webPath
[ "$webPath" ] && echo "
- window_name: Web
panes:
- shell_command:
- cd $webPath
- npm run dev
" >> $GENIALLY_SESSION_CONFIG
echo "Path to the databases repo (full path, empty for not adding entry): "
IFS= read -r databasesPath
[ "$databasesPath" ] && echo "
- window_name: Mongo, PostgreSQL, pgAdmin
panes:
- shell_command:
- cd $databasesPath
- docker-compose up
" >> $GENIALLY_SESSION_CONFIG
else
echo "No config created."
fi
echo "
...and we're done!
To configure tmux: $(red $TMUX_CONF_LOCAL)
To configure your tmuxp sessions create your yml files in: $(red ~/.tmuxp/)"
[ "$monoRepoPath" ] && echo "
I created: $(red $GENIALLY_SESSION_CONFIG) you can modify it as you wish or
use it as a template to create new sessions. Read tmuxp docs for that.
"
echo "
To start your genially session type:
$ $(orange "tmuxp load genially")
You can create an alias for that so that you don't need to type so much (I'm that lazy).
If you want to remove everything you can just:
$(orange "nix-env -e tmux tmuxp")
you may also want to remove the tmux related configs in your $(orange \$HOME)
If you also want to get rid of nix:
$(orange "sudo rm -rf /nix")
$(orange "rm -rf ~/.nix*")
and remove the line added for nix in your shell's profile file
(e.g. .bash_profile)
"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment