setup: add proper script to symlink config
This commit is contained in:
parent
f7c842d135
commit
e89f02d745
2 changed files with 110 additions and 30 deletions
110
setup.sh
Executable file
110
setup.sh
Executable file
|
|
@ -0,0 +1,110 @@
|
|||
#!/bin/sh
|
||||
|
||||
installed()
|
||||
{
|
||||
type "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
link()
|
||||
{
|
||||
local src="$(pwd)/$1"
|
||||
local dst="$2"
|
||||
|
||||
if test -e "$dst" && ! test -L "$dst"; then
|
||||
echo "No symlink $dst"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Linking $dst -> $src"
|
||||
ln -sf "$src" "$dst"
|
||||
}
|
||||
|
||||
|
||||
if installed vim; then
|
||||
echo "Setting up vim:"
|
||||
|
||||
link vimrc ~/.vimrc
|
||||
#link vim ~/.vim
|
||||
|
||||
echo
|
||||
fi
|
||||
|
||||
if installed zsh; then
|
||||
echo "Setting up zsh:"
|
||||
|
||||
link zshrc ~/.zshrc
|
||||
mkdir -p ~/.zsh
|
||||
|
||||
link zsh/aliases.zsh ~/.zsh/aliases.zsh
|
||||
link zsh/checks.zsh ~/.zsh/checks.zsh
|
||||
link zsh/colors.zsh ~/.zsh/colors.zsh
|
||||
link zsh/completion.zsh ~/.zsh/completion.zsh
|
||||
link zsh/history.zsh ~/.zsh/history.zsh
|
||||
link zsh/prompt.zsh ~/.zsh/prompt.zsh
|
||||
link zsh/setopt.zsh ~/.zsh/setopt.zsh
|
||||
|
||||
echo
|
||||
fi
|
||||
|
||||
if installed tmux; then
|
||||
echo "Setting up tmux:"
|
||||
|
||||
link tmux.conf ~/.tmux.conf
|
||||
|
||||
echo
|
||||
fi
|
||||
|
||||
if installed git; then
|
||||
echo "Setting up git:"
|
||||
|
||||
link gitconfig ~/.gitconfig
|
||||
|
||||
echo
|
||||
fi
|
||||
|
||||
if installed ssh; then
|
||||
echo "Setting up ssh:"
|
||||
|
||||
mkdir -p ~/.ssh
|
||||
link ssh/config ~/.ssh/config
|
||||
|
||||
echo
|
||||
fi
|
||||
|
||||
if installed gpg || installed gpg2; then
|
||||
echo "Setting up gpg:"
|
||||
|
||||
mkdir -p ~/.gnupg
|
||||
link gnupg/gpg-agent.conf ~/.gnupg/gpg-agent.conf
|
||||
link gnupg/gpg.conf ~/.gnupg/gpg.conf
|
||||
|
||||
echo
|
||||
fi
|
||||
|
||||
if installed X; then
|
||||
echo "Setting up X:"
|
||||
|
||||
link xinitrc ~/.xinitrc
|
||||
link xsession ~/.xsession
|
||||
link Xresources ~/.Xresources
|
||||
|
||||
echo
|
||||
fi
|
||||
|
||||
if installed herbstluftwm; then
|
||||
echo "Setting up herbstluftwm:"
|
||||
|
||||
mkdir -p ~/.config/herbstluftwm
|
||||
|
||||
link config/herbstluftwm/autostart ~/.config/herbstluftwm/autostart
|
||||
link config/herbstluftwm/panel.sh ~/.config/herbstluftwm/panel.sh
|
||||
link config/herbstluftwm/q3terminal.sh ~/.config/herbstluftwm/q3terminal.sh
|
||||
|
||||
link config/herbstluftwm/icons ~/.config/herbstluftwm/icons
|
||||
link config/herbstluftwm/icons_large ~/.config/herbstluftwm/icons_large
|
||||
|
||||
# barpyrus
|
||||
link config/barpyrus/config.py ~/.config/barpyrus/config.py
|
||||
|
||||
echo
|
||||
fi
|
||||
30
symlink.sh
30
symlink.sh
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Creates symlinks from home to ~/dotfiles
|
||||
|
||||
#Variables
|
||||
dir=~/dotfiles
|
||||
olddir=~/oldConfig
|
||||
files="$(find . -type f ! -path './.git/*' ! -name 'symlink.sh' -printf '%P\n')"
|
||||
|
||||
timestamp="$(date +%s)"
|
||||
|
||||
#Create oldConfig in ~
|
||||
|
||||
mkdir -p $olddir/$timestamp
|
||||
echo "Created $olddir/$timestamp to backup existing dotfiles in ~"
|
||||
|
||||
#Swap dir
|
||||
cd $dir
|
||||
|
||||
# Move any existing config-files to $olddir and then creating symlinks
|
||||
for file in $files; do
|
||||
echo "Backing up old configuration files"
|
||||
mkdir -p $olddir/$timestamp/$(dirname $file)
|
||||
mv ~/.$file $olddir/$timestamp/$file
|
||||
|
||||
echo "Creating symlink from homedir to $file."
|
||||
mkdir -p $(dirname ~/.$file)
|
||||
ln -s $dir/$file ~/.$file
|
||||
echo "Done."
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue