From d09942d575d1a1a1452af447766f0d6d5cb578e7 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 9 Jan 2019 09:32:11 -0500 Subject: [PATCH] fixed a minor bug in picktag and added a new shortcut for filename/filepath completion using the picker --- TODO.md | 1 - bin/fcomplete | 6 ++++++ bin/picktag | 4 +++- config.h | 1 + src/tide.c | 32 ++++++++++++++++++++------------ 5 files changed, 30 insertions(+), 14 deletions(-) create mode 100755 bin/fcomplete diff --git a/TODO.md b/TODO.md index 210eed7..86a7808 100644 --- a/TODO.md +++ b/TODO.md @@ -9,7 +9,6 @@ * registrar: should remove invalid windows from registry when detected * tide: Ctrl+D should not pass tag name as arg when executing tag commands * tide: gap buffer does not handle UTF-8 currently -* filename/path completion shortcut * pick can return null if mouse clicked on empty row ## BACKLOG diff --git a/bin/fcomplete b/bin/fcomplete new file mode 100755 index 0000000..2575387 --- /dev/null +++ b/bin/fcomplete @@ -0,0 +1,6 @@ +#!/bin/sh +orig="$1" +path="${orig%/*}" +file="${orig##*/}" +[ "$path" == "$file" ] && path="." +printf "%s" "$(find "$path" -path "$path/$file*" | pick "$path/$file")" diff --git a/bin/picktag b/bin/picktag index 1508e9e..73d41c2 100755 --- a/bin/picktag +++ b/bin/picktag @@ -21,7 +21,9 @@ printtags(){ } print(){ - printf "%s" "$(printtags | pick "$TAG")" + tag="$(printtags | pick "$TAG")" + [ "" == "$tag" ] && tag="$TAG" + printf "%s" "$tag" } fetch(){ diff --git a/config.h b/config.h index 9dfd6a5..08ed519 100644 --- a/config.h +++ b/config.h @@ -15,6 +15,7 @@ enum { /* Color Names */ #define CMD_TIDE "!tide" #define CMD_PICKFILE "!pickfile ." #define CMD_COMPLETE "