From ada3cb7d3d4513c19e63f9d013191b250e055737 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Mon, 20 Aug 2018 10:14:59 +0100 Subject: [PATCH] Add layout and note plugins --- .conduit.yaml | 4 ++++ layout/_layout | 14 ++++++++++++++ layout/layout.plugin.zsh | 10 ++++++++++ notes/_note | 13 +++++++++++++ notes/notes.plugin.zsh | 8 ++++++++ zshrc | 6 ++++++ 6 files changed, 55 insertions(+) create mode 100644 layout/_layout create mode 100644 layout/layout.plugin.zsh create mode 100644 notes/_note create mode 100644 notes/notes.plugin.zsh diff --git a/.conduit.yaml b/.conduit.yaml index 2f782da..acb7792 100644 --- a/.conduit.yaml +++ b/.conduit.yaml @@ -18,6 +18,10 @@ dst: ~/.local/share/zsh/site-functions/prompt_fresh_setup - src: sandbox/_sandbox dst: ~/.local/share/zsh/site-functions/_sandbox + - src: layout/_layout + dst: ~/.local/share/zsh/site-functions/_layout + - src: notes/_note + dst: ~/.local/share/zsh/site-functions/_note - repo: - https://github.com/zsh-users/zsh-autosuggestions.git - https://github.com/zsh-users/zsh-history-substring-search.git diff --git a/layout/_layout b/layout/_layout new file mode 100644 index 0000000..907c97e --- /dev/null +++ b/layout/_layout @@ -0,0 +1,14 @@ +#compdef layout + +__get_layouts() { + ls -1 ~/.config/tmux/layouts 2>/dev/null | \ + while read -r layout; do echo $layout; done +} + +__layouts() { + local -a layouts + layouts=(${(fo)"$(__get_layouts)"}) + _describe 'layout' layouts +} + +_arguments ':layout:__layouts' diff --git a/layout/layout.plugin.zsh b/layout/layout.plugin.zsh new file mode 100644 index 0000000..f78f648 --- /dev/null +++ b/layout/layout.plugin.zsh @@ -0,0 +1,10 @@ +layout() { + if [[ "$1" == "" ]]; then + echo "usage: layout [name]" + else + tmux source-file ~/.config/tmux/layouts/$1 + if [[ "$2" != "" ]]; then + tmux rename-window $2 + fi + fi +} diff --git a/notes/_note b/notes/_note new file mode 100644 index 0000000..a61c366 --- /dev/null +++ b/notes/_note @@ -0,0 +1,13 @@ +#compdef note + +__get_notes() { + ls -1 ~/Sync/Notes 2>/dev/null | while read -r note; do echo $note; done +} + +__notes() { + local -a notes + notes=(${(fo)"$(__get_notes)"}) + _describe 'notes' notes +} + +_arguments ':notes:__notes' diff --git a/notes/notes.plugin.zsh b/notes/notes.plugin.zsh new file mode 100644 index 0000000..4b0d8ad --- /dev/null +++ b/notes/notes.plugin.zsh @@ -0,0 +1,8 @@ +# TODO: Support opening multiple notes in buffers or tabs +note() { + if [[ "$1" == "" ]]; then + echo "usage: note \"\"" + else + vim -c "Note $1" + fi +} diff --git a/zshrc b/zshrc index dfb0732..8c39a24 100644 --- a/zshrc +++ b/zshrc @@ -30,6 +30,12 @@ source-plugin build # Project sandboxing commands source-plugin sandbox +# Layout tmux window commands +source-plugin layout + +# Note taking commands +source-plugin notes + # Remove duplicates from history setopt hist_ignore_all_dups setopt hist_reduce_blanks