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
|
## What is this?
Basta! is a small amount of GNU Bash code that maintains a
scroll-protected status line at the bottom of the terminal.
The status line shows the date, host name and current directory
(possibly abbreviated to fit).
This allows you to have very simple prompt:
::text
PS1='\$ '
To use the code put the `basta.sh` file somewhere. Perhaps,
turn it into a dot file in your home directory, under
the name`~/.basta` Then, then source this file from some startup script, for
instance by adding this line to `~/.bashrc`:
::text
. ~/.basta.sh
This requires Bash 4.4 or higher.
## Reloading
Basta supports hot reloading: if you make some changes to the
code or fetch a minor update, you can just source the file again.
::text
. /path/to/basta.sh
However, if you're updating from a very old version to a much newer one,
here is how to perfrm a deeper reload (assuming your `~/.bashrc` sources the
Basta code):
::text
basta.cleanup; exec bash -l
I.e. run the Basta cleanup code explicitly and re-execute the
login shell. The cleanup code is hooked to the `EXIT` trap,
but that doesn't execute on exec.
## Temporarily Disabling
Basta executes code for every new prompt, and when the signals SIGALRM
and SIGWINCH are received. This activity can be a nuisance if you're debugging
something else running in the same shell, particularly if you turn on `set -x`
tracing.
To get Basta temporarily out of the way run the command `basta.remove_hooks`.
All that activity will stop; Basta will not update the display.
To re-enable the activity, execute `basta.install_hooks`.
## Screenshot
![Screenshot of Basta](screenshot.png)
The clock actually updates. The code launches a background
process which periodically the SIGALRM signal to the shell,
whose trap calls the `basta.update_status` function.
Here is another screenshot showing nested interactive shells,
each taking up its own Basta! status line. The lines
disappear one by one when the shells are exited.
![Screenshot of Nested Basta](screenshot-nested.png)
## License
This is under distributed under a modified two-clause BSD license.
See the license block at the bottom of the file.
The second clause says that any binary code (as if that would
exist for shell customization code, ha!) is not required to
carry any copyright notice.
|