update: formatting, cleanup & order

This commit is contained in:
=
2020-03-07 19:22:06 +01:00
parent 06f373d5e9
commit e48b226951
4 changed files with 13 additions and 53 deletions

View File

@ -1,13 +1,5 @@
set -g CMD_DURATION 0
#function dim
# set_color -o 4f4f4f
#end
#function off
# set_color -o normal
#end
function fish_greeting
echo "Welcome to FiSH "(uname -nrs)
echo "Welcome to "(uname -n)
end

View File

@ -54,10 +54,11 @@ function fish_prompt
set t31m_custom (t31m_prompt)
# check if latest cmd resulted in exit code 0 (ok)
if test "$code" = 0
echo -n -s "$t31m_custom"(red)"$symbol"(off)
else
echo -n -s (dim)"$symbol"(off)
echo -n -s "$t31m_custom"(dim)"$symbol"(off)
end
end

View File

@ -86,29 +86,6 @@ function git::untracked
end
end
# Kubernetes
function k8s::current_context
command kubectl config current-context
end
function k8s::current_namespace
command kubectl config view --minify -o jsonpath='{.contexts[0].context.namespace}'
end
# Terraform
# Test whether this is a terraform directory by finding .tf files
function terraform::directory
command find . -name '*.tf' >/dev/null ^/dev/null -maxdepth 0
end
function terraform::workspace
terraform::directory; and begin
test -e .terraform/environment
end
end
function fish_right_prompt
if test "$theme_complete_path" = "yes"
@ -123,21 +100,7 @@ function fish_right_prompt
end
end
command -sq kubectl; and k8s::current_context >/dev/null 2>/dev/null; and begin
set -l k8s_namespace (k8s::current_namespace)
if test -z "$k8s_namespace"
printf (yellow)"("(dim)(k8s::current_context)(yellow)") "(off)
else
printf (yellow)"("(dim)(k8s::current_context)"/$k8s_namespace"(yellow)") "(off)
end
end
if terraform::workspace
set terraform_workspace_name (command cat .terraform/environment)
printf (yellow)"("(dim)$terraform_workspace_name(yellow)") "(off)
end
printf (yellow)"("(dim)$cwd(yellow)") "(off)
printf (dim)(date +%H(yellow):(dim)%M(yellow):(dim)%S)(off)
printf (yellow)"("(off)$cwd(yellow)") "(off)
printf (off)(date +%H(yellow):(off)%M(yellow):(off)%S)(off)
end

View File

@ -1,20 +1,24 @@
# by T31M
function prompt::awsenv
if test -n "$env"
echo -n -s "[aws=$env]"
if [ $env = "prod" ]
echo -n -s (yellow)"["(red)"$env"(yellow)"]"(off)
else
echo -n -s (yellow)"["(off)"$env"(yellow)"]"(off)
end
end
end
function prompt::pyenv
if test -n "$PYENV_VERSION"
echo -n -s "[$PYENV_VERSION]"
echo -n -s (yellow)"["(cyan)"$PYENV_VERSION"(yellow)"]"(off)
end
end
function t31m_prompt
set awsenv (prompt::awsenv)
set pyenv (prompt::pyenv)
echo -n -s (red)"$awsenv"(cyan)"$pyenv"
#echo -n -s (red)"$awsenv"(cyan)"$pyenv"
echo -n -s "$pyenv$awsenv"
end