mirror of https://github.com/ohmyzsh/ohmyzsh.git
Compare commits
1 Commits
08cb9393a7
...
52b0da9c30
Author | SHA1 | Date |
---|---|---|
Siddharth Agrawal | 52b0da9c30 |
|
@ -36,10 +36,3 @@ Last login: Fri Jan 30 23:12:26 on ttys001
|
||||||
- `cowsay` if using `chuck_cow`
|
- `cowsay` if using `chuck_cow`
|
||||||
|
|
||||||
Available via homebrew, apt, ...
|
Available via homebrew, apt, ...
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> In addition to installing `fortune`, it may be necessary to run:
|
|
||||||
>
|
|
||||||
> `strfile $ZSH/plugins/chucknorris/fortunes/chucknorris\n`
|
|
||||||
>
|
|
||||||
> (include the "\n" literally) to write the fortune data to the proper directory.
|
|
||||||
|
|
|
@ -8,36 +8,30 @@ To use it, add `perl` to the plugins array in your zshrc file:
|
||||||
plugins=(... perl)
|
plugins=(... perl)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Perlbrew activation
|
|
||||||
|
|
||||||
If the plugin detects that `perlbrew` hasn't been activated, yet there is an installation of it in
|
|
||||||
`$PERLBREW_ROOT`, it'll initialize by default. To avoid this behaviour, set `ZSH_PERLBREW_ACTIVATE=false`
|
|
||||||
before `source oh-my-zsh.sh` in your zshrc.
|
|
||||||
|
|
||||||
## Aliases
|
## Aliases
|
||||||
|
|
||||||
| Aliases | Command | Description |
|
| Aliases | Command | Description |
|
||||||
| :---------- | :----------------- | :------------------------------------- |
|
| :------------ | :----------------- | :------------------------------------- |
|
||||||
| pbi | `perlbrew install` | Install specific perl version |
|
| pbi | `perlbrew install` | Install specific perl version |
|
||||||
| pbl | `perlbrew list` | List all perl version installed |
|
| pbl | `perlbrew list` | List all perl version installed |
|
||||||
| pbo | `perlbrew off` | Go back to the system perl |
|
| pbo | `perlbrew off` | Go back to the system perl |
|
||||||
| pbs | `perlbrew switch` | Turn it back on |
|
| pbs | `perlbrew switch` | Turn it back on |
|
||||||
| pbu | `perlbrew use` | Use specific version of perl |
|
| pbu | `perlbrew use` | Use specific version of perl |
|
||||||
| pd | `perldoc` | Show the perl documentation |
|
| pd | `perldoc` | Show the perl documentation |
|
||||||
| ple | `perl -wlne` | Use perl like awk/sed |
|
| ple | `perl -wlne` | Use perl like awk/sed |
|
||||||
| latest-perl | `curl ...` | Show the latest stable release of Perl |
|
| latest-perl | `curl ...` | Show the latest stable release of Perl |
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
||||||
- `newpl`: creates a basic Perl script file and opens it with $EDITOR.
|
* `newpl`: creates a basic Perl script file and opens it with $EDITOR.
|
||||||
|
|
||||||
- `pgs`: Perl Global Substitution: `pgs <find_pattern> <replace_pattern> <filename>` Looks for
|
* `pgs`: Perl Global Substitution: `pgs <find_pattern> <replace_pattern> <filename>`
|
||||||
`<find_pattern>` and replaces it with `<replace_pattern>` in `<filename>`.
|
Looks for `<find_pattern>` and replaces it with `<replace_pattern>` in `<filename>`.
|
||||||
|
|
||||||
- `prep`: Perl grep, because 'grep -P' is terrible: `prep <pattern> [<filename>]` Lets you work with pipes or
|
* `prep`: Perl grep, because 'grep -P' is terrible: `prep <pattern> [<filename>]`
|
||||||
files (if no `<filename>` provided, use stdin).
|
Lets you work with pipes or files (if no `<filename>` provided, use stdin).
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
In order to make this work, you will need to have perl installed. More info on the usage and install:
|
In order to make this work, you will need to have perl installed.
|
||||||
https://www.perl.org/get.html
|
More info on the usage and install: https://www.perl.org/get.html
|
||||||
|
|
|
@ -54,12 +54,3 @@ pgs() { # [find] [replace] [filename]
|
||||||
prep() { # [pattern] [filename unless STDOUT]
|
prep() { # [pattern] [filename unless STDOUT]
|
||||||
perl -nle 'print if /'"$1"'/;' $2
|
perl -nle 'print if /'"$1"'/;' $2
|
||||||
}
|
}
|
||||||
|
|
||||||
# If the 'perlbrew' function isn't defined, perlbrew isn't setup.
|
|
||||||
if [[ $ZSH_PERLBREW_ACTIVATE != false ]] && (( ! $+functions[perlbrew] )); then
|
|
||||||
local _perlbrew="${PERLBREW_ROOT:-${HOME}/perl5/perlbrew}"
|
|
||||||
if [[ -f "${_perlbrew}/etc/bashrc" ]]; then
|
|
||||||
source "${_perlbrew}/etc/bashrc"
|
|
||||||
fi
|
|
||||||
unset _perlbrew
|
|
||||||
fi
|
|
||||||
|
|
|
@ -24,45 +24,16 @@ plugins=(... python)
|
||||||
The plugin provides three utilities to manage Python 3.3+ [venv](https://docs.python.org/3/library/venv.html)
|
The plugin provides three utilities to manage Python 3.3+ [venv](https://docs.python.org/3/library/venv.html)
|
||||||
virtual environments:
|
virtual environments:
|
||||||
|
|
||||||
- `mkv [name]`: make a new virtual environment called `name` in the current directory.
|
- `mkv [name]`: make a new virtual environment called `name` (default: if set `$PYTHON_VENV_NAME`, else
|
||||||
**Default**: `$PYTHON_VENV_NAME` if set, otherwise `venv`.
|
`venv`) in the current directory.
|
||||||
|
|
||||||
- `vrun [name]`: activate the virtual environment called `name` in the current directory.
|
- `vrun [name]`: Activate the virtual environment called `name` (default: if set `$PYTHON_VENV_NAME`, else
|
||||||
**Default**: the first existing in `$PYTHON_VENV_NAMES`.
|
`venv`) in the current directory.
|
||||||
|
|
||||||
- `auto_vrun`: automatically activate the venv virtual environment when entering a directory containing
|
- `auto_vrun`: Automatically activate the venv virtual environment when entering a directory containing
|
||||||
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated
|
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated
|
||||||
in subdirectories).
|
in subdirectories).
|
||||||
- To enable the feature, set `PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
|
- To enable the feature, set `export PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
|
||||||
- The plugin activates the first existing virtual environment, in order, appearing in `$PYTON_VENV_NAMES`.
|
- Plugin activates first virtual environment in lexicographic order whose name begins with `<venv-name>`.
|
||||||
The default virtual environment name is `venv`. To use a different name, set
|
The default virtual environment name is `venv`. To use a different name, set
|
||||||
`PYTHON_VENV_NAME=<venv-name>`. For example: `PYTHON_VENV_NAME=".venv"`
|
`export PYTHON_VENV_NAME=<venv-name>`. For example: `export PYTHON_VENV_NAME=".venv"`
|
||||||
|
|
||||||
### Settings
|
|
||||||
|
|
||||||
You can set these variables in your `.zshrc` file, before Oh My Zsh is sourced.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
PYTHON_VENV_NAME=".venv"
|
|
||||||
PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv)
|
|
||||||
...
|
|
||||||
plugins=(... python)
|
|
||||||
source "$ZSH/oh-my-zsh.sh"
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## `$PYTHON_VENV_NAME`
|
|
||||||
|
|
||||||
**Default**: `venv`.
|
|
||||||
|
|
||||||
Preferred name for virtual environments, for example when creating via `mkv`.
|
|
||||||
|
|
||||||
## `$PYTHON_VENV_NAMES`
|
|
||||||
|
|
||||||
**Default**: `$PYTHON_VENV_NAME venv .venv`.
|
|
||||||
|
|
||||||
Array of virtual environment names to be checked, in order, by `vrun` and `auto_vrun`.
|
|
||||||
This means these functions will load the first existing virtual environment in this list.
|
|
||||||
Duplicate names are ignored.
|
|
||||||
|
|
||||||
|
|
|
@ -47,29 +47,12 @@ alias pygrep='grep -nr --include="*.py"'
|
||||||
alias pyserver="python3 -m http.server"
|
alias pyserver="python3 -m http.server"
|
||||||
|
|
||||||
|
|
||||||
## venv settings
|
## venv utilities
|
||||||
: ${PYTHON_VENV_NAME:=venv}
|
: ${PYTHON_VENV_NAME:=venv}
|
||||||
|
|
||||||
# Array of possible virtual environment names to look for, in order
|
|
||||||
# -U for removing duplicates
|
|
||||||
typeset -gaU PYTHON_VENV_NAMES
|
|
||||||
[[ -n "$PYTHON_VENV_NAMES" ]] || PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv .venv)
|
|
||||||
|
|
||||||
# Activate a the python virtual environment specified.
|
# Activate a the python virtual environment specified.
|
||||||
# If none specified, use the first existing in $PYTHON_VENV_NAMES.
|
# If none specified, use $PYTHON_VENV_NAME, else 'venv'.
|
||||||
function vrun() {
|
function vrun() {
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
local name
|
|
||||||
for name in $PYTHON_VENV_NAMES; do
|
|
||||||
local venvpath="${name:P}"
|
|
||||||
if [[ -d "$venvpath" ]]; then
|
|
||||||
vrun "$name"
|
|
||||||
return $?
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo >&2 "Error: no virtual environment found in current directory"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local name="${1:-$PYTHON_VENV_NAME}"
|
local name="${1:-$PYTHON_VENV_NAME}"
|
||||||
local venvpath="${name:P}"
|
local venvpath="${name:P}"
|
||||||
|
|
||||||
|
@ -108,11 +91,10 @@ if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $PWD != ${VIRTUAL_ENV:h} ]]; then
|
if [[ $PWD != ${VIRTUAL_ENV:h} ]]; then
|
||||||
local file
|
for _file in "${PYTHON_VENV_NAME}"*/bin/activate(N.); do
|
||||||
for file in "${^PYTHON_VENV_NAMES[@]}"/bin/activate(N.); do
|
|
||||||
# make sure we're not in a venv already
|
# make sure we're not in a venv already
|
||||||
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
|
||||||
source $file > /dev/null 2>&1
|
source $_file > /dev/null 2>&1
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -15,11 +15,4 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_tailscale" ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If using the alias, let's make sure that the aliased executable is also bound
|
|
||||||
# in case the alias points to "Tailscale" instead of "tailscale".
|
|
||||||
# See https://github.com/ohmyzsh/ohmyzsh/discussions/12928
|
|
||||||
if (( $+aliases[tailscale] )); then
|
|
||||||
_comps[${aliases[tailscale]:t}]=_tailscale
|
|
||||||
fi
|
|
||||||
|
|
||||||
tailscale completion zsh >| "$ZSH_CACHE_DIR/completions/_tailscale" &|
|
tailscale completion zsh >| "$ZSH_CACHE_DIR/completions/_tailscale" &|
|
||||||
|
|
Loading…
Reference in New Issue