blob: 45708f2eedaf6e42d0234c97895f5f94ac58ef07 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#!/bin/sh
# Open files.
#
# Usage:
#
# :edit <file>
# :edit +<line> <file>
# :edit +<line>:<column> <file>
# [files] | :edit
#
# Note: Order matters.
. "$KAKOUNE_PRELUDE"
# Read files from stdin when a terminal is available.
# Reason: kak-desktop
if [ ! -t 0 -a -t 1 ]; then
while read file; do
set -- "$file" "$@"
done
fi
# Skip options
[ "$1" = '--' ] && shift
# Open files at the given position (line and column) if specified (before or after the file).
commands=$(
while [ "$1" ]; do
case "$1" in
('+'*':'*)
line=${1#+}; line=${line%:*}
column=${1#*:}
file=$(realpath "$2")
shift 2
kak_escape edit "$file" "$line" "$column"
;;
('+'*)
line=${1#+}
file=$(realpath "$2")
shift 2
kak_escape edit "$file" "$line"
;;
(*)
file=$(realpath "$1")
shift
case "$1" in
('+'*':'*)
line=${1#+}; line=${line%:*}
column=${1#*:}
shift
kak_escape edit "$file" "$line" "$column"
;;
('+'*)
line=${1#+}
shift
kak_escape edit "$file" "$line"
;;
(*)
kak_escape edit "$file"
;;
esac
;;
esac
done
)
:send "$commands"
# Focus back the client
:send focus
|