starship is dead long live powerlevel10k

This commit is contained in:
Daylin Morgan 2023-11-07 18:38:24 -06:00
parent f20b2b8de7
commit 06eb1a51fe
Signed by: daylin
GPG key ID: C1E52E7DD81DF79F
8 changed files with 3449 additions and 245 deletions

View file

@ -1,234 +0,0 @@
#!/usr/bin/env bash
#colors
# remove tput just use ansi
MAGENTA="\033[35m"
CYAN="\033[34m"
YELLOW="\033[33m"
RED="\033[31m"
GREEN="\033[32m"
NORMAL="\033[0m"
BIN_DIR=$HOME/bin
YAMLDOC="$DOTFILES_DIR/info/tools.yml"
INSTALL_YES=${GREEN}✓${NORMAL}
INSTALL_NO=${RED}✗${NORMAL}
# get current binary files
shopt -s nullglob
BINARY_FILES="($HOME/bin/*)"
export EGET_BIN=$HOME/bin
alias eget="eget --system linux/amd64"
post_download_install() {
tool=$1
temp_file=$(mktemp -p . "${tool}.XXX.sh")
key=$tool yq e 'explode(.) | .[env(key)].post-download' "$YAMLDOC" >"$temp_file"
bash "$temp_file"
rm "$temp_file"
}
eget_tool() {
tool=$1
echo -n "$tool"
user=$(key=$tool yq e 'explode(.) | .[env(key)].user' $YAMLDOC)
asset=$(key=$tool yq e 'explode(.) | .[env(key)].asset // ""' $YAMLDOC)
file=$(key=$tool yq e 'explode(.) | .[env(key)].file // ""' $YAMLDOC)
to=$(key=$tool yq e 'explode(.) | .[env(key)].to // ""' $YAMLDOC)
download_only=$(key=$tool yq e 'explode(.) | .[env(key)].download-only // ""' $YAMLDOC)
custom_flags=$(key=$tool yq e 'explode(.) | .[env(key)].custom_flags // ""' $YAMLDOC)
eget $user/$tool \
${asset:+--asset $asset} \
${file:+--file $file} \
${to:+--to $to} \
${download_only:+--download-only} \
${custom_flags} \
-q
if [[ $download_only ]]; then
echo -n ' --> '
echo -n 'running post-download script'
post_download_install $tool
fi
echo
}
deps_check() {
mkdir -p $BIN_DIR
if ! $(is-executable eget); then
echo "I don't see eget on your path..."
read -p "Do you want to download it to ${BIN_DIR}? " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
else
curl https://zyedidia.github.io/eget.sh | sh
mv eget --upgrade-only $BIN_DIR/eget
fi
fi
if ! $(is-executable yq); then
eget mikefarah/yq --asset yq_linux_amd64
fi
}
get_days() {
install_date=$1
date_out=$(date -d @$1 +'%Y.%m.%d %R')
now=$(date +'%s')
days=$(((now - install_date) / 86400))
if ((days > 60)); then
echo -e "${RED}$date_out${NORMAL}"
elif ((days > 30)); then
echo -e "${YELLOW}$date_out${NORMAL}"
else
echo "$date_out"
fi
}
check_install() {
bin_name=$BIN_DIR/$1
if printf '%s\n' "${BINARY_FILES[@]}" | grep -Fxq "$bin_name"; then
modified=$(date -r $bin_name +'%s')
echo $(get_days $modified)
fi
}
list() {
deps_check
user_len=$(yq e '.[] | .user ' $YAMLDOC | tail -n +2 | sort | uniq | awk '{print length}' | sort -nr | head -n 1)
tool_len=$(yq e 'keys| .[]' $YAMLDOC | tail -n +2 | sort | uniq | awk '{print length}' | sort -nr | head -n 1)
table_width=$((user_len + tool_len + 25))
tool_cell=$(printf "%${tool_len}s" "")
user_cell=$(printf "%${user_len}s" "")
echo -e "${CYAN}CONFIGURED TOOLS${NORMAL}"
printf "%${table_width}s\n" "" | tr ' ' =
printf \
"${CYAN}tool${NORMAL}%s | \
${CYAN}author${NORMAL}%s | \
${CYAN} install date${NORMAL}\n" \
"${tool_cell:4}" "${user_cell:6}"
printf "%${table_width}s\n" "" | tr ' ' -
readarray tools < <(yq e 'keys | .[]' $YAMLDOC)
#sort tools for readability
tools=($(echo "${tools[@]:1}" | tr ' ' '\n' | sort | uniq))
for tool in "${tools[@]}"; do
user=$(key=$tool yq e 'explode(.) | .[env(key)].user' $YAMLDOC)
bin_name=$(key=$tool yq e 'explode(.) | .[env(key)].to' $YAMLDOC)
[[ $bin_name == "null" ]] && bin_name=$tool
modified=$(check_install $bin_name)
! [[ -z $modified ]] && installed=$INSTALL_YES || installed=$INSTALL_NO
printf \
"${MAGENTA}%s${NORMAL}%s | \
${YELLOW}%s${NORMAL}%s | \
$installed $modified\n" \
$tool "${tool_cell:${#tool}}" \
$user "${user_cell:${#user}}"
done
}
download() {
if ! [ -z "$1" ]; then
tool=$1
echo "installing $tool"
info=$(key=$tool yq e 'explode(.) | .[env(key)]' $YAMLDOC)
if [[ $info == "null" ]]; then
echo "$tool not found in $YAMLDOC"
echo "exiting"
exit 1
else
eget_tool $tool
fi
fi
}
download_all() {
echo -e "Downloading binaries to ${GREEN}$BIN_DIR${NORMAL}"
deps_check
readarray tools < <(yq e 'keys | .[]' $YAMLDOC)
echo "installing......"
for tool in "${tools[@]:1}"; do
eget_tool $tool
done
}
help() {
cat <<EOF
eget/yq powered binary downloader
usage: tools [tool tool2 ...]
optional flags:
-h, --help show this help text
-l, --list list all tools
-a, --all download all tools
EOF
}
for opt in "$@"; do
case $opt in
-h | --help)
help
exit 0
;;
-l | --list)
list
exit 0
;;
-a | --all)
download_all
exit 0
;;
-* | --*)
echo "Invalid option: $opt"
help
exit 1
;;
*)
args+=("$opt")
shift
;;
esac
done
# if no args, show help
if [ -z "$args" ]; then
echo -e "${RED}No arguments supplied${NORMAL}"
help
exit 0
else
echo -e "Downloading binaries to ${GREEN}$BIN_DIR${NORMAL}"
deps_check
for tool in "${args[@]}"; do
download "$tool"
done
fi

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -17,6 +17,7 @@ Aloxaf/fzf-tab kind:defer
junegunn/fzf path:shell/completion.zsh junegunn/fzf path:shell/completion.zsh
junegunn/fzf path:shell/key-bindings.zsh junegunn/fzf path:shell/key-bindings.zsh
romkatv/powerlevel10k
# Source everything in $ZDOTDIR/rc.d prior to wrapping up. # Source everything in $ZDOTDIR/rc.d prior to wrapping up.
mattmc3/zshrc.d mattmc3/zshrc.d
~/.config/zsh/plugins/zexists ~/.config/zsh/plugins/zexists

View file

@ -1,3 +1,10 @@
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
#!/usr/bin/env zsh #!/usr/bin/env zsh
# Load zprof first if we need to profile. # Load zprof first if we need to profile.
@ -37,3 +44,8 @@ fi
# Source your static plugins file. # Source your static plugins file.
source $zsh_plugins source $zsh_plugins
if zmodload zsh/terminfo && (( terminfo[colors] >= 256 )); then
[[ ! -f $ZDOTDIR/.p10k.zsh ]] || source $ZDOTDIR/.p10k.zsh
else
[[ ! -f $ZDOTDIR/.p10k-ascii.zsh ]] || source $ZDOTDIR/.p10k-ascii.zsh
fi

View file

@ -1,11 +0,0 @@
echo "no starship = dumber prompt"
autoload -Uz vcs_info
precmd() {
vcs_info
}
zstyle ':vcs_info:git:*' formats '%b '
setopt PROMPT_SUBST
PROMPT='%F{green}%*%f %F{blue}%~%f %F{red}${vcs_info_msg_0_}%f$ '

View file

@ -0,0 +1,4 @@
unalias x # set by extract plugin
source <(pkgx --shellcode) #docs.pkgx.sh/shellcode