diff --git a/nvim/.config/nvim/init.vim b/nvim/.config/nvim/init.vim index f120a0c..f273bfb 100644 --- a/nvim/.config/nvim/init.vim +++ b/nvim/.config/nvim/init.vim @@ -41,7 +41,7 @@ iab idate =strftime("%Y-%m-%d") nmap toc .put =execute('.,$write !gh-md-toc --hide-header --hide-footer') " use \ tf to format a buffer as terraform -nmap tf !terraform fmt % +nmap tf !tofu fmt -no-color % set lazyredraw " redraw only when req'd set wildmenu " visual auto-complete diff --git a/zsh/.local/share/zsh/functions/aws-ec2-instances b/zsh/.local/share/zsh/functions/aws-ec2-instances new file mode 100644 index 0000000..3748cd2 --- /dev/null +++ b/zsh/.local/share/zsh/functions/aws-ec2-instances @@ -0,0 +1,6 @@ +aws-ec2-instances() { + aws ec2 describe-instances --output json \ + | jq -r '.Reservations[].Instances[] | + [.InstanceId, .State.Name, .PrivateIpAddress, (.PublicIpAddress // "N/A")] | + @tsv' +} diff --git a/zsh/.local/share/zsh/functions/aws-publish-ssh-key b/zsh/.local/share/zsh/functions/aws-publish-ssh-key new file mode 100644 index 0000000..2120467 --- /dev/null +++ b/zsh/.local/share/zsh/functions/aws-publish-ssh-key @@ -0,0 +1,10 @@ +aws-publish-ssh-key() { + local key_name="${1:-jswank-$(hostname)}" + local key_file="${2:-$HOME/.ssh/id_ed25519.pub}" + + [[ -f "$key_file" ]] || { echo "Key file not found: $key_file" >&2; return 1; } + + aws ec2 import-key-pair \ + --key-name "$key_name" \ + --public-key-material "fileb://$key_file" +} diff --git a/zsh/.local/share/zsh/functions/aws-set-prompt b/zsh/.local/share/zsh/functions/aws-set-prompt new file mode 100644 index 0000000..719369b --- /dev/null +++ b/zsh/.local/share/zsh/functions/aws-set-prompt @@ -0,0 +1,3 @@ +aws-set-prompt() { + export AWS_ENVIRONMENT=$(aws iam list-account-aliases | jq -r '.AccountAliases[0]') +} diff --git a/zsh/.zshrc b/zsh/.zshrc index ebff3bd..cc9e72f 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,5 +1,6 @@ alias ls='ls --color=auto' alias grep='grep --color' +alias vim='nvim' fpath+=~/.local/share/zsh/functions @@ -20,6 +21,9 @@ if [ "${TERM}" = "xterm" ]; then TERM=xterm-256color fi +# setup my personal functions +autoload -Uz ~/.local/share/zsh/functions/*(.:t) + # # Prompt setup # @@ -84,7 +88,7 @@ if [ -e $HOME/cfa-work/.zshrc ]; then . $HOME/cfa-work/.zshrc fi -for env in $HOME/.okta/.env $HOME/.aws/.env $HOME/.config/github/.env $HOME/.config/aichat/.env; do +for env in $HOME/.okta/.env $HOME/.config/aws/.env $HOME/.config/github/.env $HOME/.config/aichat/.env; do if [ -r $env ]; then export $(xargs < $env) fi @@ -102,6 +106,9 @@ if command -v aws_completer > /dev/null; then complete -C aws_completer aws fi +if command -v tofu > /dev/null; then + complete -o nospace -C $(command -v tofu) tofu +fi # Highlight the current autocomplete option zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" @@ -124,3 +131,5 @@ zstyle :compinstall filename '~/.zshrc' #zstyle :compinstall filename '~/.zshrc' #compinit + +complete -o nospace -C /home/cli/dotfiles/zsh/.local/bin/tofu tofu