aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/bottom_window_drawer.sh29
-rwxr-xr-xscripts/tmux_open_filename_in_vim.sh64
-rwxr-xr-xscripts/window_renum.sh (renamed from window_renum.sh)0
-rw-r--r--templates/template.yaml2
-rw-r--r--tmux.config2
5 files changed, 95 insertions, 2 deletions
diff --git a/scripts/bottom_window_drawer.sh b/scripts/bottom_window_drawer.sh
new file mode 100755
index 0000000..7c3dcaf
--- /dev/null
+++ b/scripts/bottom_window_drawer.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+# vim: set filetype=sh :
+#
+# Author: Cody Hiar
+# Date: 2017-04-25
+#
+# Purpose: To either close or open a bottom drawer window
+#
+# Set options:
+# e: Stop script if command fails
+# u: Stop script if unset variable is referenced
+# x: Debug, print commands as they are executed
+set -eu
+
+# Immutable globals
+readonly ARGS=( "$@" )
+readonly PROGNAME=$(basename "$0")
+
+# Main loop of program
+main() {
+ NUM_PANES=$(tmux list-panes | wc -l)
+ if [[ "$NUM_PANES" == 1 ]]; then
+ tmux split-window -c '#{pane_current_path}'
+ tmux resize-pane -t 2 -y 20
+ else
+ tmux kill-pane -t 2
+ fi
+}
+main
diff --git a/scripts/tmux_open_filename_in_vim.sh b/scripts/tmux_open_filename_in_vim.sh
new file mode 100755
index 0000000..6a799e4
--- /dev/null
+++ b/scripts/tmux_open_filename_in_vim.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# Author: Cody Hiar
+# Date: 2017-04-22
+#
+# Purpose: The purpose of this script is to accept a file name then find a tmux
+# pane that is currently running either vim or neovim and tell that pane to open
+# up the file. This script is meant to be used with a fuzzy find such as fzf so
+# that you can use an external fuzzy finder but still integrate it with vim
+#
+# Set options:
+# e: Stop script if command fails
+# u: Stop script if unset variable is referenced
+# x: Debug, print commands as they are executed
+# set -eu
+
+# Immutable globals
+readonly ARGS=( "$@" )
+readonly PROGNAME=$(basename "$0")
+readonly USAGE=$(cat << EOF
+usage: $PROGNAME file_name
+
+Script that will search for a tmux pane running vim and will tell vim to open a
+file specified by the passed in arguement
+
+OPTIONS:
+ -h Display help options
+EOF
+)
+
+# Function for processing arguments
+cmdline() {
+ while getopts "h" FLAG; do
+ case "$FLAG" in
+ h)
+ echo "$USAGE"
+ exit 0
+ ;;
+ *)
+ exit 0
+ ;;
+ esac
+ done
+}
+
+# Main loop of program
+main() {
+ if [[ -z ${ARGS[0]} ]]; then
+ exit
+ fi
+ cmdline "${ARGS[@]}"
+ panes=($(tmux list-panes| awk -F: '{ print $1 }'))
+ for pane in "${panes[@]}"; do
+ pane_tty=$(tmux display -p -t "$pane" '#{pane_tty}')
+ ps -o state= -o comm= -t "$pane_tty" \
+ | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$' &> /dev/null
+ if [[ "$?" == 0 ]]; then
+ filename="${ARGS[0]}"
+ tmux send-keys -t "$pane" ":e $filename" Enter
+ tmux select-pane -t "$pane"
+ fi
+ done
+}
+main
diff --git a/window_renum.sh b/scripts/window_renum.sh
index 19e5825..19e5825 100755
--- a/window_renum.sh
+++ b/scripts/window_renum.sh
diff --git a/templates/template.yaml b/templates/template.yaml
index d2a4a09..3218321 100644
--- a/templates/template.yaml
+++ b/templates/template.yaml
@@ -9,8 +9,6 @@ windows:
- shell_command:
- nvim
focus: true
- - shell_command:
- - tmux resizep -t 2 -y 20; tmux resize-pane -Z -t 1; clear
- window_name: docker
layout: even-vertical
panes:
diff --git a/tmux.config b/tmux.config
index 8901170..594dbcf 100644
--- a/tmux.config
+++ b/tmux.config
@@ -26,6 +26,8 @@ bind C-p previous-window
bind a set-window-option synchronize-panes
# Remap zoom, sleeping tmux way too much
bind C-v resize-pane -Z
+# Binding for bottom drawer script
+bind C-m run-shell "$HOME/.tmux/scripts/bottom_window_drawer.sh"
#####################################
# Settings