Created
December 7, 2022 11:49
-
-
Save Fraasi/50e23910c613045e7f720ec781d374d3 to your computer and use it in GitHub Desktop.
my old git-bash symlink function from my dotfiles install.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
make_symlinks() { | |
log_info "This needs to be run as administrator for symlinking to work in git-bash" | |
log_info "Creating symlinks..." | |
# cygpath converts posix <-> win paths | |
local home_win=$(cygpath -aw "$HOME") | |
local repo_win=$(cygpath -aw ./) | |
# make sure ~/bin & ~/hooks exists | |
mkdir ~/bin ~/hooks >/dev/null 2>&1 | |
for file in $bin_files $home_files $hook_files; do | |
local filename=$(basename "$file") | |
local link_exists=$(find ~/ ~/bin/ ~/hooks -maxdepth 1 -type l -name "$filename") | |
if [[ -z $link_exists ]]; then | |
case "$file" in | |
*bin*) | |
cmd.exe /c "mklink $home_win\\bin\\$filename $repo_win\\bin\\$filename" | |
;; | |
*HOME*) | |
cmd.exe /c "mklink $home_win\\$filename $repo_win\\HOME\\$filename" | |
;; | |
*hooks*) | |
cmd.exe /c "mklink $home_win\\hooks\\$filename $repo_win\\hooks\\$filename" | |
;; | |
esac | |
fi | |
done | |
log_success "${FUNCNAME[@]}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment