Merge branch 'main' of ssh://git.scalene.net:22023/jswank/dotfiles

This commit is contained in:
Jason Swank
2025-10-20 02:24:31 +00:00
20 changed files with 2644 additions and 15 deletions

View File

@@ -0,0 +1 @@
_task

View File

@@ -0,0 +1,71 @@
#compdef task
compdef _task task
typeset -A opt_args
_GO_TASK_COMPLETION_LIST_OPTION="${GO_TASK_COMPLETION_LIST_OPTION:---list-all}"
# Listing commands from Taskfile.yml
function __task_list() {
local -a scripts cmd
local -i enabled=0
local taskfile item task desc
cmd=(task)
taskfile=${(Qv)opt_args[(i)-t|--taskfile]}
taskfile=${taskfile//\~/$HOME}
if [[ -n "$taskfile" && -f "$taskfile" ]]; then
enabled=1
cmd+=(--taskfile "$taskfile")
else
for taskfile in {T,t}askfile{,.dist}.{yaml,yml}; do
if [[ -f "$taskfile" ]]; then
enabled=1
break
fi
done
fi
(( enabled )) || return 0
scripts=()
for item in "${(@)${(f)$("${cmd[@]}" $_GO_TASK_COMPLETION_LIST_OPTION)}[2,-1]#\* }"; do
task="${item%%:[[:space:]]*}"
desc="${item##[^[:space:]]##[[:space:]]##}"
scripts+=( "${task//:/\\:}:$desc" )
done
_describe 'Task to run' scripts
}
_task() {
_arguments \
'(-C --concurrency)'{-C,--concurrency}'[limit number of concurrent tasks]: ' \
'(-p --parallel)'{-p,--parallel}'[run command-line tasks in parallel]' \
'(-f --force)'{-f,--force}'[run even if task is up-to-date]' \
'(-c --color)'{-c,--color}'[colored output]' \
'(-d --dir)'{-d,--dir}'[dir to run in]:execution dir:_dirs' \
'(--dry)--dry[dry-run mode, compile and print tasks only]' \
'(-o --output)'{-o,--output}'[set output style]:style:(interleaved group prefixed)' \
'(--output-group-begin)--output-group-begin[message template before grouped output]:template text: ' \
'(--output-group-end)--output-group-end[message template after grouped output]:template text: ' \
'(-s --silent)'{-s,--silent}'[disable echoing]' \
'(--status)--status[exit non-zero if supplied tasks not up-to-date]' \
'(--summary)--summary[show summary\: field from tasks instead of running them]' \
'(-t --taskfile)'{-t,--taskfile}'[specify a different taskfile]:taskfile:_files' \
'(-v --verbose)'{-v,--verbose}'[verbose mode]' \
'(-w --watch)'{-w,--watch}'[watch-mode for given tasks, re-run when inputs change]' \
+ '(operation)' \
{-l,--list}'[list describable tasks]' \
{-a,--list-all}'[list all tasks]' \
{-i,--init}'[create new Taskfile.yml]' \
'(-*)'{-h,--help}'[show help]' \
'(-*)--version[show version and exit]' \
'*: :__task_list'
}
# don't run the completion function when being source-ed or eval-ed
if [ "$funcstack[1]" = "_task" ]; then
_task "$@"
fi

View File

@@ -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'
}

View File

@@ -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"
}

View File

@@ -0,0 +1,3 @@
aws-set-prompt() {
export AWS_ENVIRONMENT=$(aws iam list-account-aliases | jq -r '.AccountAliases[0]')
}

View File

@@ -1,8 +1,8 @@
alias ls='ls --color=auto'
alias grep='grep --color'
alias vim='nvim'
alias vi='nvim'
alias w3='w3m -T text/html'
fpath+=~/.local/share/zsh/functions
path+=(~/bin)
path+=(~/.local/bin)
@@ -12,8 +12,6 @@ export PATH
# allow for # to be interpreted as a comment on the command line
setopt interactivecomments
# cd tricks
alias -- -='cd -'
setopt auto_cd # there is no binary by that name in your $PATH, your shell will cd into it that directory
# use vi-style keymap
@@ -23,6 +21,9 @@ if [ "${TERM}" = "xterm" ]; then
TERM=xterm-256color
fi
# setup my personal functions
autoload -Uz ~/.local/share/zsh/functions/*(.:t)
#
# Prompt setup
#
@@ -87,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/git/.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
@@ -105,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}"
@@ -127,3 +131,5 @@ zstyle :compinstall filename '~/.zshrc'
#zstyle :compinstall filename '~/.zshrc'
#compinit
complete -o nospace -C /home/cli/dotfiles/zsh/.local/bin/tofu tofu