Thursday, May 20, 2010

» GNU Screen: open new window with same working directory

I do this many, many times every single day, and I finally found how to implement it: a shell function to open a new window in screen which is automatically in the same directory as where you call that function. Here is the bash code to add to your ~/.bashrc: function dupscreen { screen bash -c "cd \"$PWD\" && exec $SHELL --login" } alias ,d=dupscreen When I'm in screen and I need another shell in the same directory (e.g. because I'm opening a spec file in vim and need another shell to test the build of the RPM package with osc), I then just type ,d ! Yes, I know, I'm lazy. For the record, here is the nitty gritty on how this works:
  • when you run /usr/bin/screen while already being in screen, it doesn't start a new screen process -- instead, it performs the requested operation (in this case, launching a process (bash) inside screen) in the same screen instance, which is pretty much the same as.. Firefox is doing ;D); note that screen notices that you are already inside a screen session because the environment variable STY is set and points to the name of the screen session you're in
  • bash can be passed a command to execute (instead of going into an interactive shell) using the -c switch; in this case, we ask bash to run cd "$PWD" && exec $SHELL --login and exit
  • the internal bash variable PWD contains the name of the current directory
  • the environment variable SHELL is set by login and contains the login shell that is configured for your user
So basically, the function dupscreen is telling screen to run bash inside itself, and that bash changes into the current directory (i.e. the directory you're in when you call that function) and then executes $SHELL (which is most probably also bash) from there. The ,d shell alias is for extra lazyness :)

Labels: ,

» How to add the openSUSE 11.3 counter to your site

If you have a website/blog, here is the HTML markup to add in order to include the openSUSE release countdown image: <a href=""><img src=""/></a> The markup above will add a 256x256 pixel image. If you prefer to have the smaller (130x130) one: <a href=""><img src=""/></a> And in case you prefer the huge one (400x400px) for maximum visibility: <a href=""><img src=""/></a>


Thursday, May 13, 2010

» Countdown for 11.3

It's that time of the year again... After jimmac handed me the new artwork for openSUSE 11.3, I've updated our countdown site accordingly. For further details, read my mail to the marketing list.


Tuesday, May 04, 2010

» openSUSE repository URL shortening

Hacked a little lighttpd redirect on to shorten URLs to openSUSE package repositories. Simply use followed by the name of the repository, without the slashes (/) to separate, as it is redundant with ":" Examples: Arguably, not quite as short as with or, but still shorter than the full URL ;)