Windows only: SSH client KiTTY adds dozens of new features to the PuTTY terminal client software, including a launcher, transparency, send-to-tray, and it even rolls up the windows into the title bar with a hotkey. More »
Blog Archives
KiTTY Adds Session Saving, Portability, and More to PuTTY [Downloads]
Don’t keep opening those files
Constantin has a wonderful little script that will configure you home server to reduce it’s power consumption. Unfortunately for me he uses a loop that falls into one of my scripting pet peeves. Within Contstantin’s script there is absolutely no problem but I have in the past seen customers burnt by this such that I have been able to work magic to get some really spectacular performance increases.
The problem is here:
for i in $disks ; do echo "device-thresholds $i 5m" >>$TMPFILE done
Let me emphasize again that in this case there is no real problem but I believe that if you do the right thing where it does not matter you will get it right when it does.
The issue is that for every time around that loop the script opens the output file writes one line and closes the file. This is bad when the file system is a local one but when over NFS this is a performance disaster. With a small change the number of opens can be reduced to just one, which when over NFS all data has to be sent to the server and the server confirm it is on stable storage before the close can complete give a spectacular improvement.
Here is a test I ran over a very slow NFS v4 link (Wifi) to my home server:
brompton% cat /tmp/loop
#!/bin/ksh
i=0
out=${1:-${0##*/}.out}
: > $out
while (( i < 1000))
do
echo $i >> $out
let i=i+1
done
brompton% time /tmp/loop
/tmp/loop 0.15s user 0.51s system 2% cpu 26.850 total
brompton%
Compare that with a the good case:
brompton% cat /tmp/loop2 #!/bin/ksh
i=0
out=${1:-${0##*/}.out}
while (( i < 1000))
do
echo $i
let i=i+1
done > $out
brompton% time /tmp/loop2
/tmp/loop2 0.01s user 0.01s system 5% cpu 0.384 total
brompton%
From 26 seconds to 0.384 seconds. Now this is a very bad case as the loop does nothing else and the network latency is particular bad but none the less the principle is the same if you have 10G ethernet, you don’t want to be leaving that performance on the table.
ShellFolderFix Brings Saved Folder Positions Back to Windows 7 [Downloads]
Windows: Unlike previous versions of Windows, Windows 7 has no option for remembering the position of individual windows. If you miss having Windows remember how you arrange things, ShellFolderFx can help.
It's a small thing, certainly, but if you'd grown used to Windows keeping track of the size and position of your windows—especially important for multi-monitor users!—then the removal of that feature in Windows 7 was more than a minor annoyance.
ShellFolderFix is a small application that allows you to enable folder and size position saving as well as maintaining folder browsing history between sessions. Once you set the options you want and send the application to the system tray you never need to bother with it again, it runs in the background keeping track of the folders and restoring them to their respective positions.
For another way to get a piece of Windows history back in Windows 7 check out how to get the classic network activity indicator back in Windows 7. ShellFolderFix is freeware, Windows only. Have a trick or application for restoring functionality from past versions of Windows to Windows 7? Let’s hear about it in the comments.
Use a Different Color for the Root Shell Prompt [Terminal Tip]
Linux only: Reader Chris writes in with an excellent tip that changes the prompt to red when using the root account from the terminal—as a reminder to be more careful.
Using the tip is relatively simple—just edit the /root/.bashrc file and add in the following, preferably commenting out the existing lines that set the color, though you can simply add this line to the end of the file.
PS1='${debian_chroot:+($debian_chroot)}[ 33[01;31m]u@h[ 33[00m]:[ 33[01;34m]w[ 33[00m]$ '
Once you’ve added this line, anytime you switch to using the root shell you will see the prompt in red with white text for the command line. Chris takes it further, with a line that turns the prompt green for regular users, which you can enable by adding the following to your ~/.bashrc file:
PS1='${debian_chroot:+($debian_chroot)}[ 33[01;32m]u@h[ 33[00m]:[ 33[01;34m]w[ 33[00m]$ '
This tip can really come in handy if you have a bunch of terminal windows open at once, so you can tell at a glance which ones are using root mode and which aren’t. Thanks, Chris!
For more tips on powering up your terminal, check out how to display your public IP address, show a list of only subdirectories, or make any directory into an ISO file.
Cut the Bash Prompt Down to Size [Terminal Tip]
The LinDesk weblog runs down the process of customizing the shell prompt to trim the current path down to a reasonable character limit—making typing long commands much simpler while under deeply nested folders.
The guide includes a number of options for customizing your prompt to include more information about the current path without overloading your screen with characters—one of the more interesting tweaks is this script that removes characters from the middle of the path, which will cut down the size while clearly identifying the current folder. To test it out, you can simply paste the following text into the terminal prompt:
PROMPT_COMMAND='DIR=`pwd|sed -e "s!$HOME!~!"`; if [ ${#DIR} -gt 30 ]; then CurDir=${DIR:0:12}...${DIR:${#DIR}-15}; else CurDir=$DIR; fi'
PS1="[$CurDir] $ "
Hit the link for the walk-through and alternate prompt options, or you can customize your terminal greeting and reduce your terminal clutter with screen.
Todo.txt CLI Manages Your Tasks from the Command Line [Lifehacker Code]
Dozens of fancy point-and-click task managers promise to organize your to-do list, but so often power users find that nothing outdoes that trusty old classic: the todo.txt file.
If you’re a command line lover who skips checkboxes and drop-downs to dash off notes and tasks in a regular old text file, or you’re intrigued by the idea and wish your todo.txt chops were stronger, read on.
I’ve been a heavy todo.txt user for years. Back in 2006, I started developing a command line interface (CLI) to my todo.txt which lets me add to and check off items without launching a full-on text editor. Three years of daily (or at least weekly) use later, version 2.0 of the script is now available. It offers basic to advanced commands for managing your todo.txt and other text files you might use to capture information, like ideas.txt or maybelater.txt. Let’s take a look.
Who This Is Meant For: If you’re comfortable working in the terminal, changing permissions on a file, and working with Unix-style text commands, then the todo.txt CLI is for you. If you don't spend a good amount of time at the command line—either in the Terminal on your Mac, or using a Unix command line or emulator on Windows—you're going to think this whole thing is arcane and confusing. (In that case, we highly recommend getting organized with Remember the Milk. If you want to boost your command line chops on Windows, check out our introduction to Cygwin.)
You’ve already got CLI religion? Good. Let’s get started on some hot todo.txt command line action.
- Download the Todo.txt CLI 2.0 zip file and extract it. You’ll get two files. Place both
todo.cfg(the configuration file) andtodo.shin your home directory. - Open the
todo.cfg filewith your text editor of choice. Set the TODO_DIR variable to the right path for your setup. For example, on my Windows PC, this line reads:
TODO_DIR="C:/Documents and Settings/gina/My Documents"
On my Mac, this line reads:
TODO_DIR="/Users/gina/Documents/todo" - Make the
todo.shfile executable by using the command:chmod +x todo.sh - (OPTIONAL) Alias the letter t to
todo.shto save keystrokes while you use it. In your~/.bash_profilefile, add the line:
alias t='~/todo.sh'
Now you’re ready to put this script to work!
Basic Usage
Before we start, keep in mind that this CLI isn’t trying to reinvent the text editor. If you want to do big bulk edits to a lot of items in your todo.txt, just open it up in your favorite text editor to do so. But for quick, one-hit access to add items, mark items as complete, or slice and dice your list by project or priority, todo.sh is for you.
For example, to add a line to your todo.txt file, at the command line, type:
$ t add "Pick up milk"
Add a few more items for good measure:
$ t add "Pick up the dry cleaning"
$ t add "Clean out the inbox"
Now, to see all the items on your list, use:
$ t ls
The output will look like this:
$ t ls
03 Clean out the inbox
01 Pick up milk
02 Pick up the dry cleaning
--
TODO: 3 tasks in C:/Documents and Settings/gina/My Documents/todo.txt.
Now, you can reference each item by its ID—which is actually the line number it lives at in the todo.txt file. For instance, to prioritize task 1 to the highest level—priority A—use this command:
$ t pri 1 A
To mark task 2 as complete, use todo.sh‘s do action:
$ t do 2
Since a video is worth a million words, see this in action in this screencast demonstration of a to-do list you might find for a crew member on Battlestar Galactica. (Go full-screen to see what’s being typed more clearly.)
If this video clip isn’t clear enough for you, try this alternate high-res location.
Advanced Usage
Once you’ve got the basics of working with your todo.txt down, it’s time to dive into more advanced tricks. Here are a few more things this CLI can do.
- Replace or delete a task; append or prepend text to a line. When you want to re-word a task or add a context, project, or additional info to it, use the replace, append, and prepend actions to do so. For example, add “ready at 3PM” to your “Pick up the dry cleaning task” with this command:
$ t append 2 "ready at 3PM" - See all the contexts and projects in your list. If you’re using the + and @ sign format to signify projects and contexts, use the listcon and listproj (or lsc and lsprj for short) commands to see a short list of all your contexts or projects in your
todo.txt. - Move items from your todo.txt to another text file. Say you've decided that the "Learn how to speak French" task is actually something you're not quite committed to doing—yet. Use
todo.sh‘s mv command to zip that task fromtodo.txtto another text file in your todo directory. For example, this command will move it into amaybelater.txtfile:
$ t move 10 maybelater.txt - List the contents of another text file. Since I got so used to working with
todo.txtthis way, there’s now support for working with other text files. For example, you can list the contents of yourmaybelater.txtfile using the command:
$ t listfile maybelater.txtLikewise, you can add a line to another file using:
$ t addto ideas.txt "My bright idea"You can also search the contents of another text file by adding a keyword after the list command, ala:
$ t lf ideas.txt apple
See all the options available to you using the todo.sh -h command. The full usage manual is available here.
Further Info and Related Projects
The todo.txt CLI has lived over at its official homepage, Todotxt.com, for years now, and although I haven’t posted an update there since 2006, an active mailing list of over 500 members is still going strong. Since this project is open source, happily several other todo.txt projects have sprung up over the years, including Task, which offers even more features than my little script does.
If you’re a programmer who wants to add to this script or a user with questions or ideas about the todo.txt CLI, either post them here or consider joining the mailing list for support. For a full history of this script's development—including its three-year hiatus—see its full changelog.
Think using a command line interface to a text file is insane or fantastic (or both)? Tried out todo.txt? Tell us what you think in the comments.
Gina Trapani, Lifehacker’s founding editor, is still married to her todo.txt file even after a sordid affair with Remember the Milk. Her weekly feature, Smarterware, appears every Wednesday on Lifehacker. Subscribe to the Smarterware tag feed to get new installments in your newsreader.

