ned: fixes for edit and cd
This commit is contained in:
parent
597764a0ba
commit
4a23ddeb54
1 changed files with 8 additions and 6 deletions
|
@ -17,7 +17,6 @@ DEFAULT_NEW_NOTE_NAME="$(date +'%m-%d')$DEFAULT_NEW_NOTE_EXT"
|
|||
|
||||
# Some fzf commands
|
||||
FZF="fzf -1 --layout=reverse --info=inline --height=10%"
|
||||
FZF_SEARCH="$FZF -q "
|
||||
|
||||
usage() {
|
||||
cat <<-EOF
|
||||
|
@ -50,18 +49,19 @@ edit() {
|
|||
# This logic is to allow $2 to be optional
|
||||
if [ -n "$3" ]; then
|
||||
SEARCH_TERM="$3"
|
||||
NOTE_DIR="$(cd "$BASE_DIR" && fd -t f | sed 's-\./--g' | $FZF_SEARCH "$2")" || exit
|
||||
NOTE_DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -t d -d 1 | sed 's-\./--g' | $FZF -q "$2")" || exit
|
||||
elif [ -n "$2" ]; then
|
||||
SEARCH_TERM="$2"
|
||||
else
|
||||
echo "$0: Error: No file specified" && usage && exit
|
||||
fi
|
||||
# TODO: what if there is no $2 provided
|
||||
|
||||
# Searching for 'T' will get you today's note
|
||||
if [ "$SEARCH_TERM" = 'T' ]; then
|
||||
SEARCH_TERM="$DEFAULT_NEW_NOTE_NAME"
|
||||
fi
|
||||
|
||||
NOTE="$NOTE_DIR/$(cd "$NOTE_DIR" && $FZF_SEARCH "$SEARCH_TERM")" || exit
|
||||
NOTE="$NOTE_DIR/$(cd "$NOTE_DIR" && $FZF -q "$SEARCH_TERM")" || exit
|
||||
|
||||
open_file "$NOTE"
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ new() {
|
|||
# TODO: what if there is no $2 provided
|
||||
|
||||
# Note dir
|
||||
NEW_NOTE_DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -d 1 | sed 's-\./--g' | $FZF_SEARCH "$2")/notes" || exit
|
||||
NEW_NOTE_DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -t d -d 1 | sed 's-\./--g' | $FZF -q "$2")/notes" || exit
|
||||
|
||||
# make the directory if it doesn't exist
|
||||
[ -d "${NEW_NOTE_DIR}" ] || mkdir "${NEW_NOTE_DIR}"
|
||||
|
@ -112,7 +112,9 @@ subshell() {
|
|||
|
||||
shell() {
|
||||
if [ -n "${2+foo}" ]; then
|
||||
DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -d 1 -t d | sed 's-\./--g' | $FZF_SEARCH "$2")" || exit
|
||||
DIR="$BASE_DIR/$(cd "$BASE_DIR" && fd -d 1 -t d | sed 's-\./--g' | $FZF -q "$2")" || exit
|
||||
else
|
||||
DIR="$BASE_DIR"
|
||||
fi
|
||||
if cd "$DIR"; then
|
||||
subshell
|
||||
|
|
Loading…
Add table
Reference in a new issue