Skip to content

Instantly share code, notes, and snippets.

@jlogsdon
Created August 6, 2015 14:18
Show Gist options
  • Save jlogsdon/5f2cb81be8ce3e2cb4f8 to your computer and use it in GitHub Desktop.
Save jlogsdon/5f2cb81be8ce3e2cb4f8 to your computer and use it in GitHub Desktop.
This requires the `z` script: https://github.com/rupa/z (and this will only know about directories after you have visited it once, so do that before you can use this for a given path)
#!/usr/bin/env zsh
# Takes a single argument: a partial folder name. If no tmux session is active a new one is started; then we
# - `z $partial; nvim` in a fresh window
# - `z $partial` in a fresh window, left tab
# - `z $partial` in right tab of previous window
main() {
local new_session=0
tmux has-session 2> /dev/null
if [ $? -eq 1 ]; then
new_session=1
tmux new-session -d -n ${1}:vim
else
tmux new-window -n ${1}:vim
fi
tmux send-keys "z ${1}; nvim" Enter
tmux new-window -n ${1}:shell
tmux send-keys "z ${1}" Enter
tmux split-window -h
# This layout is like 2/3 left pane 1/3 right pane? ish?
tmux select-layout '55cd,208x54,0,0{120x54,0,0,85,87x54,121,0,86}' > /dev/null
tmux send-keys "z ${1}" Enter
# Attach to the new session if we created one
if [ $new_session -eq 1 ]; then
tmux attach
fi
}
main $*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment