mirror of
https://github.com/ViViDboarder/shoestrap.git
synced 2024-11-22 05:56:31 +00:00
65 lines
1.7 KiB
Bash
65 lines
1.7 KiB
Bash
#!/bin/bash
|
|
|
|
##############################################################################
|
|
# Add your custom helpers here. Remember, this is just Bash!
|
|
##############################################################################
|
|
|
|
# Init all paths and make sure the directories exist
|
|
function init_paths_and_vars {
|
|
# Directory for projects
|
|
WORKSPACE="$HOME/workspace"
|
|
# This is in bashrc
|
|
USER_BIN="$HOME/bin"
|
|
# Local prefix
|
|
LOCAL_PREFIX="$HOME/.local"
|
|
# Local bin
|
|
LOCAL_BIN="$HOME/.local/bin"
|
|
# Temp dir for downloads
|
|
TMP_DIR="$PROJECT_DIR/tmp"
|
|
# System uname
|
|
UNAME_STR=$(uname)
|
|
# XGD_DATA
|
|
XDG_DATA_HOME="$HOME/.local/share"
|
|
# XGD_CONFIG
|
|
XDG_CONFIG_HOME="$HOME/.config"
|
|
|
|
# Create workspace dir
|
|
mkdir -p "$WORKSPACE"
|
|
mkdir -p "$USER_BIN"
|
|
mkdir -p "$LOCAL_PREFIX"
|
|
mkdir -p "$LOCAL_BIN"
|
|
mkdir -p "$TMP_DIR"
|
|
mkdir -p "$XDG_DATA_HOME"
|
|
mkdir -p "$XDG_CONFIG_HOME"
|
|
}
|
|
|
|
# Create a dotfile and source a synced version
|
|
function source_dotfile {
|
|
local RC_PATH=$1
|
|
local RC_NAME=""
|
|
RC_NAME=$(basename "$1")
|
|
local SOURCE_CMD="source"
|
|
|
|
# If a source command was passed in, we can use that
|
|
[ "$2" != "" ] && SOURCE_CMD=$2
|
|
|
|
# Check if .bash* file exists
|
|
if [[ ! ( -f "$HOME/.$RC_NAME" ) ]]; then
|
|
# Create a blank one
|
|
touch "$HOME/.$RC_NAME"
|
|
fi
|
|
|
|
try_link "$RC_PATH" "$HOME/.${RC_NAME}_sync"
|
|
|
|
add_line "#import $RC_NAME from synced" "$HOME/.$RC_NAME"
|
|
add_line "$SOURCE_CMD ~/.${RC_NAME}_sync" "$HOME/.$RC_NAME"
|
|
}
|
|
|
|
# Check if a recipe is installed, if not install it and mark it installed
|
|
function install() {
|
|
if ! is_installed "$1" ; then
|
|
recipe "$1"
|
|
set_installed "$1"
|
|
fi
|
|
}
|