tmux, bash, mgmt fiddling
This commit is contained in:
parent
6649cfc78d
commit
c653422734
11 changed files with 160 additions and 11 deletions
|
|
@ -16,3 +16,12 @@ README.md
|
||||||
{{- if eq .chezmoi.osRelease.id "arch" | not }}
|
{{- if eq .chezmoi.osRelease.id "arch" | not }}
|
||||||
bin/quickaur
|
bin/quickaur
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if eq .chezmoi.osRelease.id "ubuntu" | not }}
|
||||||
|
.config/mgmt/mod/unmanaged_packages.bash
|
||||||
|
.config/mgmt/fns/bin_from.bash
|
||||||
|
.config/mgmt/fns/current.bash
|
||||||
|
.config/mgmt/fns/github_latest.bash
|
||||||
|
.config/mgmt/fns/install_bin.bash
|
||||||
|
.config/mgmt/fns/is_latest.bash
|
||||||
|
{{- end }}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ positional=(); parse_args "$@"
|
||||||
if [ -d "$mgmt_dir/fns" ]; then
|
if [ -d "$mgmt_dir/fns" ]; then
|
||||||
while IFS= read -rd '' fnfile; do
|
while IFS= read -rd '' fnfile; do
|
||||||
source "$fnfile"
|
source "$fnfile"
|
||||||
done < <(find "$functions" -type f -print0)
|
done < <(find "$mgmt_dir/fns" -type f -print0)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PREFIX=""
|
PREFIX=""
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@ if [[ "$PATH" != *"$HOME/bin"* ]]; then
|
||||||
PATH=$PATH:"$HOME/bin"
|
PATH=$PATH:"$HOME/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bind 'set mark-symlinked-directories on'
|
|
||||||
|
|
||||||
export EDITOR='/usr/bin/env nvim'
|
export EDITOR='/usr/bin/env nvim'
|
||||||
export VISUAL='/usr/bin/env nvim'
|
export VISUAL='/usr/bin/env nvim'
|
||||||
|
|
||||||
|
|
|
||||||
35
private_dot_config/private_mgmt/fns/bin_from.bash
Normal file
35
private_dot_config/private_mgmt/fns/bin_from.bash
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
bin_from() {
|
||||||
|
name="$1"
|
||||||
|
url="$2"
|
||||||
|
flag="$3"
|
||||||
|
|
||||||
|
if [[ -z "$name" || -z "$url" ]]; then
|
||||||
|
diag "$(red "error: missing name ($name) or url ($url)!")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$url" == *.tar.gz || "$url" == *.tgz ]]; then
|
||||||
|
dir=$(mktemp -d)
|
||||||
|
if curl -sSL "$url" | tar -C "$dir" -xz 2>&1 | grep -q 'not in gzip format'; then
|
||||||
|
diag "$(red "error: file from $url not in gzip format")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
file=$(find "$dir" -type f -name "$name")
|
||||||
|
elif [[ "$url" == *.tar.xz ]]; then
|
||||||
|
dir=$(mktemp -d)
|
||||||
|
curl -sSL "$url" | tar -C "$dir" -xJ
|
||||||
|
file=$(find "$dir" -type f -name "$name")
|
||||||
|
elif [[ "$url" == *.zip ]]; then
|
||||||
|
zip=$(mktemp --suffix=.zip)
|
||||||
|
dir=$(mktemp -d)
|
||||||
|
curl -sSL "$url" > "$zip"
|
||||||
|
unzip -qq "$zip" -d "$dir"
|
||||||
|
file=$(find "$dir" -type f -name "$name")
|
||||||
|
else
|
||||||
|
file="$(mktemp)"
|
||||||
|
curl -sSLo "$file" "$url" || diag "$(red "error from url [$url]")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_bin "$name" "$file" "$url" "$flag"
|
||||||
|
}
|
||||||
40
private_dot_config/private_mgmt/fns/current.bash
Normal file
40
private_dot_config/private_mgmt/fns/current.bash
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
#================================================================
|
||||||
|
#% SYNOPSIS
|
||||||
|
#+ current <cmd> [-f <flag>] [-r <regex>]
|
||||||
|
#%
|
||||||
|
#% OPTIONS
|
||||||
|
#% -f set command-line args to pass to <cmd>; single string.
|
||||||
|
#% Default: [--version]
|
||||||
|
#% -r set regex used to extract version string from cmd output
|
||||||
|
#% Default: [v?(\d+\.\d+\.\d+)]
|
||||||
|
#================================================================
|
||||||
|
current() {
|
||||||
|
flag="--version"
|
||||||
|
regex='v?(\d+\.\d+\.\d+)'
|
||||||
|
declare -a args
|
||||||
|
OPTIND=1
|
||||||
|
while [ $OPTIND -le "$#" ]; do
|
||||||
|
if getopts :f:r: opt; then
|
||||||
|
case "$opt" in
|
||||||
|
\?)
|
||||||
|
diag "$(red "error: called 'current' badly")"
|
||||||
|
;;
|
||||||
|
f) flag="$OPTARG" ;;
|
||||||
|
r) regex="$OPTARG" ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
args+=("${!OPTIND}")
|
||||||
|
(( OPTIND++ ))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
set -- "${args[@]}"
|
||||||
|
|
||||||
|
cmd="$1"
|
||||||
|
|
||||||
|
if command -v "$cmd" >/dev/null; then
|
||||||
|
bash -c "$cmd $flag" | perl -ne 'm/'"$regex"'/ && print "$1\n"' || true
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
}
|
||||||
18
private_dot_config/private_mgmt/fns/github_latest.bash
Normal file
18
private_dot_config/private_mgmt/fns/github_latest.bash
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
github_latest() {
|
||||||
|
repo="$1"
|
||||||
|
tag="${2:-latest}"
|
||||||
|
if [ "$tag" = "--no-latest-tag" ]; then
|
||||||
|
curl -sfSL "https://github.com/$repo/tags" \
|
||||||
|
| perl -ne 'm,a href="/'"$repo"'/releases/tag/v(\d\.\d(?:.\d)?)", && print "$1\n"' \
|
||||||
|
| sort -V \
|
||||||
|
| tail -n1 || echo "[github error]"
|
||||||
|
else
|
||||||
|
curl -sfSI "https://github.com/$repo/releases/$tag" \
|
||||||
|
| grep '^location' \
|
||||||
|
| awk -F/ '{print $NF}' \
|
||||||
|
| sed 's/\s\+$//' || echo "[github error]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
17
private_dot_config/private_mgmt/fns/install_bin.bash
Normal file
17
private_dot_config/private_mgmt/fns/install_bin.bash
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
install_bin() {
|
||||||
|
name="$1"
|
||||||
|
file="$2"
|
||||||
|
source="$3"
|
||||||
|
flag="$4"
|
||||||
|
|
||||||
|
if file "$file" | grep -Eqv 'ELF|executable'; then
|
||||||
|
diag "$(red "error: file from $source not an executable")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$flag" != "--no-backup" ] && [ -f "/usr/local/bin/$name" ]; then
|
||||||
|
sudo cp "/usr/local/bin/$name" "/usr/local/bin/$name.old"
|
||||||
|
fi
|
||||||
|
sudo install -m 755 "$file" "/usr/local/bin/$name"
|
||||||
|
}
|
||||||
17
private_dot_config/private_mgmt/fns/is_latest.bash
Normal file
17
private_dot_config/private_mgmt/fns/is_latest.bash
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
is_latest() {
|
||||||
|
exe="$1"
|
||||||
|
latest="$2"
|
||||||
|
installed="$3"
|
||||||
|
silent="$4"
|
||||||
|
if ! command -v "$exe" > /dev/null; then
|
||||||
|
diag "$exe not installed; $latest available"
|
||||||
|
return 1
|
||||||
|
elif [ "$latest" = "$installed" ]; then
|
||||||
|
test "$silent" = "silent" || diag "$exe already up to date"
|
||||||
|
elif [ "$latest" = "" ]; then
|
||||||
|
diag "[warn] 'latest' $exe is empty string"
|
||||||
|
else
|
||||||
|
diag "$exe $installed installed, but $latest available"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
export DEPENDS=( mod/packages.bash )
|
||||||
|
|
||||||
|
_i_fzf() {
|
||||||
|
latest=$(github_latest junegunn/fzf)
|
||||||
|
diag "latest fzf $latest"
|
||||||
|
if ! is_latest fzf "$latest" $(current fzf); then
|
||||||
|
bin_from fzf "https://github.com/junegunn/fzf/releases/download/${latest}/fzf-${latest#v}-linux_amd64.tar.gz"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
apply() {
|
||||||
|
for fn in $(declare -F | awk '$3 ~ /^_i_/ { print $3 }'); do
|
||||||
|
$fn
|
||||||
|
done
|
||||||
|
|
||||||
|
diag "all manual packages up to date"
|
||||||
|
}
|
||||||
|
|
@ -7,5 +7,5 @@ mosh
|
||||||
nvim; termux:neovim arch:neovim ubuntu:
|
nvim; termux:neovim arch:neovim ubuntu:
|
||||||
rg; termux:ripgrep
|
rg; termux:ripgrep
|
||||||
sqlite3; termux:sqlite
|
sqlite3; termux:sqlite
|
||||||
tailscale; termux:
|
tailscale; termux: ubuntu:
|
||||||
tmux
|
tmux
|
||||||
|
|
|
||||||
|
|
@ -28,19 +28,17 @@ set -g status on
|
||||||
set -g status-style bg=colour235,fg=brightblack
|
set -g status-style bg=colour235,fg=brightblack
|
||||||
set -g status-left-length 50
|
set -g status-left-length 50
|
||||||
set -g status-right-length 50
|
set -g status-right-length 50
|
||||||
|
set -g status-justify centre
|
||||||
|
|
||||||
|
set -g status-left "#[fg=colour32] [#S] p#D ⧽ "
|
||||||
{{- if has "phone" .class }}
|
{{- if has "phone" .class }}
|
||||||
set -g status-position top
|
set -g status-position top
|
||||||
set -g status-justify left
|
set -g status-interval 60
|
||||||
set -g status-interval 15
|
set -g status-right "#[fg=colour136]⧼ %m-%d"
|
||||||
set -g status-left "#[fg=blue,bold]#S#[fg=brightblack,bg=colour235] ⧽ "
|
|
||||||
set -g status-right "#[fg=brightblack,bg=colour235]⧼ %Y-%m-%d"
|
|
||||||
{{- else }}
|
{{- else }}
|
||||||
set -g status-position bottom
|
set -g status-position bottom
|
||||||
set -g status-justify centre
|
|
||||||
set -g status-interval 1
|
set -g status-interval 1
|
||||||
set -g status-left "#[fg=colour33,bg=colour235] #h ⧽ "
|
set -g status-right "#[fg=colour136]⧼ %a ⧼ %H:%M:%S ⧼ %Y-%m-%d "
|
||||||
set -g status-right "#[bg=colour235,fg=colour136] ⧼ %a ⧼ %H:%M:%S ⧼ %Y-%m-%d "
|
|
||||||
|
|
||||||
set -g default-command fish
|
set -g default-command fish
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue