Better integration with FZF
This commit is contained in:
parent
230a1b717a
commit
8e1d3e017c
2 changed files with 26 additions and 10 deletions
13
README.md
13
README.md
|
@ -28,25 +28,26 @@ this version uses plain directories.
|
|||
Then add the following aliases to your `~/.bashrc`:
|
||||
|
||||
```bash
|
||||
# Type "nn" to create a new note
|
||||
alias nn="notes.sh -n"
|
||||
|
||||
# Type "ne" to look up and edit an existing note
|
||||
alias ne="notes.sh -l | fzf --tac --with-nth=\"2..-1\" --preview \"notes.sh -p {}\" | xargs -o notes.sh -e"
|
||||
# Type "ne" to look up and edit an existing note, or create a new one
|
||||
alias ne="notes.sh -l | fzf --tac --with-nth=\"2..-1\" --preview \"notes.sh -p {}\" --print-query --bind 'alt-enter:print-query' | xargs -o -d \"\n\" -n 2 notes.sh -f"
|
||||
```
|
||||
|
||||
To add a new note:
|
||||
|
||||
```bash
|
||||
nn This is my new note
|
||||
ne
|
||||
```
|
||||
|
||||
And then continue typing the note name and press Alt-Enter to create a new one.
|
||||
|
||||
To open a previously created note:
|
||||
|
||||
```bash
|
||||
ne
|
||||
```
|
||||
|
||||
Then select a note you want to open and press Enter.
|
||||
|
||||
## License
|
||||
|
||||
Distributed under the terms of the BSD License
|
||||
|
|
23
notes.sh
23
notes.sh
|
@ -163,9 +163,21 @@ export_note() {
|
|||
fi
|
||||
}
|
||||
|
||||
fzf_entry() {
|
||||
NAME="$1"
|
||||
ID="$(echo "$2" | cut -d " " -f 1)"
|
||||
|
||||
if [ -z "$ID" ]; then
|
||||
if [ ! -z "$NAME" ]; then
|
||||
new_entry "$NAME"
|
||||
fi
|
||||
else
|
||||
edit_entry "$ID"
|
||||
fi
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "$0 {--new,--list,--edit,--help}"
|
||||
echo "$0 {--new,--list,--edit,--fzf,--help}"
|
||||
}
|
||||
|
||||
while (( "$#" )); do
|
||||
|
@ -181,12 +193,15 @@ while (( "$#" )); do
|
|||
;;
|
||||
-e|--edit)
|
||||
if [ -z "$2" ]; then
|
||||
echo "Misssing argument for $1"
|
||||
exit 1
|
||||
exit 0
|
||||
fi
|
||||
edit_entry "$2"
|
||||
exit 0
|
||||
;;
|
||||
-f|--fzf)
|
||||
fzf_entry "$2" "$3"
|
||||
exit 0
|
||||
;;
|
||||
-E|--export)
|
||||
if [ -z "$2" ]; then
|
||||
echo "Misssing arguments for $1"
|
||||
|
@ -201,7 +216,7 @@ while (( "$#" )); do
|
|||
exit 1
|
||||
fi
|
||||
NOTE_ID="$(echo $2 | cut -d " " -f 1)"
|
||||
export_note "$NOTE_ID" ""
|
||||
export_note "$NOTE_ID" "" | fmt -w "$FZF_PREVIEW_COLUMNS"
|
||||
exit 0
|
||||
;;
|
||||
-g|--graph)
|
||||
|
|
Loading…
Reference in a new issue