App-Rakubrew
view release on metacpan or search on metacpan
lib/App/Rakubrew/Shell/Zsh.pm view on Meta::CPAN
}
sub get_init_code {
my $self = shift;
my $path = env('PATH');
$path = $self->clean_path($path);
if (get_brew_mode() eq 'env') {
my $version = get_global_version();
if ($version && $version ne 'system' && !is_version_broken($version)) {
$path = join(':', get_bin_paths($version), $path);
}
}
else { # get_brew_mode() eq 'shim'
$path = join(':', $shim_dir, $path);
}
return <<EOT;
export PATH="$path"
$brew_name() {
command $brew_exec internal_hooked Zsh "\$@" &&
eval "`command $brew_exec internal_shell_hook Zsh post_call_eval "\$@"`"
}
compctl -K _${brew_name}_completions -x 'p[2] w[1,register]' -/ -- $brew_name
_${brew_name}_completions() {
local WORDS POS RESULT
read -cA WORDS
read -cn POS
reply=(\$(command $brew_exec internal_shell_hook Zsh completions \$POS \$WORDS))
}
EOT
}
sub post_call_eval {
my $self = shift;
$self->print_shellmod_code(@_);
}
sub get_path_setter_code {
my $self = shift;
my $path = shift;
return "export PATH=\"$path\"";
}
sub get_shell_setter_code {
my $self = shift;
my $version = shift;
return "export $env_var=\"$version\"";
}
sub get_shell_unsetter_code {
my $self = shift;
return "unset $env_var";
}
sub completions {
my $self = shift;
my $index = shift;
say join(' ', $self->get_completions($self->strip_executable($index - 1, @_)));
}
1;
( run in 0.305 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )