abra zsh config 2.0
This commit is contained in:
@@ -1,28 +1,32 @@
|
||||
Perl
|
||||
====
|
||||
|
||||
Enables local [Perl][1] module installation on Mac OS X and defines aliases.
|
||||
Enables local [Perl][1] module installation on macOS and defines aliases.
|
||||
|
||||
Local Module Installation
|
||||
-------------------------
|
||||
|
||||
Perl versions older than 5.14 do not support the local installation of Perl
|
||||
modules natively. This module allows for local installation of Perl modules on
|
||||
Mac OS X in *~/Library/Perl/5.12* by altering the environment.
|
||||
macOS in *~/Library/Perl/5.12* by altering the environment.
|
||||
|
||||
### Usage
|
||||
|
||||
For Perl versions older than 5.14, install *local::lib*.
|
||||
|
||||
curl -L -C - -O http://search.cpan.org/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz
|
||||
tar xvf local-lib-1.008004.tar.gz
|
||||
cd local-lib-1.008004
|
||||
perl Makefile.PL --bootstrap=$HOME/Library/Perl/5.12
|
||||
make && make test && make install
|
||||
```console
|
||||
curl -L -C - -O http://search.cpan.org/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz
|
||||
tar xvf local-lib-1.008004.tar.gz
|
||||
cd local-lib-1.008004
|
||||
perl Makefile.PL --bootstrap=$HOME/Library/Perl/5.12
|
||||
make && make test && make install
|
||||
```
|
||||
|
||||
Install *cpanminus*:
|
||||
|
||||
curl -L http://cpanmin.us | perl - --self-upgrade
|
||||
```console
|
||||
curl -L http://cpanmin.us | perl - --self-upgrade
|
||||
```
|
||||
|
||||
Perlbrew
|
||||
--------
|
||||
@@ -30,6 +34,14 @@ Perlbrew
|
||||
An alternative to the above is to use [Perlbrew][2], which allows for the
|
||||
management of multiple, isolated Perl installations in the home directory.
|
||||
|
||||
plenv
|
||||
-----
|
||||
|
||||
Yet another alternative is [plenv][3]. This is inspired from rbenv and enables
|
||||
switching between multiple binary installations.
|
||||
|
||||
The subcommands of plenv is similar with rbenv.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
@@ -51,13 +63,52 @@ Aliases
|
||||
- `plbu` uninstalls a Perl version.
|
||||
- `plbx` temporarily sets the Perl version to use.
|
||||
|
||||
### plenv
|
||||
|
||||
- `plv` manages Perl environments.
|
||||
- `plvc` List all available plenv commands.
|
||||
- `plvl` Set or show the local application-specific Perl version.
|
||||
- `plvg` Set or show the global Perl version.
|
||||
- `plvs` Set or show the shell-specific Perl version.
|
||||
- `plvi` Install a Perl version using the perl-build plugin.
|
||||
- `plvu` Uninstall a specific Perl version.
|
||||
- `plvr` Rehash plenv shims (run this after installing executables).
|
||||
- `plvv` Show the current Perl version and its origin.
|
||||
- `plvV` List all Perl versions available to plenv.
|
||||
- `plvw` Display the full path to an executable.
|
||||
- `plvW` List all Perl versions that contain the given executable.
|
||||
- `plvm` List cpan modules in current perl.
|
||||
- `plvM` Migrate cpan modules from other version.
|
||||
- `plvI` Install cpanm.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
- `perl-info` exposes information about the Perl environment via the
|
||||
`$perl_info` associative array.
|
||||
|
||||
Theming
|
||||
-------
|
||||
|
||||
To display the name of the current Perl version in a prompt, define the
|
||||
following style in the `prompt_name_setup` function.
|
||||
|
||||
```sh
|
||||
# %v - perl version.
|
||||
zstyle ':prezto:module:perl:info:version' format 'version:%v'
|
||||
```
|
||||
|
||||
Then add `$perl_info[version]` to `$PROMPT` or `$RPROMPT` and call
|
||||
`perl-info` in the `prompt_name_precmd` hook function.
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
*The authors of this module should be contacted via the [issue tracker][3].*
|
||||
*The authors of this module should be contacted via the [issue tracker][4].*
|
||||
|
||||
- [Sorin Ionescu](https://github.com/sorin-ionescu)
|
||||
|
||||
[1]: http://www.perl.org
|
||||
[2]: http://perlbrew.pl
|
||||
[3]: https://github.com/sorin-ionescu/prezto/issues
|
||||
[3]: https://github.com/tokuhirom/plenv
|
||||
[4]: https://github.com/sorin-ionescu/prezto/issues
|
||||
|
34
.zprezto/modules/perl/functions/perl-info
Normal file
34
.zprezto/modules/perl/functions/perl-info
Normal file
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# Exposes information about the Perl environment via the $perl_info associative
|
||||
# array.
|
||||
#
|
||||
# Authors:
|
||||
# JINNOUCHI Yasushi <delphinus@remora.cx>
|
||||
#
|
||||
|
||||
# function perl-info {
|
||||
|
||||
local version
|
||||
local version_format
|
||||
local version_formatted
|
||||
|
||||
# Clean up previous $perl_info.
|
||||
unset perl_info
|
||||
typeset -gA perl_info
|
||||
|
||||
if (( $+commands[perlbrew] )); then
|
||||
version="${PERLBREW_PERL##*perl-}"
|
||||
elif (( $+commands[plenv] )); then
|
||||
version=$(plenv version-name)
|
||||
elif (( $+commands[perl] )); then
|
||||
version=$(perl -e 'printf "%vd", $^V')
|
||||
fi
|
||||
|
||||
# Format version.
|
||||
if [[ -n "$version" ]]; then
|
||||
zstyle -s ':prezto:module:perl:info:version' format 'version_format'
|
||||
zformat -f version_formatted "$version_format" "v:$version"
|
||||
perl_info[version]="$version_formatted"
|
||||
fi
|
||||
|
||||
# }
|
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Enables local Perl module installation on Mac OS X and defines aliases.
|
||||
# Enables local Perl module installation on macOS and defines aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
@@ -10,25 +10,47 @@ if (( ! $+commands[perl] )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Load Perlbrew or plenv
|
||||
#
|
||||
|
||||
# Load Perlbrew into the shell session.
|
||||
if [[ -s "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/bashrc" ]]; then
|
||||
source "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/bashrc"
|
||||
|
||||
# Load Perlbrew completion.
|
||||
if [[ -s "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/perlbrew-completion.bash" ]]; then
|
||||
source "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/etc/perlbrew-completion.bash"
|
||||
fi
|
||||
|
||||
# Load manually installed plenv into the shell session.
|
||||
elif [[ -s "$HOME/.plenv/bin/plenv" ]]; then
|
||||
path=("$HOME/.plenv/bin" $path)
|
||||
eval "$(plenv init - --no-rehash zsh)"
|
||||
|
||||
# Load package manager installed plenv into the shell session.
|
||||
elif (( $+commands[plenv] )); then
|
||||
eval "$(plenv init - --no-rehash zsh)"
|
||||
fi
|
||||
|
||||
#
|
||||
# Local Module Installation
|
||||
#
|
||||
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
# Perl is slow; cache its output.
|
||||
cache_file="${0:h}/cache.zsh"
|
||||
cache_file="${TMPDIR:-/tmp}/prezto-perl-cache.$UID.zsh"
|
||||
perl_path="$HOME/Library/Perl/5.12"
|
||||
|
||||
if [[ -f "$perl_path/lib/perl5/local/lib.pm" ]]; then
|
||||
if [[ ! -s "$cache_file" ]]; then
|
||||
if [[ "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" || ! -s "$cache_file" ]]; then
|
||||
perl -I$perl_path/lib/perl5 -Mlocal::lib=$perl_path >! "$cache_file"
|
||||
fi
|
||||
|
||||
source "$cache_file"
|
||||
fi
|
||||
|
||||
unset perl_path
|
||||
unset cache_file
|
||||
unset cache_file perl_path
|
||||
fi
|
||||
|
||||
#
|
||||
@@ -41,12 +63,31 @@ alias pld='perldoc'
|
||||
alias ple='perl -wlne'
|
||||
|
||||
# Perlbrew
|
||||
alias plb='perlbrew'
|
||||
alias plba='perlbrew available'
|
||||
alias plbi='perlbrew install'
|
||||
alias plbl='perlbrew list'
|
||||
alias plbo='perlbrew off'
|
||||
alias plbO='perlbrew switch-off'
|
||||
alias plbs='perlbrew switch'
|
||||
alias plbu='perlbrew use'
|
||||
alias plbx='perlbrew uninstall'
|
||||
if (( $+commands[perlbrew] )); then
|
||||
alias plb='perlbrew'
|
||||
alias plba='perlbrew available'
|
||||
alias plbi='perlbrew install'
|
||||
alias plbl='perlbrew list'
|
||||
alias plbo='perlbrew off'
|
||||
alias plbO='perlbrew switch-off'
|
||||
alias plbs='perlbrew switch'
|
||||
alias plbu='perlbrew use'
|
||||
alias plbx='perlbrew uninstall'
|
||||
|
||||
elif (( $+commands[plenv] )); then
|
||||
alias plv='plenv'
|
||||
alias plvc='plenv commands'
|
||||
alias plvl='plenv local'
|
||||
alias plvg='plenv global'
|
||||
alias plvs='plenv shell'
|
||||
alias plvi='plenv install'
|
||||
alias plvu='plenv uninstall'
|
||||
alias plvr='plenv rehash'
|
||||
alias plvv='plenv version'
|
||||
alias plvV='plenv versions'
|
||||
alias plvw='plenv which'
|
||||
alias plvW='plenv whence'
|
||||
alias plvm='plenv list-modules'
|
||||
alias plvM='plenv migrate-modules'
|
||||
alias plvI='plenv install-cpanm'
|
||||
fi
|
||||
|
Reference in New Issue
Block a user