all repos — dotfiles-base @ 0cc564558f6e3d7f8f6139f4c715085a47dd124d

base important configs that can safely be used almost anywhere

place-dotfiles-base.sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
#!/bin/sh
# place-dotfiles-base.sh: simple script to symlink my core dotfiles
# by x1phosura

dotfiles_root="$HOME"/73h4x/dotfiles/dotfiles-base    # where dotfiles live
# '-P|--physical' resolves the full directory, including resolving symlinks.
# NOTE: below, this still results in the full path to the directory.
script_base_dir=$(cd $(dirname $0) && pwd --physical) # this script's directory
#dotfiles_root="${script_base_dir}"  # directory where these dotfiles live
dest="$HOME"                                          # usually $HOME

die() {
    echo "$@"; exit 1
}


[ ! -d "$dotfiles_root" ] && \
    die "ERROR: $dotfiles_root doesn't exist. Aborting..."

# TODO: change '[[' to '[', test...
#[[ "$(realpath $dotfiles_root)" = "$(realpath $dest)" ]] && \
#    die " ERROR: dotfiles_root and dest are the same directory! Aborting..."

# TODO: maybe, maybe not place .bash_prompt
dotfiles_base_list=".bash_profile \
.bashrc \
.gdbinit \
.lynxrc \
.tmux.conf \
.config/fish \
.config/nvim \
.config/helix"

# Note: directly symlink items to .config instead of symlinking .config itself
# because I don't want to preserve everything that programs create there
mkdir -p "$dest"/.config

# link dotfiles in home directory
for file in $dotfiles_base_list ; do
    # TODO: only link after checking file's existence in dotfiles_root
    ln -svfn "$dotfiles_root"/"$file" "$dest"/"$file"
done

# handle neovim-to-vimrc symlink
ln -svfn "$dotfiles_root"/.config/nvim/vimrc.vim "$dest"/.vimrc