diff options
author | Tristan Williams <tgwil@tgwil.net> | 2024-10-13 12:55:01 -0400 |
---|---|---|
committer | Tristan Williams <tgwil@tgwil.net> | 2024-10-13 12:55:01 -0400 |
commit | d0615d3c88f4520d9d97602c2fa5e3fb900b54f8 (patch) | |
tree | 8077f5b25c4e5d69226d4775930c91f4f1123fab | |
parent | Make messages from installer consistent and pleasing (diff) | |
download | dotfiles.core-d0615d3c88f4520d9d97602c2fa5e3fb900b54f8.tar.gz dotfiles.core-d0615d3c88f4520d9d97602c2fa5e3fb900b54f8.tar.bz2 dotfiles.core-d0615d3c88f4520d9d97602c2fa5e3fb900b54f8.zip |
Give user options for directories similar to files
-rwxr-xr-x | new-user-setup.sh | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/new-user-setup.sh b/new-user-setup.sh index 7b8dbe1..072404b 100755 --- a/new-user-setup.sh +++ b/new-user-setup.sh | |||
@@ -47,7 +47,6 @@ echo "### Starting dotfiles.core installation... ###" | |||
47 | ######################################################################## | 47 | ######################################################################## |
48 | ## Put files into place | 48 | ## Put files into place |
49 | ######################################################################## | 49 | ######################################################################## |
50 | |||
51 | # File placement function | 50 | # File placement function |
52 | place_file () { | 51 | place_file () { |
53 | file=$1 | 52 | file=$1 |
@@ -98,12 +97,48 @@ place_file () { | |||
98 | 97 | ||
99 | # Directory placement function | 98 | # Directory placement function |
100 | place_directory () { | 99 | place_directory () { |
101 | directory=$1 | 100 | target=$1 |
102 | if [[ -d $directory ]]; then | 101 | if [[ -d $target ]]; then |
103 | echo -e "${YELLOW}Skipped: Dir : ${directory}${ENDCOLOR}" | 102 | echo -e \ |
103 | "${WARN}WARNING: Dir : ${target} already exists!" \ | ||
104 | "[A]bort, [D]elete, [R]eplace, [S]kip: ${ENDCOLOR}" | ||
105 | invalid_selection=0 | ||
106 | while | ||
107 | # The following echo fixes read's annoying newline that | ||
108 | # messes up my nice script formatting. It sends cursor back | ||
109 | # to the "target already exists" line. | ||
110 | # \033[1A moves up to previous line. | ||
111 | # \033[1000C moves to the last column in the line up to 1000. | ||
112 | echo -en "\033[1A\033[1000C" | ||
113 | read -n1 selection | ||
114 | case $selection in | ||
115 | "a"|"A") | ||
116 | echo "INFO : Abort!" | ||
117 | exit 0;; | ||
118 | "d"|"D") | ||
119 | rm -rf $target | ||
120 | echo -e "${YELLOW}Removed: Dir : ${target}${ENDCOLOR}" | ||
121 | mkdir -p $target | ||
122 | echo -e "${GREEN}Created: Dir : ${target}${ENDCOLOR}" | ||
123 | return 0;; | ||
124 | "r"|"R") | ||
125 | mv -f $target $target.bak | ||
126 | echo -e "${YELLOW}Moved : Dir : ${target} to ${target}.bak${ENDCOLOR}" | ||
127 | mkdir -p $target | ||
128 | echo -e "${GREEN}Created: Dir : ${target}${ENDCOLOR}" | ||
129 | return 0;; | ||
130 | "s"|"S") | ||
131 | echo -e "${YELLOW}Skipped: Dir : ${target}${ENDCOLOR}" | ||
132 | return 0;; | ||
133 | *) | ||
134 | echo -e "${WARN}ERROR : Invalid selection, try again...${ENDCOLOR}" | ||
135 | invalid_selection=1;; | ||
136 | esac | ||
137 | [[ $invalid_selection==1 ]] | ||
138 | do true; done | ||
104 | else | 139 | else |
105 | mkdir -p $directory | 140 | mkdir -p $target |
106 | echo -e "${GREEN}Created: Dir : ${directory}${ENDCOLOR}" | 141 | echo -e "${GREEN}Created: Dir : ${target}${ENDCOLOR}" |
107 | fi | 142 | fi |
108 | } | 143 | } |
109 | 144 | ||