Coder Social home page Coder Social logo

Comments (3)

pimterry avatar pimterry commented on May 20, 2024

Hi @NumenHackerCracker good suggestion, thanks. I think this sounds like an easy & sensible fix: if the exact filename exists, notes open should use that rather than appending an extension.

Would you be interested in putting together a PR to fix that? I think the main place the extension is used is here:

notes/notes

Lines 173 to 184 in 428946e

get_full_note_path() {
local note_path=$1
if [[ "$note_path" != *.$NOTES_EXT ]]; then
note_path="$note_path.$NOTES_EXT"
fi
if [ ! -f "$note_path" ]; then
note_path="$notes_dir/$note_path"
fi
echo "$note_path"
}
and it should be easy to add another test for this similar to:
@test "Accepts names without .md to open" {
touch $NOTES_DIRECTORY/note.md
run bash -c "$notes open note"
assert_success
assert_output "Editing $NOTES_DIRECTORY/note.md"
}

from notes.

eshapard avatar eshapard commented on May 20, 2024

I've been doing some hacking on the script recently and I actually implemented this feature.

I think all I had to do was change get_full_note_path to just not add the file extension if $notes_dir/$notes_path is a file. If not, then test for the extension and add if not there.

Looking at the code you posted, I'm wondering about this:

if [ ! -f "$note_path" ]; then
    note_path="$notes_dir/$note_path"
fi

Is this there in case a user supplies an absolute path or something? it seems like the $nodes_dir should always be prepended, shouldn't it?

from notes.

pimterry avatar pimterry commented on May 20, 2024

If you've got a fix for this issue in general, please do put in a PR, that'd be great.

Is this there in case a user supplies an absolute path or something?

Yes, I'm pretty sure that's why that's there. I don't remember the original reasoning for that (that line was last touched 5 years ago!) but it's a useful option to have, especially for composing notes with other CLI tools.

from notes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.