Skip to content

bkager/Magpie-Command-Prompt-Notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Magpie: Notes in the command prompt

Magpie is a shell script which displays small snippets of text in your shell prompt. It's useful for reminders or for keeping brief notes while you work. Magpie is compatible with bash/zsh.

Screenshot of a command prompt with three numbered notes following the usual prompt text, each on a separate line. An example is "2: Add readme"

Add or delete notes from the command line while you work, or open the notes file in a text editor to perform more complex editing. Your notes will refresh every time your prompt does.

Screenshot showing three a user typing "magpie add 'Buy eggs'. The note is added to the command prompt as line 3. The user then types "magpie del 3", and the note has been removed from the prompt the next time it appears.

Setup 1: Files

To use Magpie, download the script file (magpie-notes.sh) and the text file in which your notes will be kept (magpie-notes.txt) and place them in your preferred directory. They do not have to be kept in the same place. You may want to put the .txt file somewhere easy to access. Magpie lets you add/delete notes from the command line, but sometimes it's also handy to open the text file directly in an editor.

Setup 2: Configure Your Script File

Open your copy of magpie-notes.sh. On line 12, add the path to the location where you saved magpie-notes.txt:

# Location of text file
file='/Users/myname/Desktop/magpie-notes.txt'

Setup 3: Configure Your Prompt

Bash Setup

Place the following line in your shell's config file (.bashrc), adding the path to your copy of magpie-notes.sh:

  alias magpie="ABSOLUTE_PATH_TO_THE_SCRIPTFILE"

Add to end of PS1 value in your .bashrc file:

  \n"$(magpie)"\n

Example .bashrc file:

alias magpie="/Users/myname/Desktop/magpie/magpie-notes-script.sh"

PS1='\n\u@\w \d \T\n"$(magpie)"\n'

Note that you need to include the double quotes!

Also make sure you have source ~/.bashrc somewhere in your .bash_profile file.

Zsh Setup

Place the following lines in your shell's config file (.zshrc), adding the path to your copy of magpie-notes.sh:

  setopt PROMPT_SUBST
  NEWLINE=$'\n'
  alias magpie="ABSOLUTE_PATH_TO_THE_SCRIPTFILE"

Add to end of PS1 value in your .zshrc file:

  ${NEWLINE}`magpie`${NEWLINE}

Example .zshrc file:

setopt PROMPT_SUBST

NEWLINE=$'\n'

PS1='%d (%D{%A, %B %e})${NEWLINE}`magpie`${NEWLINE}'

alias magpie="/Users/myname/Desktop/magpie/magpie-notes-script.sh"

Setup 4: Permissions

From the command line, enter this command to give the script permission to execute:

chmod +x \<PATH TO YOUR MAGPIE-NOTES.SH FILE>

Using Magpie

To add a note, type magpie add "Whatever you want to type":

Screenshot showing the user type "magpie add "Add license". It is added to the command prompt as a new line.

To delete a note, type magpie del <line num>:

Screenshot showing the user type "magpie del 3". The note numbered 3 is removed.

You can also delete a range: magpie del 2-6:

Screenshot showing the user type "magpie del 2-6". The notes on those line numbers are removed.

"Deleted" notes aren't fully gone--they're moved to the bottom of the file as a comment. You can see all current and deleted notes by opening the notes file in a text editor or by typing magpie all:

Screenshot showing the user type "magpie all". The output of the command is the contents of the magpie text file. Active notes are at the top. Below them, a line reads "### Lines preceded with a # will not be printed ###". Below it, each line is numbered, followed by a #, followed by the text of previously deleted notes.

To get rid of all your old notes, open the file in a text editor. Or if you want to entirely clear your file of all current and deleted notes and start over, type magpie clear:

Screenshot showing the user type "magpie clear". A confirmation dialogue appears. When the user types "y" all notes are removed from the command prompt and the text file.

To see a quick summary of usage, including abbreviated forms of these commands, type magpie help:

Screenshot showing a sample of the help output when a user types "magpie help".

About

A shell script that puts small notes in your command prompt

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages