bugfix/make-fish-3-3-compatible #3
@ -1,3 +1,4 @@
|
|||||||
function cdk -d "execute aws cdk" -w cdk
|
# Defined in - @ line 1
|
||||||
__nvm_run "cdk" $argv
|
function cdk --wraps='npx aws-cdk@1.x' --description 'alias cdk=npx aws-cdk@1.x'
|
||||||
|
npx aws-cdk@1.x $argv;
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,3 +1,113 @@
|
|||||||
|
# Colors
|
||||||
|
function orange
|
||||||
|
set_color -o ee5819
|
||||||
|
end
|
||||||
|
|
||||||
|
function yellow
|
||||||
|
set_color -o b58900
|
||||||
|
end
|
||||||
|
|
||||||
|
function red
|
||||||
|
set_color -o d30102
|
||||||
|
end
|
||||||
|
|
||||||
|
function cyan
|
||||||
|
set_color -o 2aa198
|
||||||
|
end
|
||||||
|
|
||||||
|
function white
|
||||||
|
set_color -o fdf6e3
|
||||||
|
end
|
||||||
|
|
||||||
|
function dim
|
||||||
|
set_color -o 4f4f4f
|
||||||
|
end
|
||||||
|
|
||||||
|
function off
|
||||||
|
set_color -o normal
|
||||||
|
end
|
||||||
|
|
||||||
|
# Git
|
||||||
|
function git::is_repo
|
||||||
|
test -d .git; or command git rev-parse --git-dir 2>/dev/null 2>/dev/null
|
||||||
|
# test 0 -eq 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function git::ahead -a ahead behind diverged none
|
||||||
|
not git::is_repo; and return
|
||||||
|
|
||||||
|
set -l commit_count (command git rev-list --count --left-right "@{upstream}...HEAD" 2>/dev/null)
|
||||||
|
|
||||||
|
switch "$commit_count"
|
||||||
|
case ""
|
||||||
|
# no upstream
|
||||||
|
case "0"\t"0"
|
||||||
|
test -n "$none"; and echo "$none"; or echo ""
|
||||||
|
case "*"\t"0"
|
||||||
|
test -n "$behind"; and echo "$behind"; or echo "-"
|
||||||
|
case "0"\t"*"
|
||||||
|
test -n "$ahead"; and echo "$ahead"; or echo "+"
|
||||||
|
case "*"
|
||||||
|
test -n "$diverged"; and echo "$diverged"; or echo "±"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function git::branch_name
|
||||||
|
git::is_repo; and begin
|
||||||
|
command git symbolic-ref --short HEAD 2>/dev/null;
|
||||||
|
or command git show-ref --head -s --abbrev | head -n1 2>/dev/null
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function git::is_dirty
|
||||||
|
git::is_repo; and not command git diff --no-ext-diff --quiet --exit-code
|
||||||
|
end
|
||||||
|
|
||||||
|
function git::is_staged
|
||||||
|
git::is_repo; and begin
|
||||||
|
not command git diff --cached --no-ext-diff --quiet --exit-code
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function git::is_stashed
|
||||||
|
git::is_repo; and begin
|
||||||
|
command git rev-parse --verify --quiet refs/stash >/dev/null
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function git::is_touched
|
||||||
|
git::is_repo; and begin
|
||||||
|
test -n (echo (command git status --porcelain))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function git::untracked
|
||||||
|
git::is_repo; and begin
|
||||||
|
command git ls-files --other --exclude-standard
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function fish_right_prompt
|
||||||
|
|
||||||
|
if test "$theme_complete_path" = "yes"
|
||||||
|
set cwd (prompt_pwd)
|
||||||
|
else
|
||||||
|
set cwd (basename (prompt_pwd))
|
||||||
|
|
||||||
|
if git::is_repo
|
||||||
|
set root_folder (command git rev-parse --show-toplevel 2>/dev/null)
|
||||||
|
set parent_root_folder (dirname $root_folder)
|
||||||
|
set cwd (echo $PWD | sed -e "s|$parent_root_folder/||")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Because of having a two line promt now we dont need right anymore so we dont print anything here atm
|
||||||
|
#printf (yellow)"("(off)$cwd(yellow)") "(off)
|
||||||
|
#printf (off)(date +%H(yellow):(off)%M(yellow):(off)%S)(off)"\n"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function fish_prompt
|
function fish_prompt
|
||||||
set -l symbol "λ "
|
set -l symbol "λ "
|
||||||
set -l code $status
|
set -l code $status
|
||||||
@ -12,7 +122,7 @@ function fish_prompt
|
|||||||
end
|
end
|
||||||
|
|
||||||
if git::is_repo
|
if git::is_repo
|
||||||
set -l branch (git::branch_name ^/dev/null)
|
set -l branch (git::branch_name 2>/dev/null)
|
||||||
set -l ref (git show-ref --head --abbrev | awk '{print substr($0,0,7)}' | sed -n 1p)
|
set -l ref (git show-ref --head --abbrev | awk '{print substr($0,0,7)}' | sed -n 1p)
|
||||||
|
|
||||||
printf '%s ' \U1F6E0
|
printf '%s ' \U1F6E0
|
||||||
@ -26,7 +136,7 @@ function fish_prompt
|
|||||||
printf (white)"*"(off)
|
printf (white)"*"(off)
|
||||||
end
|
end
|
||||||
|
|
||||||
if command git symbolic-ref HEAD > /dev/null ^/dev/null
|
if command git symbolic-ref HEAD > /dev/null 2>/dev/null
|
||||||
if git::is_staged
|
if git::is_staged
|
||||||
printf (cyan)"$branch"(off)
|
printf (cyan)"$branch"(off)
|
||||||
else
|
else
|
||||||
@ -37,8 +147,8 @@ function fish_prompt
|
|||||||
end
|
end
|
||||||
|
|
||||||
for remote in (git remote)
|
for remote in (git remote)
|
||||||
set -l behind_count (echo (command git rev-list $branch..$remote/$branch ^/dev/null | wc -l | tr -d " "))
|
set -l behind_count (echo (command git rev-list $branch..$remote/$branch 2>/dev/null | wc -l | tr -d " "))
|
||||||
set -l ahead_count (echo (command git rev-list $remote/$branch..$branch ^/dev/null | wc -l | tr -d " "))
|
set -l ahead_count (echo (command git rev-list $remote/$branch..$branch 2>/dev/null | wc -l | tr -d " "))
|
||||||
|
|
||||||
if test $ahead_count -ne 0; or test $behind_count -ne 0; and test (git remote | wc -l) -gt 1
|
if test $ahead_count -ne 0; or test $behind_count -ne 0; and test (git remote | wc -l) -gt 1
|
||||||
echo -n -s " "(orange)$remote(off)
|
echo -n -s " "(orange)$remote(off)
|
||||||
|
|||||||
@ -1,107 +0,0 @@
|
|||||||
# Colors
|
|
||||||
function orange
|
|
||||||
set_color -o ee5819
|
|
||||||
end
|
|
||||||
|
|
||||||
function yellow
|
|
||||||
set_color -o b58900
|
|
||||||
end
|
|
||||||
|
|
||||||
function red
|
|
||||||
set_color -o d30102
|
|
||||||
end
|
|
||||||
|
|
||||||
function cyan
|
|
||||||
set_color -o 2aa198
|
|
||||||
end
|
|
||||||
|
|
||||||
function white
|
|
||||||
set_color -o fdf6e3
|
|
||||||
end
|
|
||||||
|
|
||||||
function dim
|
|
||||||
set_color -o 4f4f4f
|
|
||||||
end
|
|
||||||
|
|
||||||
function off
|
|
||||||
set_color -o normal
|
|
||||||
end
|
|
||||||
|
|
||||||
# Git
|
|
||||||
function git::is_repo
|
|
||||||
test -d .git; or command git rev-parse --git-dir >/dev/null ^/dev/null
|
|
||||||
end
|
|
||||||
|
|
||||||
function git::ahead -a ahead behind diverged none
|
|
||||||
not git::is_repo; and return
|
|
||||||
|
|
||||||
set -l commit_count (command git rev-list --count --left-right "@{upstream}...HEAD" ^/dev/null)
|
|
||||||
|
|
||||||
switch "$commit_count"
|
|
||||||
case ""
|
|
||||||
# no upstream
|
|
||||||
case "0"\t"0"
|
|
||||||
test -n "$none"; and echo "$none"; or echo ""
|
|
||||||
case "*"\t"0"
|
|
||||||
test -n "$behind"; and echo "$behind"; or echo "-"
|
|
||||||
case "0"\t"*"
|
|
||||||
test -n "$ahead"; and echo "$ahead"; or echo "+"
|
|
||||||
case "*"
|
|
||||||
test -n "$diverged"; and echo "$diverged"; or echo "±"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function git::branch_name
|
|
||||||
git::is_repo; and begin
|
|
||||||
command git symbolic-ref --short HEAD ^/dev/null;
|
|
||||||
or command git show-ref --head -s --abbrev | head -n1 ^/dev/null
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function git::is_dirty
|
|
||||||
git::is_repo; and not command git diff --no-ext-diff --quiet --exit-code
|
|
||||||
end
|
|
||||||
|
|
||||||
function git::is_staged
|
|
||||||
git::is_repo; and begin
|
|
||||||
not command git diff --cached --no-ext-diff --quiet --exit-code
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function git::is_stashed
|
|
||||||
git::is_repo; and begin
|
|
||||||
command git rev-parse --verify --quiet refs/stash >/dev/null
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function git::is_touched
|
|
||||||
git::is_repo; and begin
|
|
||||||
test -n (echo (command git status --porcelain))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function git::untracked
|
|
||||||
git::is_repo; and begin
|
|
||||||
command git ls-files --other --exclude-standard
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function fish_right_prompt
|
|
||||||
|
|
||||||
if test "$theme_complete_path" = "yes"
|
|
||||||
set cwd (prompt_pwd)
|
|
||||||
else
|
|
||||||
set cwd (basename (prompt_pwd))
|
|
||||||
|
|
||||||
if git::is_repo
|
|
||||||
set root_folder (command git rev-parse --show-toplevel ^/dev/null)
|
|
||||||
set parent_root_folder (dirname $root_folder)
|
|
||||||
set cwd (echo $PWD | sed -e "s|$parent_root_folder/||")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Because of having a two line promt now we dont need right anymore so we dont print anything here atm
|
|
||||||
#printf (yellow)"("(off)$cwd(yellow)") "(off)
|
|
||||||
#printf (off)(date +%H(yellow):(off)%M(yellow):(off)%S)(off)"\n"
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|||||||
@ -5,6 +5,11 @@ function ssm_tunnel --description 'access private AWS ressources via Bastion Hos
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if [ "$env" != "ops" ]
|
||||||
|
echo "Switch to OPS ENV first"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
# Get bastion host ID using it's name
|
# Get bastion host ID using it's name
|
||||||
set INSTANCE_ID (aws ec2 describe-instances \
|
set INSTANCE_ID (aws ec2 describe-instances \
|
||||||
--filter 'Name=tag:Name,Values=ops-infrastructure-bastion'\
|
--filter 'Name=tag:Name,Values=ops-infrastructure-bastion'\
|
||||||
|
|||||||
@ -7,7 +7,7 @@ function t31m_prompt_right
|
|||||||
set cwd (basename (prompt_pwd))
|
set cwd (basename (prompt_pwd))
|
||||||
|
|
||||||
if git::is_repo
|
if git::is_repo
|
||||||
set root_folder (command git rev-parse --show-toplevel ^/dev/null)
|
set root_folder (command git rev-parse --show-toplevel 2>/dev/null)
|
||||||
set parent_root_folder (dirname $root_folder)
|
set parent_root_folder (dirname $root_folder)
|
||||||
set cwd (echo $PWD | sed -e "s|$parent_root_folder/||")
|
set cwd (echo $PWD | sed -e "s|$parent_root_folder/||")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user