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:
sh
bash
ash
dash
ksh
zsh
- csh family:
csh
tcsh
- 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 eval
ed 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 variablefoo
tobar
lvar bar, 'baz'
sets a local variablebar
tobaz
alias foo, 'bar'
creates an alias namedfoo
, which will runbar
when run
Refer to config.sample.rb
for more details.