0
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-09-19 04:01:21 +02:00

fix: use python3 for all python invocations (#10832)

This commit is contained in:
Carlo Sala 2022-04-09 14:45:42 +02:00 committed by GitHub
parent b3999a4b15
commit 0818df057c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 17 additions and 17 deletions

View file

@ -3,9 +3,9 @@
# - acs: alias cheatsheet # - acs: alias cheatsheet
# group alias by command, pass addition argv to grep. # group alias by command, pass addition argv to grep.
function acs(){ function acs(){
(( $+commands[python] )) || { (( $+commands[python3] )) || {
echo "[error] No python executable detected" echo "[error] No python executable detected"
return return
} }
alias | python ${functions_source[$0]:h}/cheatsheet.py $@ alias | python3 ${functions_source[$0]:h}/cheatsheet.py $@
} }

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
import sys import sys
import itertools import itertools
import termcolor import termcolor

View file

@ -13,7 +13,7 @@ See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
## Requirements ## Requirements
This plugin uses `python`, so your host needs to have it installed This plugin uses `python3`, so your host needs to have it installed.
## Examples ## Examples

View file

@ -36,7 +36,7 @@ function update_current_git_vars() {
unset __CURRENT_GIT_STATUS unset __CURRENT_GIT_STATUS
local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py" local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
_GIT_STATUS=$(python ${gitstatus} 2>/dev/null) _GIT_STATUS=$(python3 ${gitstatus} 2>/dev/null)
__CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}") __CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}")
GIT_BRANCH=$__CURRENT_GIT_STATUS[1] GIT_BRANCH=$__CURRENT_GIT_STATUS[1]
GIT_AHEAD=$__CURRENT_GIT_STATUS[2] GIT_AHEAD=$__CURRENT_GIT_STATUS[2]

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
from __future__ import print_function from __future__ import print_function
import os import os

View file

@ -8,7 +8,7 @@ fi
# If method undefined, find the first one that is installed # If method undefined, find the first one that is installed
if [[ -z "$JSONTOOLS_METHOD" ]]; then if [[ -z "$JSONTOOLS_METHOD" ]]; then
for JSONTOOLS_METHOD in node python ruby; do for JSONTOOLS_METHOD in node python3 ruby; do
# If method found, break out of loop # If method found, break out of loop
(( $+commands[$JSONTOOLS_METHOD] )) && break (( $+commands[$JSONTOOLS_METHOD] )) && break
# Otherwise unset the variable # Otherwise unset the variable
@ -45,12 +45,12 @@ case "$JSONTOOLS_METHOD" in
xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))" xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"
} }
;; ;;
python) python3)
function pp_json() { function pp_json() {
python -c 'import sys; del sys.path[0]; import runpy; runpy._run_module_as_main("json.tool")' python3 -c 'import sys; del sys.path[0]; import runpy; runpy._run_module_as_main("json.tool")'
} }
function is_json() { function is_json() {
python -c ' python3 -c '
import sys; del sys.path[0]; import sys; del sys.path[0];
import json import json
try: try:
@ -61,14 +61,14 @@ except ValueError:
' '
} }
function urlencode_json() { function urlencode_json() {
python -c ' python3 -c '
import sys; del sys.path[0]; import sys; del sys.path[0];
from urllib.parse import quote_plus from urllib.parse import quote_plus
print(quote_plus(sys.stdin.read())) print(quote_plus(sys.stdin.read()))
' '
} }
function urldecode_json() { function urldecode_json() {
python -c ' python3 -c '
import sys; del sys.path[0]; import sys; del sys.path[0];
from urllib.parse import unquote_plus from urllib.parse import unquote_plus
print(unquote_plus(sys.stdin.read())) print(unquote_plus(sys.stdin.read()))

View file

@ -89,7 +89,7 @@ if [[ $FOUND_PYENV -eq 1 ]]; then
else else
# Fall back to system python # Fall back to system python
function pyenv_prompt_info() { function pyenv_prompt_info() {
local version="$(python -V 2>&1 | cut -d' ' -f2)" local version="$(python3 -V 2>&1 | cut -d' ' -f2)"
echo "system: ${version:gs/%/%%}" echo "system: ${version:gs/%/%%}"
} }
fi fi

View file

@ -12,7 +12,7 @@ plugins=(... python)
| Command | Description | | Command | Description |
| ---------------- | -------------------------------------------------------------------------------------- | | ---------------- | -------------------------------------------------------------------------------------- |
| `py` | Runs `python` | | `py` | Runs `python3` |
| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv | | `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv |
| `pyfind` | Finds .py files recursively in the current directory | | `pyfind` | Finds .py files recursively in the current directory |
| `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one | | `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one |

View file

@ -1,5 +1,5 @@
# python command # python command
alias py='python' alias py='python3'
# Find python file # Find python file
alias pyfind='find . -name "*.py"' alias pyfind='find . -name "*.py"'
@ -44,10 +44,10 @@ function pyuserpaths() {
alias pygrep='grep -nr --include="*.py"' alias pygrep='grep -nr --include="*.py"'
# Run proper IPython regarding current virtualenv (if any) # Run proper IPython regarding current virtualenv (if any)
alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'" alias ipython="python3 -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
# Share local directory as a HTTP server # Share local directory as a HTTP server
alias pyserver="python -m http.server" alias pyserver="python3 -m http.server"
## venv utilities ## venv utilities