ned: change directories to the file for editor

This commit is contained in:
PowerUser64 2022-02-06 22:13:57 -08:00
parent 9a04036778
commit da5d2d9597

View file

@ -17,15 +17,15 @@ usage() {
cat <<-EOF
Usage:
ned <verb>
new <folder> [note name] create a new note in the matched class folder
[edit|ed] <folder> [note name] search for and edit a text document in a folder
ned edit ned
help print this message
new <folder> [note name] Create a new note in the matched folder
[edit|ed] <folder> [note name] Search for and edit a text document in a folder
ned Edit ned
help Print this message
Notes:
Right now, only the first letter of each option is considered, so \`ned n\` and \`ned neww\` do the same thing
Folder and file names are globbed
Will automatically activate the ZenMode nvim extension
Folder and file names are searched with fuzzy search
Ned will automatically activate the ZenMode nvim extension
Current repository path: $NOTES_DIR
EOF
}
@ -44,6 +44,7 @@ edit() {
NOTE_PATH="$NOTES_DIR/$(cd "$NOTES_DIR" && fzf -1 -q "$SEARCH_TERM" --layout=reverse --info=inline --height=10%)" || exit
cd "$(dirname "$NOTE_PATH")"
$EDITOR_CMD "$NOTE_PATH"
}
@ -121,7 +122,7 @@ check_setup() {
# Parse arguments (first character only)
case "${1}" in
# help
'--help'|'-h'|'help') usage;;
'--help'|'-h'|'help'|'h') usage;;
# create and edit new note
'new') new $@;;
# edit an existing document or file