MicroReflexion
Feb 12, 2012

A clean ZSH prompt with GIT status integration

Here is my ZSH config to achieve two aims :

1) Clearly separates the results of commands :

2) Integrate GIT status in the prompt when working in a GIT repository :

To do that, I have added to my .zshrc the following lines :

autoload -Uz vcs_info
#zstyle ':vcs_info:*' stagedstr 'Staged'
#zstyle ':vcs_info:*' unstagedstr 'Unstaged'
zstyle ':vcs_info:git*' formats "%{$fg_bold[blue]%}[%s] %{$fg_bold[green]%}(%b)%{$reset_color%} %{$fg[red]%}%u %{$fg[yellow]%}%c"
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' enable git
precmd() {
  vcs_info

  local STATUS="`git status 2>&1`"
  if [[ "$STATUS" == *'Not a git repository'* ]] then
    GITINFO=""
  else
    GITINFO="------ ${vcs_info_msg_0_}"$'n'
  fi
}
setopt prompt_subst

export PS1=$'n'"%{$fg[green]%}"-----------------------------------------------------------------------$'n''${GITINFO}'"%{$fg[green]%}""------ [%~] %*"$'n'-----------------------------------------------------------------------"%{$reset_color%}"$'nnn'"%{$fg_bold[green]%}%n@%m:%#%{$reset_color%} "

More information about vcs_info can be found at http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Version-Control-Information

autoload -Uz vcs_info loads the vcs_info module.

zstyle ':vcs_info:git*' formats "%{$fg_bold[blue]%}[%s] %{$fg_bold[green]%}(%b)%{$reset_color%} %{$fg[red]%}%u %{$fg[yellow]%}%c" defines the output format :

  • %s : the VCS used (= git)
  • %b : the current branch
  • %u : unstaged status (= there are unstaged files in the repository)
  • %c : staged status (= there are staged files in the repository)

If you want to change the default U and S for unstaged and staged, you can use :

zstyle ':vcs_info:*' stagedstr 'Staged'
zstyle ':vcs_info:*' unstagedstr 'Unstaged'

zstyle ':vcs_info:*' check-for-changes true to monitor changes.
zstyle ':vcs_info:*' enable git to enable it for GIT VCS.

I want to show the GIT status only inside a GIT repository, not in a ordinary directory.
This is done in the precmd() by testing the STATUS variable which contains the GIT STATUS output :

precmd() {
vcs_info
local STATUS="`git status 2>&1`"
if [[ "$STATUS" == *'Not a git repository'* ]] then
GITINFO=""
else
GITINFO="------ ${vcs_info_msg_0_}"$'n'
fi
}

The prompt itself is build inside PS1 :

export PS1=$'n'"%{$fg[green]%}"-----------------------------------------------------------------------$'n''${GITINFO}'"%{$fg[green]%}""------ [%~] %*"$'n'-----------------------------------------------------------------------"%{$reset_color%}"$'nnn'"%{$fg_bold[green]%}%n@%m:%#%{$reset_color%} "

Note : you have to make a first commit before the staged and unstaged status become active.

You can see the whole .zshrc file at Gitorious : My ZSH config

Posted by in GIT, ZSH
Tags: ,


Dec 04, 2011

[FR] Une introduction à la configuration de VIM

Si vous êtes intéressé par l’éditeur de texte VIM, vous pouvez regarder sur youtube une introduction en français.
Cette présentation a pour but de vous aider à faire les premiers pas en vous montrant comment commencer à configurer VIM.

[FR] Introduction à la configuration de VIM

Posted by in VIM
Tags:


Apr 01, 2011

Is open hardware becoming real ?

Firefox, Linux, LibreOffice etc. are the proof that open software are successful.
But, open hardware has never been massively adopted and used in the industry.
Keeping everything secret is still the commonly rule followed by corporations.
It seems that thing are at least slowly changing.

First, some major corporations like TI, NXP, Freescale, Xilinx and others have started to promote their chips by creating open communities :

The fact that major corporations are looking toward open source world is certainly a big change.

Usual open software license like GNU GPL are not adapted to hardware.
Real efforts to define open hardware licenses are also in progress.
At least the FSF is considering the open hardware license :

We can also see more and more open hardware that may really interest companies.
One very interesting place to visit is the CERN Open Hardware Repository, where you can find complex projects like the White Rabbit. A system to synchronize 1000 nodes with sub ns accuracy over 10km.
Even if it’s not very used in industry, Arduino is very popular among hobbyist, and also a commercial success for its distributors. 30 000 boards were sold in 2006, and The Arduino’s community was estimated to 100 000 users in 2010.
Other open hardware actors like Dangerous Prototypes sell their products through distributors (http://www.seeedstudio.com/depot/wherelabs-m-9.html).

Some additional links :

Posted by in Open hardware
Tags: ,


Mar 06, 2011

YaJiMuMa WordPress Theme

The theme of MicroReflexion.com (this site) has been added to Gitorious under GNU AFFERO licence :

http://gitorious.org/yajimuma

More info : http://www.microreflexion.com/?page_id=68

Posted by in YaJiMuMa
Tags:


Dec 12, 2010

New version of VIP released

A new version of VIP has been released.

A wider support of style of writing component and entity has been added.

Now, you can put several signals in the same line, like :


component foo
  port (
     a,b: in bit;
     c: out bit );
end component;

or put signal after the “generic” or port “brace” :


component bar
  generic (DELAY: time :=5ns);
  port (
     in: in std_logic;
     out: out std_logic );
end component;

You can also place a brace at a new line after a “port” or a “generic” if you want :


entity e_g is
  generic
  (
     g_WIDTH : positive := 4
  );
  port 
  (
     CLK : out std_logic (31 downto 0)
  );
end entity e_g;

There are still some limitation. Please see the documentation.

Posted by in VIM, VIP
Tags: , ,