fa9b59937108e5b6514cd983d629c3d4f8bfc34b
2 # Copyright (C) 2014 Ian Kelling
3 # This program is under GPL v. 3 or later, see <http://www.gnu.org/licenses/>
6 local help="lnf [--help] LN_ARGUMENTS...
7 Create symlinks conveniently and forcefully.
8 Remove existing file/links using trash-put or rm -rf if it is not available.
9 Create directory if needed. Finally, ln -s -- LN_ARGUMENTS"
10 if [[ $1 == --help ]]; then
16 if type -P dircolors
>/dev
/null
; then
22 if [[ $# -ge 3 && ! -d ${!#} ]]; then
24 elif [[ $# -ge 2 && -d ${!#} ]]; then
27 for x
in "${@:1:$(($#-1))}"; do # all but last arg
28 # remove any trailing slashes
30 # remove any leading directory components
32 [[ -e "$x" ||
-L "$x" ]] && $remove "$x"
35 elif [[ $# -eq 2 ]]; then
36 if [[ -e "$2" ||
-L "$2" ]]; then
38 elif [[ ! -d "$2/.." ]]; then
41 elif [[ $# -eq 1 ]]; then
42 [[ -e "${1##*/}" || -L "${1##*/}" ]] && $remove "${1##*/}"