Skip to content

Instantly share code, notes, and snippets.

@simics-ja
Last active March 22, 2022 00:49
Show Gist options
  • Save simics-ja/0f7f49b65f9bc8083e678c963607fa32 to your computer and use it in GitHub Desktop.
Save simics-ja/0f7f49b65f9bc8083e678c963607fa32 to your computer and use it in GitHub Desktop.
[ちょいスクリプト] #zsh #shell
#!/bin/zsh
MEMO_DIR=$HOME/memofiles
mkdir -p $MEMO_DIR 2>/dev/null
local -A opthash
zparseopts -D -A opthash -- c: d l
# cot is installed in /usr/local/bin/
if [[ -n "${opthash[(i)-c]}" ]]; then
cot -n $MEMO_DIR/${opthash[-c]}
exit 0
fi
if [[ -n "${opthash[(i)-d]}" ]]; then
ls -d $MEMO_DIR/* | fzf -m --ansi --preview 'bat --color=always {}' | xargs rm
exit 0
fi
if [[ -n "${opthash[(i)-l]}" ]]; then
ls $MEMO_DIR
exit 0
fi
if [ "$#" -eq "0" ]; then
ls -d $MEMO_DIR/* | fzf -m --ansi --preview 'bat --color=always {}' | xargs cot
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment