Blob


1 #!/bin/sh
3 old_path="$HOME/.telescope"
5 Die() {
6 printf 'error: %s\n' "$1" 1>&2
7 exit 1
8 }
10 [ -e "$old_path" ] || Die "$old_path does not exist."
11 [ -d "$old_path" ] || Die "$old_path is not a directory."
13 xdg_config="${XDG_CONFIG_HOME:-$HOME/.config}/telescope"
14 xdg_data="${XDG_DATA_HOME:-$HOME/.local/share}/telescope"
15 xdg_cache="${XDG_CACHE_HOME:-$HOME/.cache}/telescope"
17 mkdir -p "$xdg_config" "$xdg_data" "$xdg_cache"
19 for filepath in \
20 "$xdg_config/config" \
21 "$xdg_data/pages" \
22 "$xdg_data/bookmarks.gmi" \
23 "$xdg_data/known_hosts"
24 do
25 old_file="$old_path/${filepath##*/}"
26 [ -e "$old_file" ] && cp -R "$old_file" "filepath"
27 done
29 printf "\
30 WARNING: the old ~/.telescope directory will be removed.
32 Every file/directory other than the followings has not been copyied:
33 - config
34 - bookmarks.gmi
35 - known_hosts
36 - pages/
38 Are you sure? [Y/n] "
40 read -r reply
41 case $reply in
42 [yY]) rm -r "$old_path" && printf 'done\n' ;;
43 esac