Skip to content

Commit

Permalink
add init_all script for configs
Browse files Browse the repository at this point in the history
  • Loading branch information
moukoublen committed Feb 5, 2025
1 parent d91598f commit 8d2ee0f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 73 deletions.
3 changes: 3 additions & 0 deletions bin/lnx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ fi
# if link already exists, return.
if [[ -L ${dst_file} ]]; then
echo -e "Link already exists\n \e[0;36m${dst_file}\e[0m -> \e[0;35m$(rp "${dst_file}")\e[0m"
echo ""
exit 0
fi

# install sym link
echo -e "\e[0;92mLinking\e[0m\n \e[0;35m${src_file}\e[0m -> \e[0;36m${dst_file}\e[0m"
ln -s "${src_file}" "${dst_file}"

echo ""
6 changes: 6 additions & 0 deletions config/dircolors/install-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONF_PATH="${HOME}"

lnx "${SRC}/.dir_colors" "${CONF_PATH}/.dir_colors"
27 changes: 2 additions & 25 deletions config/git/install-config
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
#!/usr/bin/env bash

SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONF_PATH="${HOME}"
# if [[ $(uname) = "Darwin" ]]; then
# CONF_PATH="${HOME}"
# fi
mkdir -p "${CONF_PATH}"

SELF_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

__install_settings_file() {
local cnf_file="${1}"
local trg_file=${2:-${cnf_file}}

local ORIGIN="${SELF_PATH}/${cnf_file}"
local TARGET="${CONF_PATH}/${trg_file}"

# if file exists, backup.
[[ -f ${TARGET} ]] && [[ ! -L ${TARGET} ]] && mv "${TARGET}"{,.backup}

# if link already exists, return.
[[ -L ${TARGET} ]] && echo "Link for ${cnf_file} already exists" && return

# install sym link
echo -e "Linking \e[0;35m${ORIGIN}\e[0m -> \e[0;36m${TARGET}\e[0m"
ln -s "${ORIGIN}" "${TARGET}"
}

__install_settings_file '.gitconfig'
lnx "${SRC}/.gitconfig" "${CONF_PATH}/.gitconfig"
26 changes: 2 additions & 24 deletions config/starship/install-config
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
#!/usr/bin/env bash

SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONF_PATH="${HOME}/.config"
# if [[ $(uname) = "Darwin" ]]; then
# CONF_PATH="${HOME}/.config"
# fi
mkdir -p "${CONF_PATH}"

SELF_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

__install_settings_file() {
local cnf_file="${1}"
local trg_file=${2:-${cnf_file}}

local ORIGIN="${SELF_PATH}/${cnf_file}"
local TARGET="${CONF_PATH}/${trg_file}"

# if file exists, backup.
[[ -f ${TARGET} ]] && [[ ! -L ${TARGET} ]] && mv "${TARGET}"{,.backup}

# if link already exists, return.
[[ -L ${TARGET} ]] && echo "Link for ${cnf_file} already exists" && return

# install sym link
echo -e "Linking \e[0;35m${ORIGIN}\e[0m -> \e[0;36m${TARGET}\e[0m"
ln -s "${ORIGIN}" "${TARGET}"
}

__install_settings_file 'starship.toml'
lnx "${SRC}/starship.toml" "${CONF_PATH}/starship.toml"
23 changes: 2 additions & 21 deletions config/sublime/install-config
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
#!/usr/bin/env bash

SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONF_PATH="${HOME}/.config/sublime-text/Packages/User"
# if [[ $(uname) = "Darwin" ]]; then
# CONF_PATH="${HOME}/.config/sublime-text/Packages/User"
# fi
mkdir -p "${CONF_PATH}"

SELF_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

__install_settings_file() {
local cnf_file=$1
local trg_file=${2:-${cnf_file}}

local ORIGIN="${SELF_PATH}/${cnf_file}"
local TARGET="${CONF_PATH}/${trg_file}"

# if file exists, backup.
[[ -f ${TARGET} ]] && [[ ! -L ${TARGET} ]] && mv "${TARGET}"{,.backup}

# if link already exists, return.
[[ -L ${TARGET} ]] && echo "Link for ${cnf_file} already exists" && return

# install sym link
echo -e "Linking \e[0;35m${ORIGIN}\e[0m -> \e[0;36m${TARGET}\e[0m"
ln -s "${ORIGIN}" "${TARGET}"
}

__install_settings_file 'Preferences.sublime-settings'
lnx "${SRC}/Preferences.sublime-settings" "${CONF_PATH}/Preferences.sublime-settings"
10 changes: 10 additions & 0 deletions init_all
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

"${DOTFILES_PATH}"/config/bat/install-config
"${DOTFILES_PATH}"/config/dircolors/install-config
"${DOTFILES_PATH}"/config/ghostty/install-config
"${DOTFILES_PATH}"/config/git/install-config
"${DOTFILES_PATH}"/config/starship/install-config
"${DOTFILES_PATH}"/config/vim/install-config
"${DOTFILES_PATH}"/config/vscode/install-config
"${DOTFILES_PATH}"/config/sublime/install-config
12 changes: 9 additions & 3 deletions scripts/install-kubectl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

VER="${1}" # first argument is the version number e.g. 1.19
set -euo pipefail

VER="${1:-}" # first argument is the version number e.g. 1.19

if [ -z "${VER}" ]; then
VER=$(curl -L -s https://dl.k8s.io/release/stable.txt)
fi
Expand All @@ -11,7 +14,7 @@ fi

__LOCAL_VER=""
if command -v kubectl &>/dev/null; then
__LOCAL_VER=$(kubectl version --client --short | sed 's/Client Version: //')
__LOCAL_VER=$(kubectl version --client | grep 'Client Version' | sed 's/Client Version: //')
fi

if [[ ${VER} == "${__LOCAL_VER}" ]]; then
Expand All @@ -24,7 +27,10 @@ printf "Installing kubectl \e[1;34m%s\e[0m \n" "${VER}"
rm -rf /tmp/kubectl_install || true
mkdir -p /tmp/kubectl_install

curl --fail --show-error --location "https://dl.k8s.io/release/${VER}/bin/linux/amd64/kubectl" --output /tmp/kubectl_install/kubectl
curl --fail --show-error --location \
"https://dl.k8s.io/release/${VER}/bin/linux/amd64/kubectl" \
--output /tmp/kubectl_install/kubectl

sudo install -o root -g root -m 0755 /tmp/kubectl_install/kubectl /usr/local/bin/kubectl

rm -rf /tmp/kubectl_install || true

0 comments on commit 8d2ee0f

Please sign in to comment.