Compare commits

...

2 Commits

Author SHA1 Message Date
Andrew Coleman 2ea9a291c4 auto-shellcheck and shfmt at the script end 2023-07-28 08:32:14 -04:00
Andrew Coleman a57c555a3d new bins and formatted 2023-07-28 08:28:53 -04:00
1 changed files with 46 additions and 27 deletions

View File

@ -1,24 +1,24 @@
#!/bin/sh
[ ! -z "${DEBUG-}" ] && set -x
[ -n "${DEBUG-}" ] && set -x
cd "$(dirname $0)" || exit 1
cd "$(dirname "$0")" || exit 1
if ! pgrep nix-daemon >/dev/null 2>&1; then
sh < $(curl -L https://nixos.org/nix/install)
sh <"$(curl -L https://nixos.org/nix/install)"
fi
mkdir -p "$HOME/.config"
mkdir -p "$HOME/.config/nix"
if [ ! -f "$HOME/.config/nix/nix.conf" ]; then
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
echo "experimental-features = nix-command flakes" >>"$HOME/.config/nix/nix.conf"
echo "trusted-users = root andrew" | sudo tee -a /etc/nix/nix.conf && sudo pkill nix-daemon
cachix use devenv
nix profile install --accept-flake-config github:cachix/devenv/latest
fi
function has_bin() {
has_bin() {
[ -e "$HOME/.nix-profile/bin/$1" ]
}
@ -67,7 +67,9 @@ has_bin "llama" || nix profile install nixpkgs#llama
has_bin "mdbook" || nix profile install nixpkgs#mdbook
has_bin "mosh" || nix profile install nixpkgs#mosh
has_bin "nix-bisect" || nix profile install nixpkgs#nix-bisect
has_bin "nix-doc" || nix profile install nixpkgs#nix-doc
# fails for some odd reason at the moment
#has_bin "nix-doc" || nix profile install nixpkgs#nix-doc
command -v "nix-doc" >/dev/null || cargo install nix-doc
has_bin "nix-init" || nix profile install nixpkgs#nix-init
has_bin "nix-search" || nix profile install github:peterldowns/nix-search-cli --refresh
has_bin "nurl" || nix profile install nixpkgs#nurl
@ -81,6 +83,7 @@ has_bin "rustfilt" || nix profile install nixpkgs#rustfilt
has_bin "sd" || nix profile install nixpkgs#sd
has_bin "shellcheck" || nix profile install nixpkgs#shellcheck
has_bin "shfmt" || nix profile install nixpkgs#shfmt
has_bin "spacer" || nix profile install nixpkgs#spacer
has_bin "starship" || nix profile install nixpkgs#starship
has_bin "terminal-notifier" || nix profile install nixpkgs#terminal-notifier
has_bin "tig" || nix profile install nixpkgs#tig
@ -92,19 +95,30 @@ has_bin "watchexec" || nix profile install nixpkgs#watchexec
has_bin "xcp" || nix profile install nixpkgs#xcp
has_bin "xh" || nix profile install nixpkgs#xh
has_bin "xsv" || nix profile install nixpkgs#xsv
has_bin "zenith" || nix profile install nixpkgs#zenith
has_bin "zola" || nix profile install nixpkgs#zola
has_bin "zoxide" || nix profile install nixpkgs#zoxide
PATH="$PATH:$HOME/.nix-profile/bin"
function newest_wezterm_release() {
curl -H "Accept: application/vnd.github+json" -L https://api.github.com/repos/wez/wezterm/releases/latest | jq -r '.assets | map(select(.name | startswith("WezTerm-macos"))) | first.browser_download_url'
newest_wezterm_release() {
curl -s -H "Accept: application/vnd.github+json" -L https://api.github.com/repos/wez/wezterm/releases/latest | jq -r '.assets | map(select(.name | startswith("WezTerm-macos"))) | first.browser_download_url'
}
LATEST_WEZTERM=$(newest_wezterm_release)
install_latest_wezterm() {
curl -Lo wezterm.zip "$LATEST_WEZTERM"
ouch d wezterm.zip
mv WezTerm-macos-*/WezTerm.app /Applications/ && rm -rf wezterm.zip WezTerm-macos-*
}
if [ ! -e /Applications/WezTerm.app ]; then
curl -Lo wezterm.zip $(latest_wezterm_release)
ouch d wezterm.zip
mv WezTerm-macos-*/WezTerm.app /Applications/ && rm -rf wezterm.zip WezTerm-macos-*
install_latest_wezterm
else
current_wezterm=$(/Applications/WezTerm.app/Contents/MacOS/wezterm -V | awk '{print $2}')
if ! echo "$LATEST_WEZTERM" | grep "$current_wezterm" >/dev/null; then
install_latest_wezterm
fi
fi
cat <<EOF >"$HOME/.wezterm.lua"
@ -287,19 +301,24 @@ EOF
install -m 640 ./.zshrc "$HOME/"
AUTO_FILE="$HOME/.zshrc.auto"
echo > "$AUTO_FILE"
atuin init zsh --disable-up-arrow >> "$AUTO_FILE"
direnv hook zsh >> "$AUTO_FILE"
starship init zsh --print-full-init >> "$AUTO_FILE"
zoxide init zsh >> "$AUTO_FILE"
{
atuin init zsh --disable-up-arrow
direnv hook zsh
starship init zsh --print-full-init
zoxide init zsh
} >"$AUTO_FILE"
[ -d /usr/local/bin ] || sudo mkdir /usr/local/bin
function install_typst() {
install_typst() {
echo "manually installing typst"
curl -sLO https://github.com/typst/typst/releases/download/22-03-21-2/typst-x86_64-apple-darwin.tar.gz
ouch d typst*.tar.gz
sudo install -m 755 typst*/typst /usr/local/bin/
rm -rf ./typst*
}
[ -e "/usr/local/bin/typst" ] || install_typst
shellcheck "$0" || exit 1
shfmt -i 2 -d -s "$0"