commit b4f0b6902c32368b3cd3b73edc3e1f5a5c1373b3 parent 7e6a614e3fd90477ffbf97bc388b1fe34640bb9f Author: Alex Balgavy <a.balgavy@gmail.com> Date: Sun, 2 Sep 2018 20:21:56 +0200 Moved linkdir to a separate file, too big for profile Diffstat:
A | dotfiles/bin/linkdir | | | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
M | dotfiles/commonprofile | | | 43 | ------------------------------------------- |
2 files changed, 44 insertions(+), 43 deletions(-)
diff --git a/dotfiles/bin/linkdir b/dotfiles/bin/linkdir @@ -0,0 +1,44 @@ +#!/bin/bash +if [ $# -eq 0 ]; then + echo "Needs at least one argument (the source directory)." + echo "Usage: linkdir source_directory [target_directory]" + exit 1 +fi +if [[ "$1" != */ ]]; then + source_dir="${1}/" +else + source_dir="$1" +fi + +target_dir="./" + +if [ $# -ge 2 ]; then + if [[ "$2" != */ ]]; then + target_dir="${2}/" + else + target_dir="$2" + fi +fi + +echo "Linking content of $source_dir to $target_dir..." + +cr=0 +ca=0 + +for f in ${source_dir}*; do + if [ -L "${target_dir}${f##*/}" ]; then + rm "${target_dir}${f##*/}" + ((cr++)) + fi + + ln -s "$f" "${target_dir}${f##*/}" + echo "'$f' -> '${target_dir}${f##*/}'" + ((ca++)) + +done + +for i in "$source_dir"*; do +done +echo "Removed $cr local symlinks with originals in $source_dir." +echo "Linked $ca directories into $target_dir." +unset cr ca source_dir target_dir diff --git a/dotfiles/commonprofile b/dotfiles/commonprofile @@ -190,50 +190,7 @@ unalias() { unset p done } -linkdir() { - if [ $# -eq 0 ]; then - echo "Needs an argument (the source directory)." - else - if [[ "$1" != */ ]]; then - source_dir="${1}/" - else - source_dir="$1" - fi - - target_dir="./" - - if [ $# -ge 2 ]; then - if [[ "$2" != */ ]]; then - target_dir="${2}/" - else - target_dir="$2" - fi - fi - echo "Linking content of $source_dir to $target_dir..." - - cr=0 - ca=0 - - for f in ${source_dir}*; do - if [ -L "${target_dir}${f##*/}" ]; then - rm "${target_dir}${f##*/}" - ((cr++)) - fi - - ln -s "$f" "${target_dir}${f##*/}" - echo "'$f' -> '${target_dir}${f##*/}'" - ((ca++)) - - done - - for i in "$source_dir"*; do - done - echo "Removed $cr local symlinks with originals in $source_dir." - echo "Linked $ca directories into $target_dir." - unset cr ca source_dir target_dir - fi -} ###################### ### PATH CHANGES ###