Aller au contenu | Aller au menu | Aller à la recherche

Le skyblog de bochecha

vendredi, octobre 2 2009

Yay ! \o/

I just received the results: 805009568343075

/me is happly going back to hack :]

samedi, août 15 2009

A git-aware prompt (part2)

It seems I've been doing some unnecessary stuff in my previous post. Once again, when one tries to do something, he should always remember that someone most probably already had the same idea :-)

Someone pointed to me in the comments that Git already provided a way to have a Git-aware prompt in Bash. Here is an attempt to explain how to use it to have the same result as my previous attempt at scripting it.

One would only need to set the following in their ~/.bashrc file:

PS1='[\u@\h \W]$(__git_ps1 " (%s)")\\$ '

This gives you the following prompt:

[mathieu@localhost ~]$
[mathieu@localhost rpmbuild] (master)$

As you can see, when you enter a Git repository, your prompt displays the name of the current branch.

But that's not quite enough. One might want to show the current changes, to help with their workflow. Just add the following in your ~/.bashrc file, right above the previous line:

export GIT_PS1_SHOWDIRTYSTATE=true

Now, your prompt will look like this:

[mathieu@localhost rpmbuild] (master)$ echo "titi" > SPECS/dummy.spec 
[mathieu@localhost rpmbuild] (master*)$ git add SPECS/dummy.spec
[mathieu@localhost rpmbuild] (master+)$ git commit
[mathieu@localhost rpmbuild] (master)$

The above should be pretty self-explainatory, but in case you didn't get it:

  • prompt displays the name of the current branch
  • a file was modified, the prompt displays a « * »
  • the modified file was staged, the « * » becomes a « + »
  • staged file was commited, there are no more changes (either staged or unstaged) in the working dir, prompt goes back to only displaying the branch name.

That's better, but something is still missing compared to what I had written:

[mathieu@localhost rpmbuild] (master)$ touch foobar
[mathieu@localhost rpmbuild] (master)$

That's right, untracked files are not shown on the prompt!

The solution came from a second comment on my previous post. All that is necessary is to add the following in your ~/.bashrc file:

export GIT_PS1_SHOWUNTRACKEDFILES=true

Now, you'll get:

[mathieu@localhost rpmbuild] (master)$ touch foobar
[mathieu@localhost rpmbuild] (master%)$

That's it! The exact same fonctionality as what I had hacked in an ugly way, with only the following 3 lines:

export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
PS1='[\u@\h \W]$(__git_ps1 " (%s)")\\$ '

Nice isn't it? :)

Remark 1: the env vars GIT_PS1_SHOWDIRTYSTATE and GIT_PS1_SHOWUNTRACKEDFILES only need to be set to something not empty. I used « true » because it kinda made sense, but setting them to « iamagitn00bz » would produce the exact same result.

Remark 2: Fedora 11 comes with Git 1.6.2.5 which doesn't support GIT_PS1_SHOWUNTRACKEDFILES in the bash completion script it ships. To make the above work I simply grabbed the file from the Rawhide Git 1.6.4 package. You could alternatively take it in the Git Git repository.

Remark 3: as mentioned in the comments on my previous blog article, there also is the GIT_PS1_SHOWSTASHSTATE env var that can be used to display other things in your prompt. This article was only about replicating the behavior I described before, and this variable is not part of it. But go play with it yourself :)

samedi, août 8 2009

A git-aware prompt

UPDATE: Gitigit in the comment talked about another env var that would show unstaged changes. This article thus contains wrong informations, see the next one to do things properly.

Thanks for pointing me my mistakes Gitigit and Blah! :-)


UPDATE: Blah pointed out in the comments that something already existed, but as I stated, it doesn't quite match my workflow with Git. However, this lead me to think a little and I saw that I didn't understand anything about the difference between staged and unstaged changes :)

After looking at it a bit more, I finally got it, and as such, I updated the below function so that it takes unstaged changes into account.

So once again, thank you blah :-)


I read Peter's post today about how happy he was to have switched to zsh.

Now, this isn't one of those « you're right man, zsh is so much more awesomer » or even « dude, bash can do it too, why did you go to the other side ? » posts.

However, Peter had an incredible idea: display the current git branch in your prompt, as well as whether there are uncommited changes or not.

So I don't really care about what shell I'm using, and bash has at least one huge benefit: it's the default on my distro of choice (and I'm too lazy to change it and learn another one :). But this git thingy, I love it!

Here's what I added to my ~/.bashrc file:

# set the prompt, appending the current git branch (if any)
set_prompt() {
if [ -d ./.git ]; then
GITBRANCH="(\[\033[0;32m\]$(awk -F '/' '{ print $NF }' .git/HEAD)\[\033[0m\]"

if [ $(git diff --exit-code > /dev/null 2>&1; echo $?) -eq 1 ] || [ $(git diff-index --cached --quiet --ignore-submodules HEAD --; echo $?) -eq 1 ]; then
GITBRANCH="$GITBRANCH\[\033[1;31m\]*\[\033[0m\]"
else
GITBRANCH="$GITBRANCH\[\033[0;34m\]-\[\033[0m\]"
fi

if [ "x$(git status | grep Untracked)" != "x" ]; then
GITBRANCH="$GITBRANCH\[\033[1;31m\]+\[\033[0m\])"
else
GITBRANCH="$GITBRANCH\[\033[0;34m\]-\[\033[0m\])"
fi
fi

echo -ne "\[\033[0;34m\][\u@\h \W]\[\033[0m\]${GITBRANCH}\[\033[0;34m\]\\$\[\033[0m\] "
}

export PROMPT_COMMAND='PS1="$(set_prompt)"'

This gives me a very nice (and useful!) prompt:

[mathieu@localhost ~]$

Yeah, not so great... But now let's say I enter a folder which turns out to be a git repository. Name of the current branch appears:

[mathieu@localhost rpmbuild](master--)$

If there are uncommited changes to the tree, then the first green dash after the branch name becomes a red star. Just the same, if there are new untracked files in the tree, the second green dash becomes a red plus.

[mathieu@localhost rpmbuild](master*-)$

[mathieu@localhost rpmbuild](master-+)$

[mathieu@localhost rpmbuild](master*+)$

Hope that can be useful to someone. It certainly is for me :).

dimanche, juillet 12 2009

Back from the LSM

This week I was at LSM aka RMLL.

I held the Fedora booth there, alone, for the whole 5 days.

The event was really nice, I met a lot of people and tried to do my best promoting Fedora (which must not be a lot). My only regret is that... well, being alone on a booth for a week is really tiring ^^'

Thomas, Patrice and Max joined me on Friday. Max gave a talk on the Fedora Foundations. Apparently, it was filmed, so I'll try to get a hand on the video. Thomas was interviewed by the event radio, and the recording is available online (in french).

Logistic was kind of shaky. We had a really hard time accessing the Internet, both at the event and at the dorm. The event also moved on Saturday, as the university that hosted us the 4 previous days was closed. However, we were welcomed by an elephant on the Saturday place:

elephant-1

elephant-2

All in all, I had a great time, even if I would have loved to go to more than 3 conferences. I had to let the booth unattended to go to those 3, but the Ubuntu-Fr and Mandriva-Fr booth people were really helpful, especially Marianne who made some delicious cookies (I managed to let some for the visitors :-D) and Michael, who even promoted Fedora while I was away :-D.

On the Shomyu side, the event was also quit... surprising. I finally met Sonny from the Mozilla community who had contacted me earlier about it. I also got in touch with Julien from SliTaz who expressed his interest in using Shomyu for their community. The aforementioned Mandriva Michaël told me the same, and even invited me to the soon to happen AFPyro (an « apéro » organized by the french Python association), and asked me if I would be interested in presenting Shomyu at the next PyCon :-D

I also talked about it with some Ubuntu-Fr guys. It seems they are trying to build such a tool themselves (but with GoogleMaps instead of OpenLayers / OpenStreetMap, and I sincerely hope we can share some code or even merge the two projects.

I can't believe what's happening with what started as a rant on the french Fedora mailing-list. Lot's of people seem to have heard of it and are willing to use it. I sincerely hope that at least some will give me a hand, as it will not be ready any time soon if I have to go on alone.*hint hint* :-)

jeudi, mai 28 2009

It's alive!

I recently decided to spend more time working on shomyu, my little project that I had neglected for too long. After less than a month since I went back to work, shomyu 0.6 is released.

In this release, shomyu was trimmed down by unbundling all the external Javascript APIs it uses, namely TinyMCE, OpenLayers and OpenStreetMap.

I also wanted to rebase shomyu 0.6 on TurboGears 2, but I ended up not doing it for the following reasons:

  • that's a lot of work, and I was almost sure I wouldn't have this ready in time for FUDCon. I didn't want to be blocked during the hackfest because of WIP on this point.
  • also, some great features are being worked on in TurboGears 2, for example a generic registration module by a GSoC student, which is a planned feature for shomyu.
  • another thing is that it is rather complicated to install TurboGears 2 right now, as packages are still pending inclusion in Fedora. I didn't want my users / co-developers (who knows, someone might join me one day :) to have to go through the extra work of setting up a virtual env and installing TurboGears 2 manually.

As a result, this was postponed for a future milestone, probably post 0.8.

Another significant thing happened in this release: TinyMCE was totally dropped. TinyMCE is rather feature-creep comparing to what shomyu needs. I also tried using Xinha instead of TinyMCE (seemed to be more « community friendly » even if as much feature-creep), but I had a lot of trouble with using it while it was not actually bundled in shomyu (DOM manipulation error as the Xinha API is not necessarily on the same domain as shomyu, this would have been a PITA for 0.7+ releases).

Instead, I decided to use the simple wikimarkup python module. So for now, the editor area is less pretty, but as much powerful. One could think of this as a regression, but it will allow easier future development. Once milestone 0.7 is released, that APIs are fully working and I'm tackling the « prettyness » of shomyu, rich-text Javascript editors will certainly be reconsidered. :)

So, without further ado, go grab shomyu 0.6. Be sure to pay a visit to the documentation on how to run shomyu as it changed a lot since 0.5.

Report any bug you find, and help improving shomyu!

Now is time to look at the next release, as well as start planning for the shomyu hackfest that will take place at FUDCon in Berlin. If you're interested in shomyu, this would be the perfect place to start contributing!

lundi, février 9 2009

FOSDEM 2009 report

On Sunday, I was at FOSDEM 2009 in Bruxelles.

I couldn't go on Saturday, and as a result, I missed the two talks that were interesting me the much: the ones from Greg and Tomeu about Sugar and Fedora. I hope the presentations will be uploaded on the fp.o page (or somewhere else), so that I can catch up.

I spent most of the time at the booth, which allowed me to meet a lot of Fedora Ambassadors I didn't know. Loved it. Talking with people from different local communities was great, and as we discussed with Yaakov, we (the French community) really need to work in a less insular way and share experiences with others.

Regarding the booth attendance, I was once again incredibly surprised to see how people are attracted by this little green and white alien on the tables. We had 4 XOs, all of them had almost always someone toying with it. The funny thing is it looked like Fedora can be summed up to the XO, as very few people were asking about Fedora specifically, while a lot were interested in the OLPC project.

I had two requests for liveUSB creations, but I failed on the second one. It was one of those keys with a fancy partition (seen as /dev/sr1 on my Fedora 10 laptop) with programs autoruned when you plug the key on Windows (something called "U3 System"). I tried three times to create the liveUSB (both with Live USB Creator and livecd-iso-to-disk), each time, the liveUSB was successfully created but couldn't boot. Could it be this "U3" stuff that prevents booting on such USB sticks ?

Second failure of the day, someone came with an Acer Aspire One, running a custom Fedora 8 (they call it Linpus). He wanted to be able to listen to MP3 files with Amarok, but as Fedora 8 was EOLed some time ago, I couldn't find the necessary packages. Big Fail to Acer: how can you honestly sell computers with an already EOLed system ?

I could only assist to one talk: Cobbler and Koan. The talk was great, and those two look really interesting. I'm looking forward to use them at work.

So this was a great day, filled with encounters with great people, but also exhausting. I have only two regrets: not being able to go on Saturday, and not having gone there in previous years :-D. Thanks to all those who made this event a success for Fedora, and an(two) enjoyable day(s) for its community.

lundi, décembre 1 2008

Paris se pare de bleu pour un appel à la communauté

Cela a déjà été annoncé: les 6 et 7 décembre se tiendront les Rencontres Fedora parisiennes en l'honneur de Fedora 10.

D'autres vous ont déjà présenté le programme des festivités, j'aimerais néanmoins y revenir en insistant tout particulièrement sur un point.

Un des objectifs forts du Projet Fedora est son engagement envers l'upstream. Toutes les contributions Fedora sont faites directement upstream, afin que la communauté du libre dans son intégralité en profite.

Cet objectif se retrouve dans le programme de l'événement. Évidemment, nous installerons Fedora sur les ordinateurs de ceux qui le voudront. Bien sûr, nous présenteront le Projet Fedora, les nouveautés de Fedora 10, etc... Mais des conférences et ateliers plus généraux auront aussi lieu.

Jugez plutôt:

  • une conférence sur les formats ouverts et les enjeux qui y sont liés par Thierry Stoehr
  • une conférence sur le projet OLPC par deux intervenants de l'association OLPC-France
  • une conférence technique sur les outils de virtualisation sous Linux
  • un atelier sur Mutt
  • une conférence sur l'implication de Red Hat dans le libre, ou comment gagner de l'argent avec le FOSS
  • et bien d'autres !

Vous l'aurez compris, nous ne souhaitons pas voir venir uniquement des gens souhaitant de l'aide dans l'installation de Fedora.

Au lieu de ça, l'ensemble de la communauté d'utilisateurs, intéressés ou passionnés par le libre est la bienvenue. Que vous souhaitiez repartir avec Fedora installée sur votre ordinateur ou pas, venez, assistez aux conférences, participez aux ateliers. En d'autres mots, venez échanger avec nous sur le libre et passer une bonne journée, voire un week-end.

J'espère donc vous voir très nombreux, Ubunteros, Mandrivistes, Debianeux ou autres. Et Fedoristas bien sûr ;-)

mardi, septembre 30 2008

Release early, release often... release with dumb bugs :)

On Sunday, I discovered a bug in shomyu.

The Javascript library TinyMCE was called in the wrong folder (yeah, I know, stupid mistake -_-) which made it impossible to enable rich-text editing in the users descriptions.

This was fixed in master branch and in 0.5. As a consequence, I released version 0.5.1 of shomyu.

I also took the opportunity to make a new demo screencast that shows better the latest features of shomyu (the old one had been made with a very early stage of development).

Get it, try it, love it, and help improving it :)

dimanche, septembre 14 2008

Shomyu is out !

I recently introduced shomyu, a free webapp allowing members of a community to locate themselves and to add a short description about them.

I asked for being Fedora Hosted 3 weeks ago, and it finally came :-D (I suppose the guys from the Fedora Infrastructure Team were too busy lately to open my account, and I really can't blame them for that, given the hard time they certainly had ;-))

Anyway, here is the fresh new official web site for shomyu: https://fedorahosted.org/shomyu.

This little project will now try to live and grow up, so help, comments and flames are obviously welcome. :-)

dimanche, août 24 2008

Introducing shomyu

The french Fedora community is currently using frappr to display the locations of members and ambassadors.

We recently received a reminder from one of us, saying that all french ambassadors should subscribe to our frappr instance and set their location.

What a surprise! frappr is a non-free flash application that doesn't even work with swfdec (and thus I couldn't subscribe). Did I mention it was full of ads ?... :-/

That's why I started to write a free equivalent: shomyu (screencast).

On the technological side, shomyu uses:

  • Javascript with the OpenLayers API and geographical data from OpenStreetMap
  • Python / Turbogears for the backend, so that if there is interest to integrate it with the FAS (one can dream ^^), it will already fit the other Turbogears apps we have.

I'm about to release the code, I asked for being Fedorahosted.

Comments, feed-back, help, money or drinks are welcome :-)

- page 1 de 2