console.systems

Bash auto-completion trick

Tuesday, July 31, 2012

zhs has a nice feature. If a program supports --help then zsh can do auto-completion of its arguments. The trick is that zsh silently runs the program with --help argument, parses the output and use it for auto-completion. I wish bash could do that. Well, not exactly but it can. Bash has auto-completions too using templates. But if you want to add auto-completion to your program you would need to write a new template and either put it to /etc/bash_completion.d/ or source in .bashrc or .profile.

But you don’t have to do any of it if you can re-use bash templates as is. For example the template for configure scripts does almost the same what zsh does for all programs. It simply parses the output from ./configure --help. Unfortunately it works only for arguments that prefixed with double dash. Better than nothing anyways.

How to restore previously opened tabs in IE automatically

Thursday, May 24, 2012

Short answer, you cannot.

I always prefer to continue the browsing session from where I left it. Unlike any other browser (Firefox, Opera, Chrome) even the latest IE 9 after over 15 years of development yet doesn’t offer this functionality. Well, IE is not a browser so nothing to complain.

How to quickly switch between two git branches

Tuesday, March 6, 2012

Occasionally figured out, just like

$ cd -

to switch between directories you can do the same for branches

$ git checkout -

How to switch Phonon backend

Wednesday, August 24, 2011

After installing new phonon backend:

$ kbuildsycoca4 --noincremental
$ kcmshell4 kcm_phonon

Or if you are running KDE4 session just go to System Settings -> Multimedia -> Backend

Select a backend and move it up in the list with “Prefer” button.

Easy way to extract archives

Thursday, June 3, 2010

There are many command line tools on Linux to work with compressed files (more than one tool for some formats) and each tool has a different list of arguments. Not that I don’t remember how to extract a certain format, but sometimes all I need is quickly unpack a file and that’s it.

Once I have found a tiny shell script called ex that allowed to do that, I can’t remember now where exactly I got it, but after some search it seems that it’s made by a user rezza from Arch Linux forums. I was happy with that script for a while (or a few years), it worked well with most types of archives, but it was missing one important feature - it couldn’t extract into a certain directory.

Today I extended it or actually have completely rewritten. It became a bit bulky for a single .bashrc, but you can put the script file to e.g. your ~/.bin (make sure that it’s in $PATH) and use the same way as ex. You will also need to set the rights for execution:

$ chmod a+x ~/.bin/exx

I renamed mine to eXx (extended ex) for the people who still use the original script (and to eliminate any ambiguity). I had to exclude some formats like pure bzip2 and gzip, mainly because bunzip2 and gunzip don’t work with external directories. Anyways, nobody today uses those formats alone.

eXx supports .tar, tar.gz (.tgz), .tar.bz2 (.tbz2), tar.lzma (.tlz), 7z, zip and rar. It also checks if appropriate tools are installed, lets you know otherwise. Tested on Bash 3.2 at Ubuntu and may not work on BusyBox systems.

Some examples:

$ exx ~/*.{zip,7z} -C /tmp # extracts all *.zip and *.7z files from home dir to /tmp
$ exx file1.tar file2.tar.gz # extracts into the current directory

Download it from here: eXx

<- Newer Posts Older Posts ->