~joshleeb/dotfiles

1592018dd698fed68d0b45b1248326c8cb6769f5 — Josh Leeb-du Toit 9 days ago 70d9c1a
Add BSD and GNU utils scripts

Add utils scripts for GNU and BSD with functions that abstract over
symlinking files (symlink) and directories (symlinkdir) for
compatibility across profiles
5 files changed, 59 insertions(+), 26 deletions(-)

M bin/common.sh
M bin/malus.sh
M bin/sycamore.sh
A bin/utils/bsd.sh
A bin/utils/gnu.sh
M bin/common.sh => bin/common.sh +13 -16
@@ 8,17 8,15 @@ function _link_common_cargo {
        mkdir "${dstdir}"
    fi

    ln --symbolic --force "${REPO_DIR}/cargo/config.toml" "${dstdir}/config"
    symlink "${REPO_DIR}/cargo/config.toml" "${dstdir}/config"
}

function _link_common_git {
    ln --symbolic --no-target-directory --force \
        "${REPO_DIR}/git" "${HOME}/.config/git"
    symlinkdir "${REPO_DIR}/git" "${HOME}/.config/git"
}

function _link_common_nvim {
    ln --symbolic --no-target-directory --force \
        "${REPO_DIR}/nvim" "${HOME}/.config/nvim"
    symlinkdir "${REPO_DIR}/nvim" "${HOME}/.config/nvim"
}

function _link_common_smerge {


@@ 27,23 25,22 @@ function _link_common_smerge {
        mkdir --parents "${dstdir}"
    fi

    ln --symbolic --force "${REPO_DIR}/smerge/diff.json" "${dstdir}/Diff.sublime-settings"
    ln --symbolic --force "${REPO_DIR}/smerge/preferences.json" "${dstdir}/Preferences.sublime-settings"
    symlink "${REPO_DIR}/smerge/diff.json" "${dstdir}/Diff.sublime-settings"
    symlink "${REPO_DIR}/smerge/preferences.json" "${dstdir}/Preferences.sublime-settings"
}

function _link_common_tmux {
    ln --symbolic --force "${REPO_DIR}/tmux/init.conf" "${HOME}/.tmux.conf"
    symlink "${REPO_DIR}/tmux/init.conf" "${HOME}/.tmux.conf"
}

function _link_common_zsh {
    ln --symbolic --force "${REPO_DIR}/zsh/aliases.zsh" "${HOME}/.zaliases"
    ln --symbolic --force "${REPO_DIR}/zsh/env.zsh" "${HOME}/.zshenv"
    ln --symbolic --force "${REPO_DIR}/zsh/login.zsh" "${HOME}/.zlogin"
    ln --symbolic --force "${REPO_DIR}/zsh/opts.zsh" "${HOME}/.zshopts"
    ln --symbolic --force "${REPO_DIR}/zsh/prompt.zsh" "${HOME}/.zprompt"
    ln --symbolic --force "${REPO_DIR}/zsh/rc.zsh" "${HOME}/.zshrc"
    ln --symbolic --force --no-target-directory \
        "${REPO_DIR}/zsh/scripts" "${HOME}/.zscripts"
    symlink "${REPO_DIR}/zsh/aliases.zsh" "${HOME}/.zaliases"
    symlink "${REPO_DIR}/zsh/env.zsh" "${HOME}/.zshenv"
    symlink "${REPO_DIR}/zsh/login.zsh" "${HOME}/.zlogin"
    symlink "${REPO_DIR}/zsh/opts.zsh" "${HOME}/.zshopts"
    symlink "${REPO_DIR}/zsh/prompt.zsh" "${HOME}/.zprompt"
    symlink "${REPO_DIR}/zsh/rc.zsh" "${HOME}/.zshrc"
    symlinkdir "${REPO_DIR}/zsh/scripts" "${HOME}/.zscripts"
}

function link_common {

M bin/malus.sh => bin/malus.sh +3 -0
@@ 2,6 2,9 @@

REPO_DIR=$(git rev-parse --show-toplevel)

# shellcheck source=bin/utils/bsd.sh
source "${REPO_DIR}/bin/utils/bsd.sh"

# shellcheck source=bin/common.sh
source "${REPO_DIR}/bin/common.sh"


M bin/sycamore.sh => bin/sycamore.sh +13 -10
@@ 2,6 2,9 @@

REPO_DIR=$(git rev-parse --show-toplevel)

# shellcheck source=bin/utils/gnu.sh
source "${REPO_DIR}/bin/utils/gnu.sh"

# shellcheck source=bin/common.sh
source "${REPO_DIR}/bin/common.sh"



@@ 11,7 14,7 @@ function _link_sycamore_alacritty {
        mkdir "${dstdir}"
    fi

    ln --symbolic --force "${REPO_DIR}/alacritty/config.sycamore.yaml" "${dstdir}/alacritty.yml"
    symlink "${REPO_DIR}/alacritty/config.sycamore.yaml" "${dstdir}/alacritty.yml"
}

function _link_sycamore_smerge {


@@ 20,22 23,22 @@ function _link_sycamore_smerge {
        mkdir --parents "${dstdir}"
    fi

    ln --symbolic --force "${REPO_DIR}/smerge/theme.json" "${dstdir}/Merge.sublime-theme"
    symlink "${REPO_DIR}/smerge/theme.json" "${dstdir}/Merge.sublime-theme"
}

function _link_sycamore_x11 {
    ln --symbolic --force "${REPO_DIR}/x11/xinitrc" "${HOME}/.xinitrc"
    ln --symbolic --force "${REPO_DIR}/x11/xmodmap" "${HOME}/.Xmodmap"
    ln --symbolic --force "${REPO_DIR}/x11/xresources" "${HOME}/.Xresources"
    ln --symbolic --force "${REPO_DIR}/x11/user-dirs.dirs" "${HOME}/.config/user-dirs.dirs"
    ln --symbolic --force "${REPO_DIR}/x11/user-dirs.locale" "${HOME}/.config/user-dirs.locale"
    symlink "${REPO_DIR}/x11/xinitrc" "${HOME}/.xinitrc"
    symlink "${REPO_DIR}/x11/xmodmap" "${HOME}/.Xmodmap"
    symlink "${REPO_DIR}/x11/xresources" "${HOME}/.Xresources"
    symlink "${REPO_DIR}/x11/user-dirs.dirs" "${HOME}/.config/user-dirs.dirs"
    symlink "${REPO_DIR}/x11/user-dirs.locale" "${HOME}/.config/user-dirs.locale"
}

function _link_sycamore_zsh {
    ln --symbolic --force "${REPO_DIR}/zsh/env.zsh" "${HOME}/.zshenv.common"
    ln --symbolic --force "${REPO_DIR}/zsh/env.sycamore.zsh" "${HOME}/.zshenv"
    symlink "${REPO_DIR}/zsh/env.zsh" "${HOME}/.zshenv.common"
    symlink "${REPO_DIR}/zsh/env.sycamore.zsh" "${HOME}/.zshenv"

    ln --symbolic --force "${REPO_DIR}/zsh/profile.sycamore.zsh" "${HOME}/.zprofile"
    symlink "${REPO_DIR}/zsh/profile.sycamore.zsh" "${HOME}/.zprofile"
}

function link_sycamore {

A bin/utils/bsd.sh => bin/utils/bsd.sh +15 -0
@@ 0,0 1,15 @@
#!/usr/bin/env bash

function symlink {
    local target="$1"
    local link_name="$2"

    ln -sf "${target}" "${link_name}"
}

function symlinkdir {
    local target="$1"
    local link_name="$2"

    ln -shf "${target}" "${link_name}"
}

A bin/utils/gnu.sh => bin/utils/gnu.sh +15 -0
@@ 0,0 1,15 @@
#!/usr/bin/env bash

function symlink {
    local target="$1"
    local link_name="$2"

    ln --symbolic --force "${target}" "${link_name}"
}

function symlinkdir {
    local target="$1"
    local link_name="$2"

    ln --symbolic --no-target-directory --force "${target}" "${link_name}"
}