redirecting python's "print" statements to a file

7 October, 2005 - 12:05
Categories:

Something I find annoying about writing a program/script that writes to text files is that you explicitly have to write the linefeeds (things like "\n", "\r", "\r\n" or std::endl). I remember Pascal having something like a writeln() function, which was very handy when I spend my time programming in TurboPascal, but it's no real incentive at all to return to the "begin...end" mess of Pascal. Apparently java has a writeln function too.

Read more...

moving files to the (KDE) trash can from the command line

7 October, 2005 - 11:52
Categories:

When you want get rid of some files, but fully deleting them is bit drastic, a trash can is an handy option. In a graphical environment the tools are there to do it (drag and drop, right mouse button on a file, etc.), but on the command line it is not something very handy to do. In the old days there was a directory ~/Desktop/Trash that acted as the trash can. But nowadays, KDE and Gnome implement the freedesktop.org trash specification, which is more advanced than a simple directory with files.

Read more...

Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc and others

3 October, 2005 - 17:08
Categories:

Ever wondered what's the difference between ~/.bashrc, ~/.bash_profile, ~/.profile, /etc/profile, /etc/bash.bashrc (and maybe others) and what their purposes are? I do.

Some interesting excerpts from the bash manpage:

Read more...

Avoid duplicates in your bash history

3 October, 2005 - 15:56
Categories:

Sometimes I need to repeat a command several times on the bash commandline. I don't mean a scenario where you could use a for or while loop, but take for example editing a script in an editor and periodically running it in a terminal. In that case my bash history used to be appended over and over with the same command for running that script.

If you set the shell variable HISTCONTROL to ignoredups, bash will not append a command to the history if it matches the last command of the history.

Read more...

Changing the theme of GTK/Gnome applications under KDE

19 August, 2005 - 12:10
Categories:

While I'm a KDE user, I still use some Gnome appliciations or other applications with a GTK interface (the gimp, synaptic, firefox and thunderbird for example). Their default skin when running under KDE (on my Kubuntu Linux system) was a bit ugly in my humble opinion, not to say it felt like motif uglyness.

Read more...

Get the last argument of the previous command in the bash shell

11 August, 2005 - 12:34
Categories:

Working on the command line shell typically involves using the same argument of the previous command. In bash there is a trick to save you those boring keystrokes. When you use "!$" (called bang dollar-sign) in a command, bash will expand it to the last argument of the previous command. A simple example to clarify:

$> file /etc/fstab
/etc/fstab: ASCII text
$> ls -l !$
ls -l /etc/fstab
-rw-r--r--  1 root root 894 2005-08-03 15:12 /etc/fstab
Read more...

Activate tab completion in interactive python mode with a python startup script

9 August, 2005 - 10:41
Categories:

Before my switch from Mandrake Linux to Ubuntu Linux I used the tab completion feature in interactive python without noticing it. But after the switch I noticed it wasn't there any more. On my search to find a way to reactivate it I found this page about the standard python module rlcompleter. I followed the instructions involving a python startup script and now I'm happy tab completing on the python shell again.

I also found a website about rlcompleter2, which should be a python module for a more advanced form of code completion for python's interactive mode.

Read more...

walking through directories with pushd and popd

6 August, 2005 - 13:28
Categories:

When you're spending a part of your life on the commandline, you'r probably cd'ing a lot in and out directories. Some handy commands (for bash):

  • cd (without arguments) brings you to your home directory
  • cd - (with just a minus) brings you to the previous directory you went to with cd
Read more...

Load url from clipboard on middle mouse click in Firefox on Linux

5 August, 2005 - 12:00
Categories:

A nice feature of working in X on Linux is copy/paste by selecting (copy) and pressing the middle mouse button (paste). When I'm sometimes forced to work in Windows I realise how much it replaced my old ctrl-c/ctrl-v habit. I also use the trick with Mozilla Firefox to load an URL that is not clickable, because there is no anchor element around, or because it's in some textfile for example.

Read more...

Using multiple SMTP servers for outgoing mail in Mozilla Thunderbird

4 August, 2005 - 11:03
Categories:

What if you use your computer (laptop) in different networks (work, home, ...) and consequently need a different SMTP server for your outgoing mail in Mozilla Thunderbird?

Read more...