File: pyenv-commands

package info (click to toggle)
pyenv 2.6.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,496 kB
  • sloc: sh: 4,914; python: 410; makefile: 161; ansic: 60
file content (43 lines) | stat: -rwxr-xr-x 812 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# Summary: List all available pyenv commands
# Usage: pyenv commands [--sh|--no-sh]

set -e
[ -n "$PYENV_DEBUG" ] && set -x

# Provide pyenv completions
if [ "$1" = "--complete" ]; then
  echo --sh
  echo --no-sh
  exit
fi

if [ "$1" = "--sh" ]; then
  sh=1
  shift
elif [ "$1" = "--no-sh" ]; then
  nosh=1
  shift
fi

IFS=: paths=($PATH)

shopt -s nullglob

{ for path in "${paths[@]}"; do
    for command in "${path}/pyenv-"*; do
      command="${command##*pyenv-}"
      if [ -n "$sh" ]; then
        if [ "${command:0:3}" = "sh-" ]; then
          echo "${command##sh-}"
        fi
      elif [ -n "$nosh" ]; then
        if [ "${command:0:3}" != "sh-" ]; then
          echo "${command##sh-}"
        fi
      else
        echo "${command##sh-}"
      fi
    done
  done
} | sort | uniq