-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continuing in the tradition of `portool` and `gg`, this is `dog`. At the moment, it doesn't do much at all (just `go` to jump to a tmux session and `help` to show help). I resurrected the completion from the last tool, but note that for now there are no commands that take file arguments; that bit is commented out for now because I don't want to have to look it up again in the future when I have such a subcommand.
- Loading branch information
Showing
8 changed files
with
435 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#compdef dog | ||
|
||
typeset -A opt_args | ||
|
||
_arguments -C \ | ||
'1:cmd:->cmds' \ | ||
'*:: :->args' \ | ||
&& ret=0 | ||
|
||
case "$state" in | ||
(cmds) | ||
local commands; commands=( | ||
"go:Go to (or start) tmux session" | ||
"help:Show help" | ||
) | ||
_describe -t commands 'command' commands && ret=0 | ||
;; | ||
# (args) | ||
# case $line[1] in | ||
# (command_that_takes_a_file_argument) | ||
# _files && ret=0 | ||
# ;; | ||
# esac | ||
# ;; | ||
esac | ||
|
||
return $ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# Wrapper script to stop recent Node versions from complaining about: | ||
# TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for gg | ||
|
||
LIB=$(cd $(dirname "$BASH_SOURCE")/..; echo "$(pwd)/lib") | ||
|
||
exec node "$LIB/dog/main.js" "$@" |
31 changes: 31 additions & 0 deletions
31
aspects/dotfiles/files/.zsh/datadog/lib/dog/helpers/.common.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# Based on: https://stackoverflow.com/a/8351489/2103996 | ||
backoff() { | ||
local max_attempts=${ATTEMPTS-5} | ||
local timeout=${TIMEOUT-1} | ||
local attempt=1 | ||
local exitCode=0 | ||
|
||
while (( $attempt < $max_attempts )) | ||
do | ||
if "$@" | ||
then | ||
return 0 | ||
else | ||
exitCode=$? | ||
fi | ||
|
||
echo "error: retrying in $timeout..." 1>&2 | ||
sleep $timeout | ||
attempt=$(( attempt + 1 )) | ||
timeout=$(( timeout * 2 )) | ||
done | ||
|
||
if [[ $exitCode != 0 ]] | ||
then | ||
echo "error: maximum attempt count exceeded ($@)" 1>&2 | ||
fi | ||
|
||
return $exitCode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
SESSION=web-ui | ||
BASE="$HOME/dev/web-ui" | ||
|
||
if [ ! -d "$BASE" ]; then | ||
echo "error: Cannot find BASE directory" | ||
exit 1 | ||
fi | ||
|
||
if tmux has-session -t $SESSION 2> /dev/null; then | ||
TARGET="$SESSION" | ||
else | ||
TARGET="$SESSION:vim.right" | ||
|
||
cd "$BASE" | ||
|
||
# 1. Main editor window: Vim on the left, shell on the right. | ||
tmux new-session -d -s $SESSION -n vim -x $(tput cols) -y $(tput lines) | ||
tmux split-window -t $SESSION:vim -h | ||
tmux send-keys -t $SESSION:vim.left "vim -c CommandT" Enter | ||
|
||
# 2. General shell use: two panes separated by a vertical split. | ||
tmux new-window -t $SESSION -n zsh | ||
tmux split-window -t $SESSION:zsh -h | ||
|
||
fi | ||
|
||
if [ -n "$TMUX" ]; then | ||
tmux switch-client -t "$TARGET" | ||
else | ||
tmux attach -t "$TARGET" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
echo "Usage: dog <subcommand> [...arguments]" | ||
echo | ||
echo "Subcommands:" | ||
echo " go 🚗 go to (or start a) tmux session" | ||
echo " help 🤷 show this help" |
Oops, something went wrong.