From 0818df057cca59a949ffa88947a6b16dec2411ca Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Sat, 9 Apr 2022 14:45:42 +0200 Subject: [PATCH] fix: use `python3` for all `python` invocations (#10832) --- plugins/aliases/aliases.plugin.zsh | 4 ++-- plugins/aliases/cheatsheet.py | 2 +- plugins/git-prompt/README.md | 2 +- plugins/git-prompt/git-prompt.plugin.zsh | 2 +- plugins/git-prompt/gitstatus.py | 2 +- plugins/jsontools/jsontools.plugin.zsh | 12 ++++++------ plugins/pyenv/pyenv.plugin.zsh | 2 +- plugins/python/README.md | 2 +- plugins/python/python.plugin.zsh | 6 +++--- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/plugins/aliases/aliases.plugin.zsh b/plugins/aliases/aliases.plugin.zsh index b3d9340f0..4e1e0558e 100644 --- a/plugins/aliases/aliases.plugin.zsh +++ b/plugins/aliases/aliases.plugin.zsh @@ -3,9 +3,9 @@ # - acs: alias cheatsheet # group alias by command, pass addition argv to grep. function acs(){ - (( $+commands[python] )) || { + (( $+commands[python3] )) || { echo "[error] No python executable detected" return } - alias | python ${functions_source[$0]:h}/cheatsheet.py $@ + alias | python3 ${functions_source[$0]:h}/cheatsheet.py $@ } diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py index 694afd31c..a7e3968b0 100644 --- a/plugins/aliases/cheatsheet.py +++ b/plugins/aliases/cheatsheet.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import itertools import termcolor diff --git a/plugins/git-prompt/README.md b/plugins/git-prompt/README.md index 83d365c84..8775af893 100644 --- a/plugins/git-prompt/README.md +++ b/plugins/git-prompt/README.md @@ -13,7 +13,7 @@ See the [original repository](https://github.com/olivierverdier/zsh-git-prompt). ## 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 diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index c86c1f59b..0485e317c 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -36,7 +36,7 @@ function update_current_git_vars() { unset __CURRENT_GIT_STATUS 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}") GIT_BRANCH=$__CURRENT_GIT_STATUS[1] GIT_AHEAD=$__CURRENT_GIT_STATUS[2] diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index 4dea8000f..b5c3c9a0c 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import print_function import os diff --git a/plugins/jsontools/jsontools.plugin.zsh b/plugins/jsontools/jsontools.plugin.zsh index 857ca0ec9..49828d32d 100644 --- a/plugins/jsontools/jsontools.plugin.zsh +++ b/plugins/jsontools/jsontools.plugin.zsh @@ -8,7 +8,7 @@ fi # If method undefined, find the first one that is installed 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 (( $+commands[$JSONTOOLS_METHOD] )) && break # Otherwise unset the variable @@ -45,12 +45,12 @@ case "$JSONTOOLS_METHOD" in xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))" } ;; - python) + python3) 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() { - python -c ' + python3 -c ' import sys; del sys.path[0]; import json try: @@ -61,14 +61,14 @@ except ValueError: ' } function urlencode_json() { - python -c ' + python3 -c ' import sys; del sys.path[0]; from urllib.parse import quote_plus print(quote_plus(sys.stdin.read())) ' } function urldecode_json() { - python -c ' + python3 -c ' import sys; del sys.path[0]; from urllib.parse import unquote_plus print(unquote_plus(sys.stdin.read())) diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index ebb1a708a..7fbd1589e 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -89,7 +89,7 @@ if [[ $FOUND_PYENV -eq 1 ]]; then else # Fall back to system python 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/%/%%}" } fi diff --git a/plugins/python/README.md b/plugins/python/README.md index c1f0adef8..97c1a34ee 100644 --- a/plugins/python/README.md +++ b/plugins/python/README.md @@ -12,7 +12,7 @@ plugins=(... python) | Command | Description | | ---------------- | -------------------------------------------------------------------------------------- | -| `py` | Runs `python` | +| `py` | Runs `python3` | | `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv | | `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 | diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh index 7a73ab92a..2fbb59577 100644 --- a/plugins/python/python.plugin.zsh +++ b/plugins/python/python.plugin.zsh @@ -1,5 +1,5 @@ # python command -alias py='python' +alias py='python3' # Find python file alias pyfind='find . -name "*.py"' @@ -44,10 +44,10 @@ function pyuserpaths() { alias pygrep='grep -nr --include="*.py"' # 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 -alias pyserver="python -m http.server" +alias pyserver="python3 -m http.server" ## venv utilities