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. Small change to ln argument semantics: for 2 arguments,
10 the second is the link, never a directory to put the link in.
11 LN_ARGUMENTS are passed to ln -s --, meaning no ln option arguments are supported."
12 if [[ $1 == --help ]]; then
18 if type -P dircolors
>/dev
/null
; then
24 if [[ $# -ge 3 ]]; then
25 if [[ -d ${!#} ]]; then
28 for x
in "${@:1:$(($#-1))}"; do # all but last arg
29 # remove any trailing slashes
31 # remove any leading directory components
33 [[ -e "$x" ||
-L "$x" ]] && $remove "$x"
39 elif [[ $# -eq 2 ]]; then
40 if [[ -e "$2" ||
-L "$2" ]]; then
42 elif [[ ! -d "$2/.." ]]; then
45 elif [[ $# -eq 1 ]]; then
46 [[ -e "${1##*/}" || -L "${1##*/}" ]] && $remove "${1##*/}"