aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rwxr-xr-xscripts/test.sh12
-rwxr-xr-xsrc/main.sh (renamed from plugin.tmux)16
-rwxr-xr-xsrc/tmux.sh (renamed from scripts/tmux.sh)2
-rwxr-xr-xsrc/toggle-term.sh (renamed from scripts/toggle-term.sh)6
-rw-r--r--tests/tests.sh4
6 files changed, 28 insertions, 14 deletions
diff --git a/README.md b/README.md
index d95f7c6..38f832d 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ git clone https://git.eugenetriguba.com/tmux-toggle-term
Add to your tmux configuration:
```tmux
-run-shell '~/.tmux/plugins/tmux-toggle-term/plugin.tmux'
+run-shell '~/.tmux/plugins/tmux-toggle-term/src/main.sh'
```
## Usage
diff --git a/scripts/test.sh b/scripts/test.sh
new file mode 100755
index 0000000..e123124
--- /dev/null
+++ b/scripts/test.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+set -o errexit
+set -o nounset
+
+DIR=$(dirname "$0")
+ROOT_DIR="$DIR/../"
+
+main() {
+ "$ROOT_DIR/vendor/bats/bin/bats" "$ROOT_DIR/tests/tests.sh"
+}
+
+main "$@"
diff --git a/plugin.tmux b/src/main.sh
index 43d587a..4bc01c2 100755
--- a/plugin.tmux
+++ b/src/main.sh
@@ -1,11 +1,9 @@
#!/bin/sh
-# vi: ft=sh
-set -e
+set -o errexit
+set -o nounset
CURRENT_DIR="$(dirname "$0")"
-. "$CURRENT_DIR/scripts/tmux.sh"
-
-SCRIPTS_DIR="${CURRENT_DIR}/scripts"
+. "$CURRENT_DIR/tmux.sh"
FLOAT_KEYBINDING="C-f"
FLOAT_KEYBINDING_OPTION="@toggle-term-float-key"
@@ -23,18 +21,18 @@ main() {
if [ "$(float_enabled)" = "true" ]; then
float_key_binding="$(float_key)"
if [ "$(use_prefix_for_float)" = "true" ]; then
- $tmux_cmd bind-key "$float_key_binding" run-shell -b "$SCRIPTS_DIR/toggle-term.sh float"
+ $tmux_cmd bind-key "$float_key_binding" run-shell -b "$CURRENT_DIR/toggle-term.sh float"
else
- $tmux_cmd bind-key -n "$float_key_binding" run-shell -b "$SCRIPTS_DIR/toggle-term.sh float"
+ $tmux_cmd bind-key -n "$float_key_binding" run-shell -b "$CURRENT_DIR/toggle-term.sh float"
fi
fi
if [ "$(split_enabled)" = "true" ]; then
split_key_binding="$(split_key)"
if [ "$(use_prefix_for_split)" = "true" ]; then
- $tmux_cmd bind-key "$split_key_binding" run-shell -b "$SCRIPTS_DIR/toggle-term.sh split"
+ $tmux_cmd bind-key "$split_key_binding" run-shell -b "$CURRENT_DIR/toggle-term.sh split"
else
- $tmux_cmd bind-key -n "$split_key_binding" run-shell -b "$SCRIPTS_DIR/toggle-term.sh split"
+ $tmux_cmd bind-key -n "$split_key_binding" run-shell -b "$CURRENT_DIR/toggle-term.sh split"
fi
fi
}
diff --git a/scripts/tmux.sh b/src/tmux.sh
index b919043..2be86de 100755
--- a/scripts/tmux.sh
+++ b/src/tmux.sh
@@ -1,4 +1,6 @@
#!/bin/sh
+set -o errexit
+set -o nounset
get_tmux_cmd() {
TMUX_CMD="tmux"
diff --git a/scripts/toggle-term.sh b/src/toggle-term.sh
index 0cc7414..3554ec0 100755
--- a/scripts/toggle-term.sh
+++ b/src/toggle-term.sh
@@ -1,4 +1,7 @@
#!/bin/sh
+set -o errexit
+set -o nounset
+
CURRENT_DIR="$(dirname "$0")"
. "$CURRENT_DIR/tmux.sh"
@@ -70,8 +73,7 @@ toggle_split() {
# and toggled it, so it is closed, and now we want to open it again.
# In this case, our single main zoomed in window would be what is on
# the screen and we want to open back up our split pane.
- zoomed_panes="$(echo "${panes_list}" | grep Z)"
- if [ -n "${zoomed_panes}" ]; then
+ if echo "${panes_list}" | grep -q Z; then
# To open back up our split pane, we can switch focus to the previously
# active pane in the current window of the current session.
#
diff --git a/tests/tests.sh b/tests/tests.sh
index 88e34aa..ed4eaa8 100644
--- a/tests/tests.sh
+++ b/tests/tests.sh
@@ -3,8 +3,8 @@
load '../vendor/bats-support/load'
load '../vendor/bats-assert/load'
-TOGGLE_TERM_SCRIPT_PATH="$BATS_TEST_DIRNAME/../scripts/toggle-term.sh"
-PLUGIN_SCRIPT_PATH="$BATS_TEST_DIRNAME/../plugin.tmux"
+TOGGLE_TERM_SCRIPT_PATH="$BATS_TEST_DIRNAME/../src/toggle-term.sh"
+PLUGIN_SCRIPT_PATH="$BATS_TEST_DIRNAME/../src/main.sh"
setup() {
export TMUX_SOCKET="test$$"