
use Zoidberg::Shell qw/:all/;
use Zoidberg::Utils qw/:output/;

$shell = Zoidberg::Shell->current(); # get object

### welcome and exit messages
message(
"--[ This is the Zoidberg shell ]--[ Version $Zoidberg::VERSION ]--
### This is a development version, consider it unstable" );
$shell->{events}{exit} = sub { message("--[ CU ]--[ Please report all bugs ]--") };

### set environment
$ENV{PS1} = '\C{bold,blue}\u@\H \A \C{green}\W\$\C{reset} ';
$ENV{PS2} = '\C{bold,blue}>\C{reset} ';
# For those wannabe l337 people ;)
#$ENV{PS1} = '\C{bold,black}/--( \u@\H )-( \t )-( \w )-( load \P{%l} ) * *\n\\-- * \$\C{reset} ';
#$ENV{PS2} = ' \C{bold,black}* *\C{reset} ';
defined $ENV{$$_[0]} or $ENV{$$_[0]} = $$_[1] for
	[ EDITOR   => 'vim'  ],
	[ VISUAL   => 'vim'  ],
#	[ MAILER   => ?      ],
	[ PAGER    => 'less' ],
	[ BROWSER  => 'lynx' ],
	[ CLICOLOR => 1      ];

# some glue for the Gentoo distrobution
if (
	-e '/etc/profile.env' and
	open EXP, '/etc/profile.env'
) {
	while (<EXP>) {
		next unless /^\s*export\s*(\w+)=['"](.*?)['"]/;
		$ENV{$1} = $2 unless defined $ENV{$1};
	}
	close EXP;
}

# Some programs expect this var to point to a fully posix compliant shell.
# Since zoid doesn't use this var, no harm is done.
# Notice that even perl core utils like perldoc have expectations about it.
$ENV{SHELL} = '/bin/sh';

### set aliases
alias( {
	up  => 'cd ..',
	bye => 'exit Bye bye',
	l   => 'ls',
	ll  => 'ls -l',
	la  => 'ls -la',
	j   => 'jobs',
	'?' => 'help',
	( ($> == 0) # root gets other aliases
		? ( perldoc => 'perldoc -U', perlfunc => 'perldoc -Uf' )
		: ( perlfunc => 'perldoc -f' )
	),
} );

### default settings
set('notify', 'notify_verbose');

### OS dependent stuff
if ($^O eq 'linux' and $ENV{CLICOLOR}) { # _GNU_/Linux rigth ?
	alias( { ls => 'ls --color=auto' } );
}
