summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fzy.14
-rw-r--r--fzy.c18
2 files changed, 16 insertions, 6 deletions
diff --git a/fzy.1 b/fzy.1
index a5b5024..0397755 100644
--- a/fzy.1
+++ b/fzy.1
@@ -21,6 +21,10 @@ heuristics for the best match.
How many lines of items to display. If unspecified, defaults to 10 lines.
.
.TP
+.BR \-p ", " \-\-prompt =\fIPROMPT\fR
+Input prompt (default: '> ')
+.
+.TP
.BR \-s ", " \-\-show-scores
Show the scores for each item.
.
diff --git a/fzy.c b/fzy.c
index a0b2b95..acb528d 100644
--- a/fzy.c
+++ b/fzy.c
@@ -16,6 +16,8 @@ int flag_show_scores = 0;
size_t num_lines = 10;
size_t scrolloff = 1;
+const char *prompt = "> ";
+
void read_choices(choices_t *c){
char *line = NULL;
size_t len = 0;
@@ -89,7 +91,6 @@ void draw(tty_t *tty, choices_t *choices){
start = choices_available(choices) - num_lines;
}
}
- const char *prompt = "> ";
tty_setcol(tty, 0);
tty_printf(tty, "%s%s", prompt, search);
tty_clearline(tty);
@@ -177,11 +178,12 @@ void run(tty_t *tty, choices_t *choices){
static const char *usage_str = ""
"Usage: fzy [OPTION]...\n"
" -l, --lines=LINES Specify how many lines of results to show (default 10)\n"
-" -e, --show-matches=QUERY output the sorted matches of QUERY\n"
+" -p, --prompt=PROMPT Input prompt (default '> ')\n"
+" -e, --show-matches=QUERY Output the sorted matches of QUERY\n"
" -t, --tty=TTY Specify file to use as TTY device (default /dev/tty)\n"
-" -s, --show-scores show the scores of each match\n"
-" -h, --help display this help and exit\n"
-" -v, --version output version information and exit\n";
+" -s, --show-scores Show the scores of each match\n"
+" -h, --help Display this help and exit\n"
+" -v, --version Output version information and exit\n";
void usage(const char *argv0){
fprintf(stderr, usage_str, argv0);
@@ -191,6 +193,7 @@ static struct option longopts[] = {
{ "show-matches", required_argument, NULL, 'e' },
{ "lines", required_argument, NULL, 'l' },
{ "tty", required_argument, NULL, 't' },
+ { "prompt", required_argument, NULL, 'p' },
{ "show-scores", no_argument, NULL, 's' },
{ "version", no_argument, NULL, 'v' },
{ "benchmark", no_argument, NULL, 'b' },
@@ -203,7 +206,7 @@ int main(int argc, char *argv[]){
char *initial_query = NULL;
char *tty_filename = "/dev/tty";
char c;
- while((c = getopt_long(argc, argv, "vhse:l:t:", longopts, NULL)) != -1){
+ while((c = getopt_long(argc, argv, "vhse:l:t:p:", longopts, NULL)) != -1){
switch(c){
case 'v':
printf("%s " VERSION " (c) 2014 John Hawthorn\n", argv[0]);
@@ -220,6 +223,9 @@ int main(int argc, char *argv[]){
case 't':
tty_filename = optarg;
break;
+ case 'p':
+ prompt = optarg;
+ break;
case 'l':
{
int l;