Last active
March 22, 2022 00:49
-
-
Save simics-ja/0f7f49b65f9bc8083e678c963607fa32 to your computer and use it in GitHub Desktop.
[ちょいスクリプト] #zsh #shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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