8 ms·
Simple note taking from the command line
- tincholio 9y agoThis probably sets the lowest bar for note taking...
- digitalsushi 9y agoIt's like the camera-you-have being best - if my fingers remember how to take notes, I'll take notes.
- indigodaddy 9y agoYou could decentish vi bindings within this by using vi mode for bash I'd guess? I'd probably usually just end up vim notes.md5 TBH.
- zer0th 9y agoI've been doing something fairly similar for years now. You can read about my method here: https://news.ycombinator.com/item?id=10997410 https://news.ycombinator.com/item?id=10997410
- lillesvin 9y agoWhy .md when you're inputting the command as plain text without any markdown?
- delinka 9y agoWhy not just have the flexibility of adding markdown whenever you feel like it (and not when you don't)? Now, you've got a file a markdown renderer can render whether or not you used markdown.
- maxerickson 9y agoThat applies to any file though. The extension just suggests to some tools that they should treat the text as markdown.
- lillesvin 9y agoWell, it's relying on you always inputting Markdown compliant input. Something like: ls -lh ./*-2017-*.log will not display correctly if rendered as markdown without any kind of escaping, and I can think of plenty of other examples.
- Flimm 9y agoI have a very similar script that lets me write notes to a file with today's filestamp. I use it to keep track of what I've done on which days.
- stevekemp 9y agoYup, I have a script `worklog` which boils down to this: #!/bin/sh mkdir ~/.worklog || true if [ -z "$1" ]; then cat ~/.worklog/$(date +%w).md else echo "$(date): $*" >> ~/.worklog/$(date +%w).md fi That gives a file per-week which can either have contents appended to it, or viewed. Usage is the obvious: $ worklog "I did some stuff" $ worklog [shows the output]
- vacri 9y agoAnother thing you can do is just use 'logger' and the syslog. You kinda have to be comfortable with viewing system logging, though; it's not for everyone - for example, I'm using sudo below just because I haven't set my user to view systemd's journal yet. $ logger hello $ logger <<EOF > this is a multiline > logging message > EOF $ sudo journalctl -t vacri -- Logs begin at Fri 2017-09-29 10:40:49 AEST, end at Mon 2017-10-02 23:44:13 AEDT Oct 02 23:40:24 myhost vacri[12320]: hello Oct 02 23:48:48 myhost vacri[12460]: this is a multiline Oct 02 23:48:48 myhost vacri[12460]: logging message syslog is good for some use-cases (eg centralisation), and not so good for others. I imagine most people would prefer your directory-of-easily-findable-history.
- Fletch137 9y agoI like to use: `alias sp='vim ~/notes/scratchpad-$(date +"%m-%d-%Y-%T")'`
- dheera 9y agoI use #!/bin/bash mkdir -p ~/Dropbox/scratch/$(date +"%Y-%m-%d") vim ~/Dropbox/scratch/$(date +"%Y-%m-%d")/$(date +"%Y-%m-%d-%H-%M-%S") for convenient sorting by date, and throw stuff in Dropbox for automatic syncing across my machines.
- nsb1 9y agoSmall improvements: - No quotes needed - Just type 'notes' alone to less the file notes() { if [ "$1" == "" ]; then less $HOME/notes.md else echo $@ >> $HOME/notes.md fi }
- vacri 9y agoCombination of your improvements and the first commentor's in the link - 'notes' by itself views the file (interactive shell only) - 'notes' with args, the args are appended to file (original function) - 'notes' with heredoc (or any piped data) allows for multiline notes notes() { if [ -n "$1" ]; then echo $@ >> "$HOME/notes.md" else # detect if we're in a tty or a pipe if [ -t 0 ]; then less "$HOME/notes.md" else cat - >> "$HOME/notes.md" fi fi } usage: $ notes 1 $ notes 1 2 3 $ notes <<EOF > this is a > multiline note > EOF $ uptime | notes $ notes (opens less with the following content) 1 1 2 3 this is a multiline note 23:22:06 up 3 days, 11:41, 1 user, load average: 0.25, 0.15, 0.26
- aidenn0 9y agoYou should use dollar-star and printf to prevent echo treating some of the arguments as flags: printf '%s\n' "$*" Which works while echo "$@" might not work as expected if you did e.g.: notes -n is a bad flag to pass to some commands The latest posix bans echo from taking any - options, so you may be safe with /bin/echo or if your shebang specifies "sh" but that hasn't percolated down everywhere yet.
- hk__2 9y agoYou still need quotes to prevent the shell from expanding $variables and globs. It’ll also mangle your spaces (try with `notes foo<space><space>bar`: it saves it as "foo<space>bar") due to the $@.
- lottin 9y agoDo you really need a function for that? cat >> ~/notes does the same thing.
- tyingq 9y agorlwrap cat >> ~/notes Would give you some rudimentary readline editing capability.
- ConfucianNardin 9y agoThis will work fine until the day when you mistype >> into >, and all your notes are gone.
- wyldfire 9y agoThat seems like a real risk, true. But at least at $THE_OFFICE, I'm lucky that there's a trivial-to-recover ~/.snapshot/hourly.?/notes file. YMMV.
- rhizome 9y agoA `cat -i` switch could be good.
- ConfucianNardin 9y agoA flag for cat won't help you - it's your shell that does the redirection. You're looking for `set -o noclobber` (same as `set -C`).
- rhizome 9y agoAh, let's go with `> -i` then! :)
- hk__2 9y agoNot if you have `set -C` in your ~/.bashrc, which prevents you from overriding files with >.
- hathym 9y agonow go and pitch VCs for you notes taking app
- pweissbrod 9y agoNot as simple but well worth the extra weight would be org-mode. I personally find the vim-orgmode a balance between the full power of org vs my reliance on vim for day-to-day operations but I must admit I'm sometimes jealous of the power I see in emacs for this.
- uep 9y agoI have been a long-time Emacs user and I finally just started learning org-mode. I wish I had started earlier. Previously, I had used Zim to do my note-taking, but org-mode is just so much better in every way. I have a feeling it's going to be my gateway into more heavy LaTeX usage for all manner of documents. The ability to evaluate code during document generation is a big deal to me.
- gglitch 9y agoHa - I had that experience a few times: the first time I started using Org, the first time I started using the agenda, the first time I started using capture templates, the first time I started using code blocks, etc. Each time: Wow, why didn't I do this from the beginning.
- JoshMnem 9y agoAnother vote for Org Mode. I just added this idea from the post to my laptop (adding a timestamp and sending it into an org-mode file): note() { echo "`date +%s`\t$1" >> ~/org/unsorted-notes.org }
- deleted 9y ago[deleted]
- lysium 9y agoSounds as if you will love spacemacs!
- jaddood 9y agoThis is extremely similar to the 'microscopic planner for shell' that I wrote and often use. Take a look at https://news.ycombinator.com/item?id=14126006 https://news.ycombinator.com/item?id=14126006 I also add a few aliases to make it even quicker: alias mcr='mplan create' alias msh='mplan show' alias mrm='mplan remove' alias mclear='mplan remove \*' This will provide (in my opinion) both a very simple way to take notes and a somewhat mature and usable note taking 'program'.
- hk__2 9y ago> Take a look at https://news.ycombinator.com/item?id=14126006 https://news.ycombinator.com/item?id=14126006 Direct link: https://github.com/jad-issa/mplan-sh https://github.com/jad-issa/mplan-sh. Why post a link to a 6-months years-old HN submission with no comments?
- corobo 9y agoAnyone else use http://jrnl.sh/ http://jrnl.sh/ ? I prefer it over echoing into a file because it has more advanced display features - such as by date - and topics (hashtags [don't forget to escape the hash!], or @tags) Got the journal files stored in Dropbox so they're everywhere I am
- pwelch 9y agoYes! Jrnl is awesome and I've been using it for awhile now. Highly recommend it.
- balladeer 9y agoI have it setup but don’t use it as my main notes app. That would still be Simplenote (with Notational Velocity on desktop). Mainly because I figured would rather use GUI for notes on both desktop and mobile. Maybe one of these days I should give Standard Notes a try (https://standardnotes.org https://standardnotes.org). It’s OSS and client side encrypted (afaik).
- corobo 9y agoOh no for actual full on note notes I use Evernote. For little quips I use jrnl - infact I have it aliased to `log` so I can just type "log work started work on @project" The way I have jrnl configured is that the "work" keyword makes it log to work.txt as opposed to my default log.txt I also have a "todo" which I've configured as a relative path ./todo.txt so I can drop todos into the current directory/project
- overcast 9y agooooo good find! thank you.
- talideon 9y agoI have this: https://github.com/kgaughan/dotfiles/blob/master/local/bin/note https://github.com/kgaughan/dotfiles/blob/master/local/bin/n... It allows the editing of notes for a given day, listing of all notes, and display of a note for a given day, defaulting to today if no date is provided. I keep meaning to add support for RCS or some other form of basic version control, but it's never been that much of an issue.
- catullus 9y agoWith a few more features, but similar in spirit, is Gina Trapani's todo.txt: https://lifehacker.com/5155450/todotxt-cli-manages-your-tasks-from-the-command-line https://lifehacker.com/5155450/todotxt-cli-manages-your-task...
- lucb1e 9y agoSo if I'm reading this correctly, you need to quote your text, and it can't be multi-line... why not this: alias notes='cat >> ~/notes' Just hit ctrl+c (stops cat) or ctrl+d (signals EOF) when you're done writing. No quoting, special characters that might act funny, line or size limits, etc.
- dylanpyle 9y agoI've been using a variation on this for a bit: (echo && date && cat) >> ~/notes.txt Adds a newline and datestamp above each note group
- jasonm23 9y agoDepending on the shell in use C-c (will|won't) write to the redirected output file. C-d remains constant, but it's irritating that there's no way to consistently abort. To deal with this our edit target needs to be a temporary file which we subsequently bless, append to the notes file and then trash. Keeping notes open in an editor buffer that I can jump to easily, and manually: >> notes.md From the command line gains me all the utility I need while using a modern machine and zsh. Of course, if I time travel, the GP trick is useful on old ultrix machines.
- cat199 9y agoor just learn ed/ex, etc. just as fast and you can actually edit when needed. $ ed ~/.todo a this is a new bloat . s/bloat/note/ this is a new note w q $ cat ~/.todo this is a new note $ ed ~/.todo 19 a this is another note. it goes across more lines. woo! . w q $
- rhizome 9y agoTake note, people: ed is the standard text editor.
- reacharavindh 9y agoWould any such note-taking solution work across several ssh sessions? I'm a small scale sysadmin, SSHing into multiple servers configured by my predecessors. I'd love to be able to some command | notes.txt or whatever. And no, I don't have my home directory mounted at all locations the same way. I even need to login as different user for different machines. The command factor is my Mac and Terminal.app
- amdavidson 9y agoI'm going to assume that you can edit .bashrc for these as that's the premise from the original article. You could adjust it so that it uses a central notes store on one ssh host pretty easily with something like: notes() { echo $1 | ssh user@remotehost "cat >> ~/notes.md" } then you probably need something like read_notes() { ssh user@remotehost "cat ~/notes.md" | more }
- Diederich 9y agoThis is neat, and there's a lot of interesting comments and pointers elsewhere in these comment threads. What I've been doing (for the last 25 years or so) is simple. I always keep a window open, visible in all virtual desktops, on the bottom right of my screen, with: vi ~/notes/notes For somewhat less than the last 25 years, ~/notes is an encrypted git repo. I have a cron that, minutely, adds, commits, pulls and pushes to a couple of my servers on the Internet. I generally have one of these for each company I work for, and another one that I've used for all things personal.
- perryprog 9y agoDo you have code for this on GitHub?
- Diederich 9y agoThere's really not much involved. For the encrypted git repo, I use this: https://github.com/AGWA/git-crypt https://github.com/AGWA/git-crypt The cron points to a shell script: #!/bin/sh cd ~/notes git add -A . git commit -am wip git pull git push So with that, I have the same directory, ~/notes/ syncd on all of my computers automatically, as long as I don't do conflicting edits within the space of a minute, which has never happened.
- nastygibbon 9y agoThis looks interesting. I'm going to assume that you add whatever temporary buffer you use while editing the files to your gitignore? E.g. Vim will use .swp files. Does this get annoying if you want to commit something specific? Let's say you edit an old note and save the file. Then, in the time it takes for you to write a commit about this new edit, your cron script has added your change as a 'wip'. Also, is there a nice way to set this up with a cron script so that you can use git via ssh (rather than https) but still keep a passphrase on the key? I seem to remember having problems with cron and git regarding ssh keys.
- 9y ago
- wnmurphy 9y agoI just have Sublime open all the time, and set a keyboard shortcut to open up a designated scratchpad text file. Open, jot, close.
- throwme211345 9y agoman script.
- mdhughes 9y agoWell, I got nerd-sniped by this, since lately I've been dumping text in Apple Notes which isn't really suitable for everything. http://markdamonhughes.com/thoughtpy/ http://markdamonhughes.com/thoughtpy/ Kindly email me bugs, not pull requests.
- vermaden 9y agoSuch 'notes' function can seem 'useful' at first glance, but how You gonna 'organize these notes, for example after You have used it for about a year, or several years? I prefer other approach. Everytime I get to know some new switch for a command, or new use for them, or even a new command, I create ~/man/command file with examples and commends inside, like ~/man/tar or ~/man/gstat or ~/man/xorg.conf. This way its already organized and you can grep -r 'something' ~/man for the thing you need. My $0.02.