Feeds:
Posts
Comments

Archive for December, 2008

My very customized bash prompt

Bash’s $PS1 variable is what you see every time you get a prompt. It’s there, waiting for you to type something.

Some people go minimal … maybe just “$” like the Bourne shell. Others go crazy and cram as much information as possible … on multiple lines … in colors.

My $PS1 falls somewhere in the middle, but I realized today it was time for a change. One of the things I wanted was the current path. A lot of people like to put that in the “xterm title bar”, but I wanted it closer to the action.

After a bit of experimentation, I found that I could play with the PROMPT_COMMAND to faux-position the path in pale gray ON the same line as the prompt.

Here’s my variables.sh file which I put under ~/etc/bash/local/ — it works with the rest of my config files:

function prompt_command() {   

  printf \e[30;40;1m%*s\n\e[0m\e[1A" $COLUMNS "$PWD"

}

PS1="\[\e[31;43m\]\u@\h\[\e[0m\]

PROMPT_COMMAND=prompt_command

export LANG=”en_US.UTF-8

export LC_ALL=”en_US.UTF-8

export TERM=”xterm-256color

export FIND_OPTIONS=”-name .git -prune -o -name .hg -prune -o

The prompt_command function uses “printf” to print ($COLUMNS wide) the $PWD. There are escapes sequences to color it gray. Finally, the “\e[1A” sequence moves the cursor 1 line up. Consequently, the prompt itself prints on the same line as the PROMPT_COMMAND.

It looks something like:

terminal

What do you put in your $PS1?

Read Full Post »

I never intended to make money with booklife. There were 3 objectives for that project:

  1. Practice Rails.
  2. Track my books, obviously.
  3. Be able to track my friends’ books.

Consequently, booklife has already fulfilled its purpose.

I’ve received feedback, but there’s only finite time I can invest in developing new features. Making booklife open-source would allow people to contribute and scratch their if-only-there-was-that-feature-I-would-use-it itch :-D

The code can be found on github. Clone it, fork it, patch it — please — I’m looking forward to learning something from you.

Read Full Post »

Booklife update

Since booklife went up (December 7th), I’ve added the following features:

  • logo links back to login page
  • “add to my books” link when looking at other people’s books
  • a direct link to amazon from the ISBN
  • per user RSS feed

Subscribe to a user by clicking on the “RSS” icon in your browser.

Here’s my RSS feed.

Read Full Post »

I created a short screencast (3m40s) to show the ctrl-key shortcuts in action. I’m always surprised that people don’t know/use these more.

Cheatsheet:

shortcut what does it do?
ctrl-l clears the screen
ctrl-u erases the whole line
ctrl-a brings cursor to the beginning of the line
ctrl-e brings cursor to the end of the line
ctrl-k erases from cursor to the end of the line
ctrl-w erases the last word – the the previous space
ctrl-y pastes what you erased
ctrl-f erases the last word – to the previous slash
esc-. pastes last argument of previous line
esc-, completes, shows each match one-by-one every time it is pressed

Customizations from my .inputrc:

"\C-f": unix-filename-rubout

"\e,": menu-complete

Read Full Post »

Booklife goes Live

I read a lot … enough to write a webapp to track what I want to read, what I’m reading and what I read. I give you booklife.

Booklife is an application to scratch one of my itch.

How I use it:

  • when I hear about a book, I put it somewhere in my lists
  • when I’m batching books to get the free delivery, I pick from my “to buy” list
  • when I’m planning to go to chapters/indigo, I print out a list of books to check out

Because it’s multi-user:

  • I can check who read what books, maybe to get a recommendation, maybe to borrow them
  • you can get a feeling from people based on the books they read

I’m going to let people use it for a while and see where this goes.

What now?

Read Full Post »

Follow

Get every new post delivered to your Inbox.