WIP: Script to automatically link files

Takes the source path from PWD and the symlink path and creates them
all. Not tested, just building list.
This commit is contained in:
John Mertz 2023-04-26 22:54:58 -04:00
parent 68ada8a315
commit 659c8efaca
1 changed files with 32 additions and 0 deletions

32
symlink.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
# <relative location to $PWD>:<absolute path of link>
# '~' will be expanded to $HOME
LINKS="
alacritty/alacritty.yml:~/alacritty.yml
bash/bashrc:~/.bashrc
bash/bash_login:~/.bash_login
bash/bash_logout:~/.bash_logout
bash/bash_profile:~/.bash_profile
nvim:~/.config/nvim
vim/vimrc:~/.vimrc
fonts:~/.fonts
icons:~/.icons
"
SUDO="
"
for i in $LINKS; do
DEST=$PWD/$(echo "${i}" | cut -d: -f1)
LINK=$(echo "$i" | cut -d: -f2 | sed -E "s#~#$HOME#")
CMD="ln -s $DEST $LINK"
eval "$CMD"
done
for i in $SUDO; do
DEST=$PWD/$(echo "${i}" | cut -d: -f1)
LINK=$(echo "$i" | cut -d: -f2 | sed -E "s#~#$HOME#")
CMD="sudo ln -s $DEST $LINK"
eval "$CMD"
done