| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::Rakubrew::Shell::Zsh; | 
| 2 | 1 |  |  | 1 |  | 6 | use App::Rakubrew::Shell; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 44 |  | 
| 3 |  |  |  |  |  |  | our @ISA = "App::Rakubrew::Shell"; | 
| 4 | 1 |  |  | 1 |  | 5 | use strict; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 19 |  | 
| 5 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 22 |  | 
| 6 | 1 |  |  | 1 |  | 16 | use 5.010; | 
|  | 1 |  |  |  |  | 4 |  | 
| 7 | 1 |  |  | 1 |  | 6 | use File::Spec::Functions qw(catfile); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 50 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 5 | use App::Rakubrew::Variables; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 156 |  | 
| 10 | 1 |  |  | 1 |  | 8 | use App::Rakubrew::Tools; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 77 |  | 
| 11 | 1 |  |  | 1 |  | 6 | use App::Rakubrew::VersionHandling; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 123 |  | 
| 12 | 1 |  |  | 1 |  | 6 | use App::Rakubrew::Build; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 569 |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | sub supports_hooking { | 
| 15 | 0 |  |  | 0 | 0 | 0 | my $self = shift; | 
| 16 | 0 |  |  |  |  | 0 | 1; | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | sub install_note { | 
| 20 | 1 |  |  | 1 | 0 | 319 | my $rc_file = qw( .zshenv ); | 
| 21 | 1 | 50 |  |  |  | 5 | if ( exists $ENV{ZDOTDIR} ) { | 
| 22 | 0 |  |  |  |  | 0 | $rc_file = catfile( $ENV{ZDOTDIR}, $rc_file ); | 
| 23 |  |  |  |  |  |  | } | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 1 |  |  |  |  | 6 | my $text = < | 
| 26 |  |  |  |  |  |  | Load $brew_name automatically in `zsh` by adding | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | eval "\$($brew_exec init Zsh)" | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | to ~/$rc_file. | 
| 31 |  |  |  |  |  |  | This can be easily done using: | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | echo 'eval "\$($brew_exec init Zsh)"' >> ~/$rc_file | 
| 34 |  |  |  |  |  |  | EOT | 
| 35 |  |  |  |  |  |  |  | 
| 36 | 1 | 50 |  |  |  | 4 | if ($prefix =~ / /) { | 
| 37 | 0 |  |  |  |  | 0 | $text .= < | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | =================================== WARNING ================================== | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | rakubrews home directory is currently | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | $prefix | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | That folder contains spaces. This will break building rakudos as the build | 
| 46 |  |  |  |  |  |  | system currently doesn't work in such a path. You can work around this problem | 
| 47 |  |  |  |  |  |  | by changing that folder to a directory without spaces. Do so by putting | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | export RAKUBREW_HOME=/some/folder/without/space/rakubrew | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | in your `~/$rc_file` file *before* the `eval` line. | 
| 52 |  |  |  |  |  |  | EOW | 
| 53 |  |  |  |  |  |  | } | 
| 54 | 1 |  |  |  |  | 18 | return $text; | 
| 55 |  |  |  |  |  |  | } | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | sub get_init_code { | 
| 58 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 59 | 0 |  |  |  |  |  | my $path = $ENV{PATH}; | 
| 60 | 0 |  |  |  |  |  | $path = $self->clean_path($path); | 
| 61 | 0 | 0 |  |  |  |  | if (get_brew_mode() eq 'env') { | 
| 62 | 0 |  |  |  |  |  | my $version = get_global_version(); | 
| 63 | 0 | 0 | 0 |  |  |  | if ($version && $version ne 'system' && !is_version_broken($version)) { | 
|  |  |  | 0 |  |  |  |  | 
| 64 | 0 |  |  |  |  |  | $path = join(':', get_bin_paths($version), $path); | 
| 65 |  |  |  |  |  |  | } | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  | else { # get_brew_mode() eq 'shim' | 
| 68 | 0 |  |  |  |  |  | $path = join(':', $shim_dir, $path); | 
| 69 |  |  |  |  |  |  | } | 
| 70 |  |  |  |  |  |  |  | 
| 71 | 0 |  |  |  |  |  | return < | 
| 72 |  |  |  |  |  |  | export PATH="$path" | 
| 73 |  |  |  |  |  |  | $brew_name() { | 
| 74 |  |  |  |  |  |  | command $brew_exec internal_hooked Zsh "\$@" && | 
| 75 |  |  |  |  |  |  | eval "`command $brew_exec internal_shell_hook Zsh post_call_eval "\$@"`" | 
| 76 |  |  |  |  |  |  | } | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | compctl -K _${brew_name}_completions -x 'p[2] w[1,register]' -/ -- $brew_name | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | _${brew_name}_completions() { | 
| 81 |  |  |  |  |  |  | local WORDS POS RESULT | 
| 82 |  |  |  |  |  |  | read -cA WORDS | 
| 83 |  |  |  |  |  |  | read -cn POS | 
| 84 |  |  |  |  |  |  | reply=(\$(command $brew_exec internal_shell_hook Zsh completions \$POS \$WORDS)) | 
| 85 |  |  |  |  |  |  | } | 
| 86 |  |  |  |  |  |  | EOT | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | } | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | sub post_call_eval { | 
| 91 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 92 | 0 |  |  |  |  |  | $self->print_shellmod_code(@_); | 
| 93 |  |  |  |  |  |  | } | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | sub get_path_setter_code { | 
| 96 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 97 | 0 |  |  |  |  |  | my $path = shift; | 
| 98 | 0 |  |  |  |  |  | return "export PATH=\"$path\""; | 
| 99 |  |  |  |  |  |  | } | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | sub get_shell_setter_code { | 
| 102 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 103 | 0 |  |  |  |  |  | my $version = shift; | 
| 104 | 0 |  |  |  |  |  | return "export $env_var=\"$version\""; | 
| 105 |  |  |  |  |  |  | } | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | sub get_shell_unsetter_code { | 
| 108 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 109 | 0 |  |  |  |  |  | return "unset $env_var"; | 
| 110 |  |  |  |  |  |  | } | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | sub completions { | 
| 113 | 0 |  |  | 0 | 0 |  | my $self = shift; | 
| 114 | 0 |  |  |  |  |  | my $index = shift; | 
| 115 | 0 |  |  |  |  |  | say join(' ', $self->get_completions($self->strip_executable($index - 1, @_))); | 
| 116 |  |  |  |  |  |  | } | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | 1; | 
| 119 |  |  |  |  |  |  |  |