Add layout and note plugins

This commit is contained in:
Kenneth Benzie 2018-08-20 10:14:59 +01:00
parent e13e70de6b
commit ada3cb7d3d
6 changed files with 55 additions and 0 deletions

View File

@ -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

14
layout/_layout Normal file
View File

@ -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'

10
layout/layout.plugin.zsh Normal file
View File

@ -0,0 +1,10 @@
layout() {
if [[ "$1" == "" ]]; then
echo "usage: layout <layout> [name]"
else
tmux source-file ~/.config/tmux/layouts/$1
if [[ "$2" != "" ]]; then
tmux rename-window $2
fi
fi
}

13
notes/_note Normal file
View File

@ -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'

8
notes/notes.plugin.zsh Normal file
View File

@ -0,0 +1,8 @@
# TODO: Support opening multiple notes in buffers or tabs
note() {
if [[ "$1" == "" ]]; then
echo "usage: note \"<title>\""
else
vim -c "Note $1"
fi
}

6
zshrc
View File

@ -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