cosh is a small ruby utility that generates a shell environment & alias configuration for multiple shells that don't share a common syntax.
It currently supports the following families:
- the POSIXy family:
shbashashdashkshzsh - csh family:
cshtcsh - fish family:
fish
- ruby 2.2 (probably works with 2.0+)
- any of the supported shells
Add something like the following to your shell's startup script (bashrc, cshrc, config.fish):
# sh-like
# NOTE: sourcing a process-substitution may not work on other sh-like shells
# and will not work on old versions of bash
source <( cosh --shell bash ~/.config/cosh/config.rb )# csh-like
set rc=/tmp/cshrc-`date +s`
cosh --shell csh ~/.config/cosh/config.rb >${rc} && source ${rc} && rm ${rc}# fish
source ( cosh --shell fish ~/.config/cosh/config.rb | psub )It's recommended that you use the actual shell name, since that lets you do some fancy conditionals in the config.
config.rb is a standard ruby file that gets evaled by cosh. Any standard ruby should work in it, and there's a basic DSL for common operations.
Example:
var foo, 'bar'sets an exported variablefootobarlvar bar, 'baz'sets a local variablebartobazalias foo, 'bar'creates an alias namedfoo, which will runbarwhen run
Refer to config.sample.rb for more details.