From e87bb703ef727fb24ce88bc67263d9d67d91c772 Mon Sep 17 00:00:00 2001 From: Mathieu Ablasou Date: Tue, 17 Nov 2020 01:44:30 +0100 Subject: Add support to specify the cursor position after the file Fixes #36 --- rc/connect/commands/:edit | 21 ++++++++++++++++++--- 1 file 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 -- cgit v1.2.3