setup 818 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # relpath
  3. script_dir="$( dirname "${BASH_SOURCE[0]}" )"
  4. source ${script_dir}/../bash/functions
  5. link_path="$HOME/.screenrc"
  6. target_name="screenrc"
  7. target_path="$( relpath "${script_dir}/${target_name}" "$(dirname "${link_path}")" )"
  8. # equals false for broken symlinks
  9. if [ -e "${link_path}" ]; then
  10. # empty of link_path is not a link
  11. current_target="$(readlink "${link_path}")"
  12. if [ "$current_target" != "$target_path" ]; then
  13. mv --backup=numbered "$link_path" "${link_path}.old"
  14. fi
  15. fi
  16. if [ -e "${link_path}" ]; then
  17. echo "sym link to '$target_path' already installed at '$link_path'"
  18. else
  19. # delete possibly existing broken symlink
  20. rm "$link_path" 2>/dev/null
  21. ln -s "$target_path" "$link_path"
  22. echo "installed sym link to '$target_path' at '$link_path'"
  23. fi