Populate repo
This commit is contained in:
42
tmux/.tmux/plugins/vim-tmux-navigator/pattern-check
Normal file
42
tmux/.tmux/plugins/vim-tmux-navigator/pattern-check
Normal file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Collection of various test strings that could be the output of the tmux
|
||||
# 'pane_current_comamnd' message. Included as regression test for updates to
|
||||
# the inline grep pattern used in the `.tmux.conf` configuration
|
||||
|
||||
set -e
|
||||
|
||||
RED=$(tput setaf 1)
|
||||
GREEN=$(tput setaf 2)
|
||||
YELLOW=$(tput setaf 3)
|
||||
NORMAL=$(tput sgr0)
|
||||
|
||||
vim_pattern='(^|\/)g?(view|n?vim?x?)(diff)?$'
|
||||
match_tests=(vim Vim VIM vimdiff /usr/local/bin/vim vi gvim view gview nvim vimx)
|
||||
no_match_tests=( /Users/christoomey/.vim/thing /usr/local/bin/start-vim )
|
||||
|
||||
display_matches() {
|
||||
for process_name in "$@"; do
|
||||
printf "%s %s\n" "$(matches_vim_pattern $process_name)" "$process_name"
|
||||
done
|
||||
}
|
||||
|
||||
matches_vim_pattern() {
|
||||
if echo "$1" | grep -iqE "$vim_pattern"; then
|
||||
echo "${GREEN}match${NORMAL}"
|
||||
else
|
||||
echo "${RED}fail${NORMAL}"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
echo "Testing against pattern: ${YELLOW}$vim_pattern${NORMAL}\n"
|
||||
|
||||
echo "These should all ${GREEN}match${NORMAL}\n----------------------"
|
||||
display_matches "${match_tests[@]}"
|
||||
|
||||
echo "\nThese should all ${RED}fail${NORMAL}\n---------------------"
|
||||
display_matches "${no_match_tests[@]}"
|
||||
}
|
||||
|
||||
main
|
Reference in New Issue
Block a user