Posts

Showing posts from 2011

Coalescing multiple edits into a single bazaar commit

Occasionally, after committing some changes on a bzr branch, I'll come back to it and want to make further changes. So, I'll have done something like this: $ bzr commit $ # Oops! Forgot to update foo.c. Let's do that now... $ vim src/foo.c $ bzr status modified: src/foo.c But rather than creating a second commit for the newest changes, I'll want to combine those new changes and the changes in the latest commit into a single new commit. How do we do this? With bzr its easy: $ bzr log -l1 > /tmp/commit.log # save the latest commit log entry $ bzr shelve --all -m "latest changes" # save the latest uncommitted changes $ bzr uncommit --dry-run # check its going to work $ bzr uncommit # undo the last commit $ bzr unshelve --dry-run # check if its going to work $ bzr unshelve # apply the latest changes to the working directory $ bzr commit

Adding an icon in Ubuntu's Unity for applications which don't provide one

Occasionally, when you're exploring the truly vast range of offerings in the Ubuntu Software Archives via the wonderful Ubuntu Software Centre (or maybe via " apt-cache search "), you might find a graphical application that doesn't have an icon. If this happens, there are 2 things to do: Raise a bug on that application to have an icon added. Add an icon temporarily. Raising a bug is easy, just type: $ ubuntu-bug <thing> Where " <thing> " is either the name of the program you are running, or the package that program lives in. However, you can also quickly add an icon yourself using this simple technique... There are 2 steps: Select your icon Create a "desktop" file Icons are installed in the "/usr/share/icons/" directory by default, so have a browse around to see what you like. If you're still struggling to find an appropriate icon, you could add the package wm-icons which adds over 1500 new ones (!):

Vim 'put' hook which prompts user for confirmation

Yesterday, whilst hacking on a particularly large Upstart C file in the awesome vim editor, I inadvertently 'put' a huge amount of data, caused by my mis-specifying the marks when I had originally yanked the text. Still unaware of the problem, I then compounded the problem nicely by continuing to make further changes to the file and dug myself an even bigger hole by saving the file and exiting vim. Attempting to compile the now totally invalid code resulted in a seething mass of mocking gcc warnings until it eventually gave up in disgust. Thankfully, I was taking regular backups with rsnapshot and I had the bzr branch history to fall back on. But it still took some time to perform the 3-way diff and get back to my latest changes. Later on, we had our weekly IRC meeting in #ubuntu-meeting . I use irssi and as I pasted my weekly status update, since I was pasting more than a single line, irssi gave me a helpful warning and the option to either proceed, or abort the mult

Can you help us with this Ubuntu Oneiric Plymouth bug?

If you're running Ubuntu Oneiric (beta) and are experiencing this bug , which causes Plymouth (the graphical boot animation application) to crash, please help us to diagnose it by obtaining some debug as explained in comment 14 and comment 39 .

Protecting your shell prompt when accessing a chroot

If you run any chroot environments such as schroot, they will generally set your prompt as a reminder that you are actually running within a chroot. For example with schroot, I have: $ schroot -c oneiric (oneiric):~$ echo hello hello (oneiric):~$ exit $ When you're in the chroot, you get the chroot name prepended to the prompt (here " (oneiric) "). But if you play tricks with your prompt variables ( PS1 , PS2 , etc) using maybe the magic bash PROMPT_COMMAND variable, you need to take care. I use screen , tmux , or byobu so need to take twice the amount of care since: I modify my prompt quite extensively I only have 1 window which multiplexes all my terminals (it's easier to make a mistake :) The problem is that if you forget which window you're in, you may end up modifying the wrong environment - installing packages in a minimal chroot rather than in your main (non-chroot) environment, or maybe trashing your live system rather than a throw-away chroot

How to slow down a guitar solo with free software on Ubuntu Linux

Image
In my spare time, I like to play guitar. I also enjoy learning guitar solos the "hard way" - by working out the notes, slurs, slides, bends, taps, mutes and harmonics by ear. However, some solos -- no matter how many times you listen to them -- are just too fast to "reverse engineer" as your brain just isn't able to distinguish between individual notes. If you simply slow down the solo, you'll be able to hear the individual notes, but you'll be changing the pitch of the notes such that a C 4 or " middle C " might sound like a B 4 . That's not much help as the music will sound different. What we need is a way to slow down the notes, but retain their original pitch. Since I run Ubuntu Linux , I have access to a true "Embarrassment of Riches" when it comes to free and high quality music software. This post outlines some of the methods I've found to slow down guitar solos using different tools. So, if you're wanting t

Diff two files ignoring certain fields (like timestamps)

This is a useful trick to avoid creating lots of intermediate temporary files when you're trying to compare two files that are almost the same, but which have some fields which are guaranteed to be different. Classic examples of this are two log files that have almost the same data in them, but where every line in these files is prefixed by a pesky timestamp which is different between the two files. bash process substitution (using named pipes) to the rescue! Let's assume we have two files " file1.log " and " file2.log " and the first six space-separated fields comprise a timestamp. To ignore those fields and just diff the log file contents we can do this: $ diff <(cut -d" " -f7- /tmp/file1.log) <(cut -d" " -f7- /tmp/file2.log) But why limit yourself to a textual diff. Go graphical if you prefer: $ meld <(cut -d" " -f7- /tmp/file1.log) <(cut -d" " -f7- /tmp/file2.log) This technique can be employed

how to use bash lists to time a group of commands

How do you run multiple commands in bash and calculate the total time taken to run all the commands? Use a list by surrounding the commands with curly braces: time { sleep 2; uptime; true && date; } The tricky bit is remembering to add that last semi-colon - without it, the command will fail to be parsed by bash. Also, the spaces either side of the curly braces are mandatory.

Starting terminals in tmux in particular directories

I've found a way to tweak my ~/.tmux.conf to create a terminals in particular directories: # start a window in $HOME/foo and call it "bar" set-option default-path "$HOME/foo" neww -n bar # another terminal in a different directory set-option default-path "/var/cache/weird" neww -n weird # revert to default for any further windows set-option default-path "$HOME"

quick terminal reset

Amazing how many people don't know this skool technique to reset a corrupted terminal: ^jstty sane^j Note - you don't press return/enter at all and those are CONTROL+j combos at either end.