diff options
| author | Mathieu Ablasou <alexherbo2@gmail.com> | 2020-11-17 01:44:30 +0100 |
|---|---|---|
| committer | Mathieu Ablasou <alexherbo2@gmail.com> | 2020-11-17 01:44:30 +0100 |
| commit | e87bb703ef727fb24ce88bc67263d9d67d91c772 (patch) | |
| tree | 75eec1d666cc3e2a0ea945164f175945215b51d8 | |
| parent | 932509070acb9787b2ce5c85e1727a35491ce675 (diff) | |
Add support to specify the cursor position after the file
Fixes #36
| -rwxr-xr-x | rc/connect/commands/:edit | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/rc/connect/commands/:edit b/rc/connect/commands/:edit index 949a3be..45708f2 100755 --- a/rc/connect/commands/:edit +++ b/rc/connect/commands/:edit @@ -24,7 +24,7 @@ fi # Skip options [ "$1" = '--' ] && shift -# Open files at the given position (line and column) if specified. +# Open files at the given position (line and column) if specified (before or after the file). commands=$( while [ "$1" ]; do case "$1" in @@ -43,8 +43,23 @@ commands=$( ;; (*) file=$(realpath "$1") - shift 1 - kak_escape edit "$file" + 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 |
