From 659c8efaca9b949077c671f8f7c5b16a736d165d Mon Sep 17 00:00:00 2001 From: John Mertz Date: Wed, 26 Apr 2023 22:54:58 -0400 Subject: [PATCH] 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. --- symlink.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 symlink.sh diff --git a/symlink.sh b/symlink.sh new file mode 100755 index 000000000..36f1133d5 --- /dev/null +++ b/symlink.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# : +# '~' 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