aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.bashrc_third_party
blob: cddbb6c3ad49f1b12c614d7d6b06a299f96dd495 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
[ ! -z "${BASHRC_THIRD_PARTY+x}" ] && return || readonly BASHRC_THIRD_PARTY=1

ensure_symlinks_enabled() {
  [ -z "${CYGWIN+x}" ] && return 1

  case "$CYGWIN" in
    *winsymlinks:native*)       ;;
    *winsymlinks:nativestrict*) ;;

    *)
      return 1
      ;;
  esac
}

symlink_preferences() (
  if ! ensure_symlinks_enabled; then
    echo "$FUNCNAME: it seems like native Windows symlinks aren't enabled in Cygwin." >&2
    return 1
  fi

  set -o errexit

  if [ "$#" -ne 2 ]; then
    echo "usage: $FUNCNAME SRC_DIR DEST_DIR" >&2
    return 1
  fi

  local src_dir="$1"
  local dest_dir="$2"

  [ -d "$dest_dir" ] || mkdir -p "$dest_dir"

  find "$src_dir" -maxdepth 1 -type f -exec ln --force -s {} "$dest_dir" \;
)

symlink_sublime_preferences() {
  symlink_preferences "$HOME/.Sublime Text 3" "$APPDATA/Sublime Text 3/Packages/User"
}

symlink_ghc_preferences() {
  symlink_preferences "$HOME/.GHC" "$APPDATA/ghc"
}