setup 691 B

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