├── functions ├── __howzittouch_has_buildnotes.fish ├── __howzittouch_clear_buttons.fish ├── __howzittouch_osc_command.fish ├── __howzittouch_list_tasks.fish ├── __howzittouch_keydown.fish └── __howzittouch.fish ├── key_bindings.fish ├── init.fish ├── LICENSE └── README.md /functions/__howzittouch_has_buildnotes.fish: -------------------------------------------------------------------------------- 1 | function __howzittouch_has_buildnotes 2 | set notes {B,b}uild*.{txt,md} 3 | if count $notes >/dev/null 4 | return 0 5 | else 6 | return 1 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /functions/__howzittouch_clear_buttons.fish: -------------------------------------------------------------------------------- 1 | function __howzittouch_clear_buttons 2 | for idx in (seq 20) 3 | __howzittouch_osc_command (printf 'SetKeyLabel=%s=%s' F$idx F$idx) 4 | bind -e f$idx 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /key_bindings.fish: -------------------------------------------------------------------------------- 1 | for n in (seq 20) 2 | if test "$__fish_active_key_bindings" = fish_vi_key_bindings 3 | bind -M insert -k f$n "__howzittouch_keydown $n" 4 | else 5 | bind -k f$n "__howzittouch_keydown $n" 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /init.fish: -------------------------------------------------------------------------------- 1 | set -gx __howzittouch_wd_has_tasks 0 2 | 3 | function __howzittouch_pwd -v PWD 4 | if test "$TERM_PROGRAM" = "iTerm.app" 5 | __howzittouch 6 | end 7 | end 8 | 9 | # if test "$TERM_PROGRAM" = "iTerm.app" 10 | # __howzittouch 11 | # end 12 | -------------------------------------------------------------------------------- /functions/__howzittouch_osc_command.fish: -------------------------------------------------------------------------------- 1 | function __howzittouch_osc_command -a cmd 2 | switch "$TERM" 3 | case 'screen*' 4 | printf '\033Ptmux;\033\033]' 5 | case '*' 6 | printf '\033]' 7 | end 8 | 9 | printf '1337;%s' "$cmd" 10 | 11 | switch "$TERM" 12 | case 'screen*' 13 | printf '\a\033\\"' 14 | case '*' 15 | printf '\a' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /functions/__howzittouch_list_tasks.fish: -------------------------------------------------------------------------------- 1 | set -g __howzittouch_script "howzit" 2 | 3 | function __howzittouch_list_tasks 4 | set -l stat (stat -f "%m" {B,b}uild*.{txt,md}) 5 | 6 | if test "$stat" != "$__howzittouch_mtime" 7 | set -g __howzittouch_mtime $stat 8 | set -g __howzittouch_packages (howzit -T ^/dev/null) 9 | set -p __howzittouch_packages (howzit --title-only ^/dev/null)":" 10 | end 11 | 12 | printf "%s\n" $__howzittouch_packages 13 | end 14 | -------------------------------------------------------------------------------- /functions/__howzittouch_keydown.fish: -------------------------------------------------------------------------------- 1 | function __howzittouch_keydown -a index 2 | if ! __howzittouch_has_buildnotes 3 | return 0 4 | end 5 | 6 | set -l tasks (__howzittouch_list_tasks) 7 | set -l cmd "howzit" 8 | 9 | if test -n "$howzittouch_command" 10 | set cmd "$howzittouch_command" 11 | end 12 | 13 | if test $index -eq 1 14 | commandline -r "$cmd" 15 | commandline -f execute 16 | else 17 | commandline -r "$cmd -r $tasks[$index]" 18 | commandline -f execute 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /functions/__howzittouch.fish: -------------------------------------------------------------------------------- 1 | function __howzittouch 2 | __howzittouch_clear_buttons 3 | 4 | if ! __howzittouch_has_buildnotes 5 | return 0 6 | end 7 | 8 | set -l tasks (__howzittouch_list_tasks) 9 | set key 1 10 | 11 | if test (count $tasks) = 0 12 | if test "$__howzittouch_wd_has_tasks" = 1 13 | __howzittouch_osc_command 'PopKeyLabels=howzit-scripts' 14 | end 15 | 16 | set __howzittouch_wd_has_tasks 0 17 | end 18 | 19 | if test "$__howzittouch_wd_has_tasks" = 0 20 | __howzittouch_osc_command 'PopKeyLabels=howzit-scripts' 21 | __howzittouch_osc_command 'PushKeyLabels=howzit-scripts' 22 | end 23 | 24 | set __howzittouch_wd_has_tasks 1 25 | 26 | for task in $tasks 27 | __howzittouch_osc_command (printf 'SetKeyLabel=%s=%s' F$key $task) 28 | 29 | set key (math $key + 1) 30 | 31 | if test $key -gt 20 32 | break 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Derek W. Stavis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### Howzit Touch 2 | 3 | > Run Howzit tasks from the touchbar 4 | 5 | [![MIT License](https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square)](/LICENSE) 6 | [![Fish Shell Version](https://img.shields.io/badge/fish-v2.2.0-007EC7.svg?style=flat-square)](https://fishshell.com) 7 | [![Oh My Fish Framework](https://img.shields.io/badge/Oh%20My%20Fish-Framework-007EC7.svg?style=flat-square)](https://www.github.com/oh-my-fish/oh-my-fish) 8 | 9 |
10 | 11 | 12 | ## Installing 13 | 14 | ```fish 15 | $ omf repositories add https://github.com/ttscoff/omf-packages 16 | $ omf install howzittouch 17 | ``` 18 | 19 | ## Requirements 20 | 21 | 1. Have **Oh My Fish** installed. For more information, check [here](https://github.com/oh-my-fish/oh-my-fish#installation). 22 | 1. Be using **iTerm2**, for Touch Bar support. 23 | 24 | ## Usage 25 | 26 | 1. Edit the Touch Bar (View -> Customize Touch Bar) to have only "Function keys" block. 27 | 1. Enter a directory with a `buildnotes.md` and the tasks will appear at the touch bar. 28 | 1. Exitting the directory makes the Touch Bar be restored to function keys. 29 | 30 | ## Configuration 31 | 32 | By default touchrunner will use `npm run`. If you want to switch the task 33 | runner, you can override via `touchrunner_command` global variable, eg.: 34 | 35 | ```fish 36 | set -g howzittouch_command yarn 37 | ``` 38 | 39 | # License 40 | 41 | [MIT][mit] © [Derek Stavis][author], modified for Howzit by [Brett Terpstra](https://brettterpstra.com) 42 | 43 | 44 | [mit]: https://opensource.org/licenses/MIT 45 | [author]: https://github.com/derekstavis 46 | [omf-link]: https://www.github.com/oh-my-fish/oh-my-fish 47 | 48 | [license-badge]: https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square 49 | --------------------------------------------------------------------------------