Kategorien
Entwicklung

Using pow with rvm 1.19

Since rvm 1.19.0 there is a alternative way to specify a project related ruby version and gemset through the files .ruby-version and .ruby-gemset instead of the still valid use of the .rvmrc file. The .rvmrc is of course as before the default configuration for rvm, but it requires to be trusted, as it could contain any shell command. Further the recently supported files are compatible with other ruby version managers like rbenv or chruby.

So after an upgrade of rvm a message like below would be displayed if you enter a directory which contains a .rvmrc.

You are using ‚.rvmrc‘, it requires trusting, it is slower and it is not compatible with other ruby managers,
you can switch to ‚.ruby-version‘ using ‚rvm rvmrc to [.]ruby-version‘
or ignore this warnings with ‚rvm rvmrc warning ignore /Users/dboeckma/workspace/mymine/bookmarks/.rvmrc‘,
‚.rvmrc‘ will continue to be the default project file in RVM 1 and RVM 2,
to ignore the warning for all files run ‚rvm rvmrc warning ignore all.rvmrcs‘.

Like the messages says you could switch to the new configuration with the given command.

rvm rvmrc to .ruby-version

This results in the following two files. First the .ruby-version in which the ruby version is defined.

ruby-2.0.0-p0

Second the .ruby-gemset with the gemset that should be used in conjunction with the ruby version.

octopress

Surely, the ruby version and gemset can differ in your files. 😀

So far so good. The problem comes with the next try to use pow with the new configuration files. The recommended .powrc, which comes with pow, only considers the .rvmrc file, which not exists any longer. As a result pow uses the wrong default system ruby version and gemset. With a slightly enhanced .powrc file, like the one below, it will run with both variations.

if [ -f "$rvm_path/scripts/rvm" ]; then
  source "$rvm_path/scripts/rvm"

  if [ -f ".ruby-version" ]; then 
    if [ -f ".ruby-gemset" ]; then
      rvm use `cat .ruby-version`@`cat .ruby-gemset`
    else
      rvm use `cat .ruby-version`
    fi
  elif [ -f ".rvmrc" ]; then
    source ".rvmrc"
  fi
fi

You can see the modifications also as gist on github.

Kategorien
Betriebssystem

Terminal prompt with git branch

The console of Mac OS X, is just like any unix console. It’s very powerful and can simply be customized over the preferences of the terminal application and by setting environment variables like *PS1*. So here is a picture of my current terminal.

As mentioned before, it is a combination of preferences and some variables. So here is my current setup a bit more detailed.

First of all the preferences of the terminal app. Here I changed mainly the text font and color. I think the ordinary settings are self explaining. You can start by duplicating an existing configuration over an option under the gear symbol and customize it. Mine is based on the *Pro*.

If you like it, you can download the configuration of MyOrangeTerminal.

To activate the new configuration for every new window, go to the *Startup* tab and select it under *On startup, open*.

The second is the environment variable *PS1* which should be specified in the file *~/.profile*, which will be automatically executed on each start. This definition includes a nice behaviour in interaction with git. As you may have seen in the first picture it shows the current branch of the git repository, if you in one. Crucial is that you have git installed and included the git *bash completion* which comes along with the git installer for Mac OS X.

More information about the meaning of the components in the *PS1* definition can be found in the article prompt magic. It mainly describes the colours and available variables that can be used in the *PS1* environment variable.