-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.adoc.m4
95 lines (70 loc) · 2.3 KB
/
README.adoc.m4
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
Readline-based command line utility for shell scripting
It is a simple C program that allows you to easily integrate readline
into your shell scripts and shell functions.
== Usage:
----
$ readline -d message.txt -p "Enter message: " -H history
Enter message: Hello
$ cat message.txt
Hello
$ cat history
Hello
----
When you run +readline+ again, "Hello" will be in the history.
----
$ readline -h
readlinesh usage: readline <options...>
-d <destination> -- Where to write the line (default stdout)
-H <history> -- History file (default ~/.readline-history)
-p <prompt> -- The prompt (default "> ")
The line is written to history even on Ctrl-C.
Use Ctrl-D on a blank line to cancel and skip writing to history.
----
== Git-based example
Here is an example of using +readline+ to input your Git commit messages with history and without loading your editor. Put this shell function in your shell startup scripts:
----m4_include(examples/git-commit.sh)----
Then you can do:
----
$ ls
... directory ...
$ git status
... git information ...
$ gm myfile.c
Enter commit message: This is my change to myfile.c
----
You have full-featured line editing and history without losing your view of the previous output. If you cancel +gm+ with Ctrl+C or Ctrl+D it will exit cleanly without running +git commit+.
== Installation
Be sure you have the libreadline and libhistory development packages for your system. On Debian and Ubuntu this is APT package +libreadline-dev+. Then do:
----
$ git clone https://github.com/jmjwozniak/readlinesh.git
$ cd readlinesh
$ ./autogen.sh
$ ./configure --prefix=$HOME/readlinesh
$ make install
# Test:
$ $HOME/readlinesh/bin/readline
----
=== Non-standard libreadline locations
If you have libreadline/libhistory in a non-standard location, such as a from-source installation or an Anaconda environment, use something like:
==== Anaconda
This pattern works for Linux or Mac.
----
$ C=$HOME/path/to/conda"
$ export CFLAGS="-I$C/include"
$ export LDFLAGS="-L$C/lib -Wl,-rpath -Wl,$C/lib"
$ export LIBS="-lhistory"
$ ./configure --prefix=...
$ make install
----
==== Mac Homebrew
----
$ C=/usr/local/opt/readline
$ export CFLAGS="-I$C/include"
$ export LDFLAGS="-L$C/lib"
$ export LIBS="-lhistory"
$ ./configure --prefix=...
$ make install
----
m4_dnl Local Variables:
m4_dnl mode: text;
m4_dnl End: