Last active
December 10, 2017 07:07
-
-
Save justinvdm/ede86753789c62f34e0cfc3f5b324168 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
genFilename() { | |
cat /dev/random | LC_CTYPE=C tr -dc "[:alpha:]" | head -c 8 | |
} | |
slugify() { | |
echo "$@" | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z | |
} | |
run() { | |
title="" | |
file="$@" | |
if [[ -z "$file" ]]; then | |
file="$(genFilename).md" | |
elif [[ "$file" == "."* ]]; then | |
file="$(genFilename)$file" | |
elif [[ "$file" != *"."* ]]; then | |
title="$file" | |
file="$(slugify $file).md" | |
else | |
title="${file%%.*}" | |
file="$(slugify ${file%%.*}).${file#*.}" | |
fi | |
if [[ ! -z "$title" ]] && [[ ! -f "$NOTE_DIR/$file" ]]; then | |
echo "# $title" > $NOTE_DIR/$file | |
fi | |
$EDITOR $NOTE_DIR/$file | |
} | |
run "$@" |
This file contains hidden or 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/sh | |
touch "$@" | |
open -a $MDUI_EDITOR "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment