dotfiles/.config/fish/config.fish
2026-01-05 15:00:16 -03:00

88 lines
2.1 KiB
Fish

function set_aliases
set -U fish_greeting
alias d=docker
alias dc=docker-compose
alias dd='dd status=progress'
alias g=git
alias k=kubectl
alias tf=terraform
alias tfw='terraform workspace'
alias tree='tree --filesfirst'
alias ts='sudo tailscale'
alias up='source ~/.config/fish/config.fish'
alias v='nvim -S Session.vim'
alias c='cd (git rev-parse --show-toplevel)'
function ghostty-terminfo
if test (count $argv) -ne 1
echo "Usage: ghostty-terminfo user@host"
return 1
end
infocmp -x xterm-ghostty | ssh $argv -- tic -x -
end
function tfp
# add -parallelism=2 to terraform commands
set -l cmd $argv[1]
set -l rest $argv[2..-1]
terraform $cmd -parallelism=2 $rest
end
function kocc
kubectl exec -n nextcloud --stdin --tty nextcloud-sts-0 -c app -- su -s /bin/sh www-data -c "php occ $argv"
end
end
function fish_prompt -d "Write out the prompt"
set -l _display_status $status
# if $status is not 0, print it in red
if test $_display_status -ne 0
set_color red
printf '%s' $_display_status
set_color normal
end
# Print git root
set -l git_root (git rev-parse --show-toplevel 2>/dev/null)
if test -n "$git_root"
set_color blue
printf '%s' (basename $git_root)
set_color normal
end
# printf '%s' (prompt_pwd)
# Print the directory underneath the git root
if test -n "$git_root"
printf '%s' (string replace -r "^$git_root" "" $PWD)
else
printf '%s' (prompt_pwd)
end
# Append the workspace name at the current prompt position if
# the directory contains a .terraform subdirectory
if test -d .terraform
set workspace (terraform workspace show ^/dev/null)
set_color green
printf "-%s" $workspace
set_color normal
end
printf '$ ' (prompt_pwd)
end
if status is-login
source ~/.profile
else if status is-interactive
set -U fish_greeting
set_aliases
end
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/home/jack/Documents/google-cloud-sdk/path.fish.inc' ]; . '/home/jack/Documents/google-cloud-sdk/path.fish.inc'; end
source ~/.safe-chain/scripts/init-fish.fish # Safe-chain Fish initialization script
# opencode
fish_add_path /home/jack/.opencode/bin