diff options
-rw-r--r-- | bashrc | 4 | ||||
-rwxr-xr-x | cheat.sh/install | 7 | ||||
-rw-r--r-- | cheat.sh/shell/_cht | 21 | ||||
-rw-r--r-- | cheat.sh/uninstall | 3 | ||||
-rwxr-xr-x | compose-cli/install | 27 | ||||
-rwxr-xr-x | compose-cli/uninstall | 5 | ||||
-rwxr-xr-x | docker-machine/install | 30 | ||||
-rwxr-xr-x | docker-machine/uninstall | 5 | ||||
-rw-r--r-- | install.conf.yaml | 25 | ||||
-rwxr-xr-x | scripts/install-crate.sh | 221 | ||||
-rw-r--r-- | starship.toml | 2 | ||||
-rw-r--r-- | wt.json | 4 | ||||
-rw-r--r-- | zshrc | 2 |
13 files changed, 249 insertions, 107 deletions
@@ -2,6 +2,10 @@ export DOTFILES="${HOME}/dotfiles" +for f in "${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion"; do + source $f +done + source $DOTFILES/shell/env.sh source $DOTFILES/shell/aliases.sh [ -n "${WSL_DISTRO_NAME+1}" ] && source $DOTFILES/shell/wsl.sh diff --git a/cheat.sh/install b/cheat.sh/install deleted file mode 100755 index aa0b9ec..0000000 --- a/cheat.sh/install +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -if [ ! "$(which cht.sh)" ]; then - mkdir -p ~/.local/bin - curl https://cht.sh/:cht.sh >~/.local/bin/cht.sh - chmod +x ~/.local/bin/cht.sh -fi diff --git a/cheat.sh/shell/_cht b/cheat.sh/shell/_cht deleted file mode 100644 index e1a4230..0000000 --- a/cheat.sh/shell/_cht +++ /dev/null @@ -1,21 +0,0 @@ -#compdef cht.sh - -__CHTSH_LANGS=($(curl -s cheat.sh/:list)) -_arguments -C \ - '--help[show this help message and exit]: :->noargs' \ - '--shell[enter shell repl]: :->noargs' \ - '1:Cheat Sheet:->lang' \ - '*::: :->noargs' && return 0 - -if [[ CURRENT -ge 1 ]]; then - case $state in - noargs) - _message "nothing to complete";; - lang) - compadd -X "Cheat Sheets" ${__CHTSH_LANGS[@]};; - *) - _message "Unknown state, error in autocomplete";; - esac - - return -fi diff --git a/cheat.sh/uninstall b/cheat.sh/uninstall deleted file mode 100644 index bff08cd..0000000 --- a/cheat.sh/uninstall +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -rm ~/.local/bin/cht.sh diff --git a/compose-cli/install b/compose-cli/install deleted file mode 100755 index 8ff44a0..0000000 --- a/compose-cli/install +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -if docker compose >&/dev/null; then - current_version=0.0.0 - echo "compose-cli: not installed" -else - current_version=$(docker compose version >&/dev/null | grep -oEm1 '[0-9]+.[0-9\.]+-beta[0-9\.]*') - echo "compose-cli: found $current_version" -fi - -version=$(curl -s "https://api.github.com/repos/docker/compose-cli/releases" | grep -oEm1 '[0-9]+.[0-9\.]+-beta[0-9\.]*') - -if [[ "$version" == "$current_version" ]]; then - echo "compose-cli: up-to-date" -else - echo "compose-cli: new version found $version" - echo "compose-cli: downloading..." - - arch="$(dpkg --print-architecture)" - arch="${arch/hf/v7}" - - mkdir -p ~/.docker/cli-plugins - curl -sSLo ~/.docker/cli-plugins/docker-compose "https://github.com/docker/compose-cli/releases/download/v${version}/docker-compose-linux-${arch}" - chmod +x ~/.docker/cli-plugins/docker-compose - - echo "compose-cli: installed" -fi diff --git a/compose-cli/uninstall b/compose-cli/uninstall deleted file mode 100755 index 560da86..0000000 --- a/compose-cli/uninstall +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -if rm ~/.docker/cli-plugins/docker-compose; then - echo "compose-cli: uninstalled" -fi diff --git a/docker-machine/install b/docker-machine/install deleted file mode 100755 index 5bbd82c..0000000 --- a/docker-machine/install +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT="docker-machine-installer" - -if docker compose >&/dev/null; then - current_version=0.0.0 - echo "$SCRIPT: not installed" -else - current_version=$(docker-machine --version >&/dev/null | grep -oE '[0-9]+.[0-9\.]+') - echo "$SCRIPT: found $current_version" -fi - -# version=$(curl -s "https://api.github.com/repos/docker/machine/releases" | grep -oE '[0-9]+.[0-9\.]+') -version="0.16.2" - -if [[ "$version" == "$current_version" ]]; then - echo "$SCRIPT: up-to-date" -else - echo "$SCRIPT: new version found $version" - echo "$SCRIPT: downloading..." - - arch="$(uname -s)-$(uname -m)" - echo "https://github.com/docker/machine/releases/download/v$version/docker-machine-$arch" - - curl -L "https://github.com/docker/machine/releases/download/v$version/docker-machine-$arch" >/tmp/docker-machine && - chmod +x /tmp/docker-machine && - cp /tmp/docker-machine "${HOME}/.local/bin" - - echo "$SCRIPT: installed" -fi diff --git a/docker-machine/uninstall b/docker-machine/uninstall deleted file mode 100755 index 5375ce8..0000000 --- a/docker-machine/uninstall +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -if rm -f /usr/local/bin/docker-machine; then - echo "compose-cli: uninstalled" -fi diff --git a/install.conf.yaml b/install.conf.yaml index 0dff2be..8890115 100644 --- a/install.conf.yaml +++ b/install.conf.yaml @@ -12,19 +12,26 @@ - shell: - command: git submodule update --init --recursive description: Installing submodules - - command: sh -c "$(curl -fsSL https://starship.rs/install.sh)" -- --bin-dir "${HOME}/.local/bin" --yes + + - command: ${HOME}/dotfiles/scripts/install-crate.sh --git starship/starship --no-tag description: Installing Starship + - command: curl -sfL git.io/antibody | sh -s - -b "${HOME}/.local/bin" description: Installing antibody - - command: (cd ${HOME}/dotfiles/zsh; antibody bundle < plugins.txt > plugins.zsh) + + - command: (cd ${HOME}/dotfiles/zsh; antibody bundle <plugins.txt >plugins.zsh) description: Installing zsh plugins + - command: if [ ! -f "${HOME}/.fzf/install" ]; then git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf; fi && yes | ~/.fzf/install --bin description: installing fzf - - command: ./bat/install bat + + - command: ${HOME}/dotfiles/scripts/install-crate.sh --git sharkdp/bat description: Installing bat - - command: ./cheat.sh/install + + - command: curl https://cht.sh/:cht.sh >~/.local/bin/cht.sh && chmod +x ${HOME}/.local/bin/cht.sh description: Installing cheat.sh - - command: curl -sL "https://raw.githubusercontent.com/paulirish/git-open/master/git-open" > "${HOME}/.local/bin/git-open" && chmod +x "${HOME}/.local/bin/git-open" + + - command: curl -sL "https://raw.githubusercontent.com/paulirish/git-open/master/git-open" >"${HOME}/.local/bin/git-open" && chmod +x "${HOME}/.local/bin/git-open" description: Installing git-open - link: @@ -39,6 +46,14 @@ path: gnupg/*.conf - shell: + - command: mkdir -p ${HOME}/.local/share/zsh/site-functions + description: Created zsh completion directory + - command: starship completions >${HOME}/.local/share/zsh/site-functions/_starship + description: Installing starship completions + - command: curl https://cheat.sh/:zsh >${HOME}/.local/share/zsh/site-functions/_cht + description: Installing cht.sh completions + +- shell: # ISSUE #1 Fails to import key inside of WSL2 - command: gpg --recv-key 0xC8F6E06F5C8E2634 description: Getting GPG public key diff --git a/scripts/install-crate.sh b/scripts/install-crate.sh new file mode 100755 index 0000000..22fbc11 --- /dev/null +++ b/scripts/install-crate.sh @@ -0,0 +1,221 @@ +#!/bin/sh + +# modified from https://github.com/japaric/trust/blob/gh-pages/install.sh. + +set -e + +help() { + cat <<'EOF' +Install a binary release of a Rust crate hosted on GitHub + +Usage: + install-crate.sh [options] + +Options: + -h, --help Display this message + -q, --quiet Silence all output + --git SLUG Get the crate from "https://github/$SLUG" + -f, --force Force overwriting an existing binary + --crate NAME Name of the crate to install (default <repository name>) + --tag TAG Tag (version) of the crate to install (default <latest release>) + --no-tag Do not tag between the crate and the target in the url + --target TARGET Install the release compiled for $TARGET (default <`rustc` host>) + --to LOCATION Where to install the binary (default ~/.cargo/bin) + --completion + Install all the completions + + --completion-bash DIR + Install the bash completion scripts in DIR (default ~/.local/share/bash_completion.d) + + --completion-zsh DIR + Install the zsh completion scripts in DIR (default ~/.local/share/zsh/site-functions) + + --completion-fish DIR + Install the fish completion scripts in DIR (default ~/.config/fish/completions) +EOF +} + +say() { + if [ ! $quiet ]; then + echo "install-crate.sh: $1" + fi +} + +say_err() { + say "$1" >&2 +} + +err() { + if [ ! -z $td ]; then + rm -rf $td + fi + + say_err "ERROR $1" + exit 1 +} + +need() { + if ! command -v $1 >/dev/null 2>&1; then + err "need $1 (command not found)" + fi +} + +quiet=false +force=false +no_tag=false +completion_bash=false +completion_zsh=false +completion_fish=false +comp_dir_bash="${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion" +comp_dir_zsh="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" +comp_dir_fish="${XDG_CONFIG_HOME:-$HOME/.config}/fish/completions" +while test $# -gt 0; do + case $1 in + --quiet | -q) + quiet=true + ;; + --crate) + crate=$2 + shift + ;; + --force | -f) + force=true + ;; + --git) + git=$2 + shift + ;; + --help | -h) + help + exit 0 + ;; + --tag) + tag=$2 + shift + ;; + --no-tag) + no_tag=true + ;; + --target) + target=$2 + shift + ;; + --to) + dest=$2 + shift + ;; + --completion) + completion_bash=true + completion_zsh=true + completion_fish=true + ;; + --completion-bash) + completion-bash=true + comp_bash_dir=$2 + shift + ;; + --completion-zsh) + completion-zsh=true + comp_zsh_dir=$2 + shift + ;; + --completion-fish) + completion-fish=true + comp_fish_dir=$2 + shift + ;; + *) ;; + + esac + shift +done + +# Dependencies +need basename +need curl +need install +need mkdir +need mktemp +need tar + +# Optional dependencies +if [ -z $crate ] || [ -z $tag ] || [ -z $target ]; then + need cut +fi + +if [ -z $tag ]; then + need rev +fi + +if [ -z $target ]; then + need grep + need rustc +fi + +if [ -z $git ]; then + err 'must specify a git repository using `--git`. Example: `install.sh --git japaric/cross`' +fi + +url="https://github.com/$git" +say_err "GitHub repository: $url" + +if [ -z $crate ]; then + crate=$(echo $git | cut -d'/' -f2) +fi + +say_err "Crate: $crate" + +url="$url/releases" + +if [ -z $tag ]; then + tag=$(curl -s "$url/latest" | cut -d'"' -f2 | rev | cut -d'/' -f1 | rev) + say_err "Tag: latest ($tag)" +else + say_err "Tag: $tag" +fi + +if [ -z $target ]; then + target=$(rustc -Vv | grep host | cut -d' ' -f2) +fi + +say_err "Target: $target" + +if [ -z $dest ]; then + dest="$HOME/.cargo/bin" +fi + +if [ $no_tag = false ]; then + crate_tag="-$tag" +fi + +say_err "Installing to: $dest" +url="$url/download/$tag/$crate${crate_tag}-$target.tar.gz" + +say_err "Downloading: $url" + +td=$(mktemp -d || mktemp -d -t tmp) +curl -sL $url | tar -C $td -xz + +for f in $(find "$td" -type f); do + case $f in + *".bash") + [ $completion_bash ] && install -D $f "$comp_dir_bash/$crate.sh" + ;; + *".zsh") + [ $completion_zsh ] && install -D $f "$comp_dir_zsh/_$crate" + ;; + *".fish") + [ $completion_fish ] && install -D $f "$comp_dir_fish/$crate.fish" + ;; + *) ;; + esac + + test -x $f || continue + if [ -e "$dest/$f" ] && [ $force = false ]; then + err "$(dirname $f) already exists in $dest" + else + install -Dm 755 $f $dest + fi +done + +rm -rf $td diff --git a/starship.toml b/starship.toml index 73a762b..1c6cfcd 100644 --- a/starship.toml +++ b/starship.toml @@ -30,7 +30,9 @@ symbol = " " [directory] read_only = " " +# truncation_length = 2 fish_style_pwd_dir_length = 1 +truncate_to_repo = false [directory.substitutions] "~/win" = " ~" @@ -49,10 +49,6 @@ "keys": "ctrl+w" }, { - "command": "toggleFocusMode", - "keys": "ctrl+b" - }, - { "command": { "action": "commandPalette" @@ -2,6 +2,8 @@ export DOTFILES="${HOME}/dotfiles" +fpath=( "${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" "${fpath[@]}" ) + source $DOTFILES/shell/env.sh source $DOTFILES/zsh/plugins.zsh [ -n "${WSL_DISTRO_NAME+1}" ] && source $DOTFILES/shell/wsl.sh |