Deployment improvements
Replace deploy.sh with deploy.py Some updates to setup scripts, for more consistency Split out some common unix setup tasks into a script that both mac and linux scripts call.
This commit is contained in:
3
TODO.org
3
TODO.org
@@ -1,5 +1,4 @@
|
|||||||
* Dotfiles
|
|
||||||
** Change deploy script to python
|
|
||||||
* DOOM Emacs
|
* DOOM Emacs
|
||||||
Jump to favorite files
|
Jump to favorite files
|
||||||
Figure out emacs-based terminals
|
Figure out emacs-based terminals
|
||||||
|
Figure out anaconda mode virtualenvs
|
||||||
|
|||||||
69
deploy.py
Normal file
69
deploy.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
home = Path.home().resolve().absolute()
|
||||||
|
dotdir = Path(__file__).parent.resolve().absolute()
|
||||||
|
|
||||||
|
simple = [
|
||||||
|
# 'gemrc',
|
||||||
|
'gitconfig',
|
||||||
|
'ideavimrc',
|
||||||
|
'lein',
|
||||||
|
# 'irbrc',
|
||||||
|
# 'nethackrc',
|
||||||
|
# 'spacemacs',
|
||||||
|
'tmux.conf',
|
||||||
|
'vimrc'
|
||||||
|
]
|
||||||
|
|
||||||
|
targeted = {
|
||||||
|
'doom': '.doom.d',
|
||||||
|
'fish': '.config/fish',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def deploy(source_name, target_name, dry_run=False):
|
||||||
|
source = dotdir.joinpath(source_name)
|
||||||
|
target = home.joinpath(target_name)
|
||||||
|
|
||||||
|
if not source.exists():
|
||||||
|
raise FileNotFoundError(f"Asked to link {source_name}, which doesn't exist in {dotdir}.")
|
||||||
|
|
||||||
|
if target.exists():
|
||||||
|
if target.samefile(source):
|
||||||
|
print(f"{target}->{source} already linked.")
|
||||||
|
return
|
||||||
|
|
||||||
|
backup_path = target.parent.joinpath(f"{target.name}.bak")
|
||||||
|
|
||||||
|
print(f"{target} moves to {backup_path}")
|
||||||
|
if not dry_run:
|
||||||
|
target.replace(backup_path)
|
||||||
|
|
||||||
|
if not target.parent.exists():
|
||||||
|
print(f"making parent directories of {target}")
|
||||||
|
if not dry_run:
|
||||||
|
target.parent.mkdir(parents=True)
|
||||||
|
|
||||||
|
print(f"linking {target} to {source}")
|
||||||
|
if not dry_run:
|
||||||
|
target.symlink_to(source)
|
||||||
|
|
||||||
|
|
||||||
|
def main(dry_run=True):
|
||||||
|
for source in simple:
|
||||||
|
target = f".{source}"
|
||||||
|
deploy(source, target, dry_run=dry_run)
|
||||||
|
|
||||||
|
for source, target in targeted.items():
|
||||||
|
deploy(source, target, dry_run=dry_run)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
main(False)
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
print(e)
|
||||||
|
sys.exit(1)
|
||||||
26
deploy.sh
26
deploy.sh
@@ -1,26 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo "Deploying dotfiles..."
|
|
||||||
|
|
||||||
pushd $HOME &> /dev/null
|
|
||||||
|
|
||||||
FILES=($(ls -p .dotfiles | egrep -v "/\$|\\.sh|TODO"))
|
|
||||||
|
|
||||||
for file in ${FILES[@]}; do
|
|
||||||
mv .$file .${file}.bak
|
|
||||||
ln -s .dotfiles/$file .$file
|
|
||||||
done
|
|
||||||
|
|
||||||
mkdir -p .config
|
|
||||||
mv .config/fish .config/fish.bak
|
|
||||||
ln -s $HOME/.dotfiles/fish .config/fish
|
|
||||||
|
|
||||||
mv .lein .lein.bak
|
|
||||||
ln -s $HOME/.dotfiles/lein .lein
|
|
||||||
|
|
||||||
mv .doom.d .doom.d.bak
|
|
||||||
ln -s $HOME/.dotfiles/doom .doom.d
|
|
||||||
|
|
||||||
popd &> /dev/null
|
|
||||||
|
|
||||||
echo "...done."
|
|
||||||
@@ -63,21 +63,17 @@ gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps']"
|
|||||||
# Use local time so as to not conflict with Windows
|
# Use local time so as to not conflict with Windows
|
||||||
timedatectl set-local-rtc 1 --adjust-system-clock
|
timedatectl set-local-rtc 1 --adjust-system-clock
|
||||||
|
|
||||||
|
# Change default shell
|
||||||
|
sudo chsh -ls /usr/bin/fish $USER
|
||||||
|
|
||||||
# SSH setup
|
# SSH setup
|
||||||
ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -q -P ""
|
ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -q -P ""
|
||||||
|
|
||||||
echo "Please add this key to GitHub, then press ENTER to continue."
|
echo "Your SSH public key is:"
|
||||||
echo ""
|
echo ""
|
||||||
cat $HOME/.ssh/id_rsa.pub
|
cat ~/.ssh/id_rsa.pub
|
||||||
echo ""
|
echo ""
|
||||||
read
|
read -p "Please add it to GitHub, then press enter to continue."
|
||||||
|
|
||||||
git clone git@github.com:tim-mccarthy/dotfiles.git .dotfiles
|
git clone git@github.com:tim-mccarthy/dotfiles.git $HOME/.dotfiles
|
||||||
pushd .dotfiles
|
bash ~/.dotfiles/setup_unix_common.sh
|
||||||
./deploy.sh
|
|
||||||
popd
|
|
||||||
|
|
||||||
sudo chsh -ls /usr/bin/fish $USER
|
|
||||||
|
|
||||||
git clone https://github.com/hlissner/doom-emacs ~/.emacs.d
|
|
||||||
~/.emacs.d/bin/doom install
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ brew update
|
|||||||
brew install fish git
|
brew install fish git
|
||||||
brew cask install emacs
|
brew cask install emacs
|
||||||
|
|
||||||
git clone https://github.com/syl20bnr/spacemacs .emacs.d
|
curl -s 'https://macapps.link/en/firefox-bettertouchtool-dropbox-alfred-sublime-iterm-unarchiver-transmit' | sh
|
||||||
|
|
||||||
sudo bash -c "echo /usr/local/bin/fish >> /etc/shells"
|
sudo bash -c "echo /usr/local/bin/fish >> /etc/shells"
|
||||||
chsh -s /usr/local/bin/fish
|
chsh -s /usr/local/bin/fish
|
||||||
|
|
||||||
cat /dev/zero | ssh-keygen -q -N ""
|
ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -q -P ""
|
||||||
|
|
||||||
echo "Your SSH public key is:"
|
echo "Your SSH public key is:"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -18,5 +18,5 @@ cat ~/.ssh/id_rsa.pub
|
|||||||
echo ""
|
echo ""
|
||||||
read -p "Please add it to GitHub, then press enter to continue."
|
read -p "Please add it to GitHub, then press enter to continue."
|
||||||
|
|
||||||
curl -s 'https://macapps.link/en/chrome-bettertouchtool-dropbox-alfred-sublime-iterm-unarchiver-transmit' | sh
|
git clone git@github.com:tim-mccarthy/dotfiles.git $HOME/.dotfiles
|
||||||
|
bash ~/.dotfiles/setup_unix_common.sh
|
||||||
|
|||||||
8
setup_unix_common.sh
Normal file
8
setup_unix_common.sh
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
python3 $HOME/.dotfiles/deploy.py
|
||||||
|
|
||||||
|
git clone https://github.com/hlissner/doom-emacs ~/.emacs.d
|
||||||
|
~/.emacs.d/bin/doom install
|
||||||
|
~/.emacs.d/bin/doom sync
|
||||||
Reference in New Issue
Block a user