Files
dotfiles/install

125 lines
2.9 KiB
Bash
Executable File

#!/bin/bash
#
# Adapted from Junegunn Choi (junegunn.c@gmail.com)
# https://github.com/junegunn/dotfiles/blob/master/install
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
install_rust_app() {
REPO=$1
DIRNAME=$2
BINARY=$3
if [ ! -d "$DIRNAME" ] ; then
git clone "$REPO" "$DIRNAME"
pushd "$DIRNAME" 1>/dev/null
else
pushd "$DIRNAME" 1>/dev/null
git pull
fi
cargo build --release
cp -fv $PWD/target/release/$BINARY ~/bin/
cargo clean
popd 1>/dev/null
}
BASE=$(pwd)
EXA_VER=
# RC files
mkdir -pv bak
for rc in *rc *profile tmux.conf bashrc.d mutt ; do
if [ ! -r $rc ] ; then
continue
fi
[ $(realpath ~/."$rc") == $BASE/$rc ]
if [ $? -ne 0 ] ; then
[ -e ~/."$rc" ] && mv -v ~/."$rc" bak/."$rc"
ln -sfv "$BASE/$rc" ~/."$rc"
fi
done
if [ "$(which cargo)" == "" ] ; then
# Install Cargo, in order to install exa etc.
(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh) || exit 1
source $HOME/.cargo/env
fi
cargo install bat exa sd
GIT=$(which git)
if [ "$GIT" != "" ] ; then
mkdir -p ~/src/
install_rust_app https://github.com/sharkdp/fd.git ~/src/fd fd
install_rust_app https://github.com/dandavison/delta.git ~/src/delta delta
else
echo "You don't have git; can't install fd and a lot of Vim plugins are going to fail too."
fi
GIT=$(which git)
if [ "$GIT" != "" ] ; then
mkdir -p ~/src/
pushd ~/src/
if [ ! -d fd ] ; then
git clone https://github.com/sharkdp/fd.git
cd fd
else
cd fd
git pull
fi
cargo build --release
ln -sfv $PWD/target/release/fd ~/bin
popd
else
echo "You don't have git; can't install fd and a lot of Vim plugins are going to fail too."
fi
# git-prompt
# if [ ! -e ~/.git-prompt.sh ]; then
# curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh
# fi
# scripts
mkdir -p ~/bin
for bin in $BASE/bin/*; do
BIN_NAME=$(basename $bin)
[ $(realpath ~/bin/$BIN_NAME) == $bin ]
if [ $? -ne 0 ] ; then
ln -svf "$bin" ~/bin
fi
done
if [ "$(uname -s)" = 'Darwin' ]; then
# Homebrew
[ -z "$(which brew)" ] &&
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install \
fd ag wget git bat tmux bash-completion \
vim macvim jq
# brew tap universal-ctags/universal-ctags
# brew install --HEAD universal-ctags
fi
git config --global user.email "paul@blacksun.org.uk"
git config --global user.name "Paul Walker"
git config --global core.pager "delta --line-numbers --dark"
git config --global delta.side-by-side true
git config --global delta.syntax-theme Dracula
# git config --global delta.syntax-theme "Solarized (dark)"
if [ ! -d ~/.tmux/plugins/tpm ] ; then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
if [ "$TMUX" != "" ] ; then
# If we're currently in tmux, source the new file.
tmux source-file ~/.tmux.conf
fi
fi
# TODO - install node?
./install-vim