aboutsummaryrefslogtreecommitdiff
path: root/functions/funclnk.fish
blob: 10eadb06fdca40382fa6af7dc4d642faaa511397 (plain)
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
function funclnk --description "Synchronise fish script symlinks"

function _link_fish_scripts -a scriptpath

  if test (count $argv) -lt 1
    return 1
  end

  set -f configdir "$HOME/Config"
  set -f fishfuncdir "$__fish_config_dir/functions"

  for script in (find $configdir -type f -path $scriptpath -name "*.fish")
    set -l basescriptname (path basename $script)

    if test -e "$fishfuncdir/$basescriptname"
      continue
    end

    if ask "Add a symlink to $basescriptname to fish profile?"
      pushd $fishfuncdir
        ln -s (realpath --relative-to=. $script)
      popd
    end
  end

  return 0
end

_link_fish_scripts '*/.config/fish/conf.d/*'
_link_fish_scripts '*/.config/fish/functions/*'

functions -e _link_fish_scripts

end