Compare commits

...

2 Commits

Author SHA1 Message Date
90b3e24789 Load work config if present 2018-08-20 10:23:33 +01:00
ada3cb7d3d Add layout and note plugins 2018-08-20 10:16:45 +01:00
6 changed files with 58 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
}

9
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
@ -148,6 +154,9 @@ if [[ ! -z "$cursor_block" && ! -z "$cursor_line" ]]; then
zle -N zle-line-finish
fi
# Load work related config
[ -f ~/.config/work/zshrc ] && source ~/.config/work/zshrc
# Remove duplicates from environment variables
typeset -U PATH
typeset -U MANPATH