ned: ned cd works good now

No, I do not mean "it works well." I meant what I said.
This commit is contained in:
PowerUser64 2022-04-08 14:53:09 -07:00
parent 244939b28c
commit 1aac39b453

View file

@ -12,7 +12,8 @@
BASE_DIR="${NOTES_DIR:-"$HOME/Documents/college/current"}" BASE_DIR="${NOTES_DIR:-"$HOME/Documents/college/current"}"
EDITOR="nvim" EDITOR="nvim"
EDITOR_CMD="nvim -c :ZenMode" EDITOR_CMD="nvim -c :ZenMode"
DEFAULT_NEW_NOTE_NAME="$(date +'%m-%d').md" DEFAULT_NEW_NOTE_EXT=.md
DEFAULT_NEW_NOTE_NAME="$(date +'%m-%d')$DEFAULT_NEW_NOTE_EXT"
# Some fzf commands # Some fzf commands
FZF="fzf -1 --layout=reverse --info=inline --height=10%" FZF="fzf -1 --layout=reverse --info=inline --height=10%"
@ -26,9 +27,10 @@ usage() {
[edit|ed] [folder] <note name> Search for and edit a text document in a folder [edit|ed] [folder] <note name> Search for and edit a text document in a folder
ned Edit ned ned Edit ned
help Print this message help Print this message
cd [folder] Open a shell in a directory or the default directory
Notes: Notes:
Edit 'T' to get today's note Edit 'T' to get today's note
Folder and file names are searched with fuzzy search Folder and file names are searched with fuzzy search
ned will automatically activate the ZenMode neovim extension ned will automatically activate the ZenMode neovim extension
Current repository path: '$BASE_DIR' Current repository path: '$BASE_DIR'
@ -69,7 +71,7 @@ new() {
# Note name # Note name
if [ -n "$3" ]; then if [ -n "$3" ]; then
NEW_NOTE_NAME="$3.md" NEW_NOTE_NAME="$3"
else else
NEW_NOTE_NAME="$DEFAULT_NEW_NOTE_NAME" NEW_NOTE_NAME="$DEFAULT_NEW_NOTE_NAME"
fi fi
@ -83,7 +85,7 @@ new() {
cd "$NEW_NOTE_DIR" || exit cd "$NEW_NOTE_DIR" || exit
# apply a template for notes # apply a template for notes
cat <<-EOF >> "$NEW_NOTE_DIR/$NEW_NOTE_NAME" cat <<-EOF >> "$NEW_NOTE_DIR/$NEW_NOTE_NAME"
# $NEW_NOTE_NAME # ${NEW_NOTE_NAME%%$DEFAULT_NEW_NOTE_EXT}
<!-- vim: wrap nonu nornu <!-- vim: wrap nonu nornu
--> -->
@ -104,10 +106,14 @@ subshell() {
} }
shell() { shell() {
if [ -n "${1+foo}" ]; then if [ -n "${2+foo}" ]; then
DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -d 1 -t d | sed 's-\./--g' | $FZF_SEARCH "$1")" || exit DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -d 1 -t d | sed 's-\./--g' | $FZF_SEARCH "$2")" || exit
fi
if cd "$DIR"; then
subshell
else
exit
fi fi
cd "$DIR" || exit
} }
check_setup() { check_setup() {