Files
ubuntu-fish-dotfiles/fish/theme-t31m/t31m_prompt.fish
2020-06-07 16:58:08 +02:00

49 lines
1.8 KiB
Fish

function prompt::awsenv
if test -n "$env"
if [ $env = "prod" ]
printf '%s ' \U2601
echo -n -s (yellow)"["(red)(string upper $env)(yellow)"]"(off)
else
printf '%s ' \U2601
echo -n -s (yellow)"["(off)(string upper $env)(yellow)"]"(off)
end
end
end
function prompt::pyenv
if test (command -v python)
set python_version (python -c "import sys;t='{v[0]}.{v[1]}.{v[2]}'.format(v=list(sys.version_info[:3]));sys.stdout.write(t)")
else
set python_version ""
end
#if test -n "$python_version"
# echo -n -s (yellow)(printf '%s' \U1F40D)"["(off)"$python_version"(yellow)"]"(off)
# else if test (command -v pyenv)
if set -q VIRTUAL_ENV
set venv $VIRTUALENV | grep -Eo '[^/]+/?$' | cut -d / -f1
echo -n -s (yellow)(printf '%s' \U1F40D)"[($venv"(cyan)(pyenv version-name | sed 's/:.*$//')(yellow)")"(off)"@$python_version"(yellow)"]"(off)
else if test -n "$PYENV_VERSION"; and [ "$PYENV_VERSION" != "$python_version" ]
# echo -n -s (yellow)(printf '%s' \U1F40D)"["(cyan)(pyenv version-name | sed 's/:.*$//' )(off)"@$python_version"(yellow)"]"(off)
echo -n -s (yellow)(printf '%s' \U1F40D)"["(cyan)(pyenv version-name )(off)"@$python_version"(yellow)"]"(off)
else if test -n "$python_version"
echo -n -s (yellow)(printf '%s' \U1F40D)"["(off)$python_version(yellow)"]"(off)
end
end
function t31m_prompt
set awsenv (prompt::awsenv)
set pyenv (prompt::pyenv)
echo -n -s "$pyenv"
echo -n -s "$awsenv"
if test $CMD_DURATION
# Show duration of the last command in seconds
set duration (echo "$CMD_DURATION 1000" | awk '{printf "%.2fs", $1 / $2}')
printf '%s ' \U23F1
echo -n -s (yellow)"["(off)$duration(yellow)"]"(off)
end
end