What's new in 3.4¶
hellish is now polish. 3.4 renames the shell everywhere a new user sees
it: the command, the config files, the POLISH_* settings and the
repository, which is now
Univers42/polish. Config modules
also no longer need the .hsh extension. An existing
hellish install keeps working without edits.
What came in 3.3 follows further down.
Get it
Already running hellish? Type update --now. Otherwise install it:
curl -fsSL https://raw.githubusercontent.com/Univers42/polish/main/install.sh | sh
Coming from hellish¶
update --now replaces the binary where it already is, so your login shell,
/etc/shells and $SHELL keep the hellish path. An updater from 3.3 or
earlier doesn't know the new name, so the binary it installs adds polish
beside hellish, as a symlink:
| Installed in | You get polish |
|---|---|
a directory you own (~/.local/bin) |
on your next login, silently, or when you type update |
a root-owned directory (/usr/bin) |
the banner says "no polish command — run update"; update asks before it runs sudo ln -s hellish /usr/bin/polish |
You can also run that sudo ln -s line yourself. An existing polish is
never replaced. Every old name is still read:
| You have | 3.4 reads | Rule |
|---|---|---|
~/.hellishrc |
it, unchanged | ~/.polishrc wins only once it exists |
~/.config/hellish/ |
it, unchanged | same rule for ~/.config/polish/ |
/etc/hellish/ |
it, unchanged | same rule for /etc/polish/ |
HELLISH_AUTOSUGGEST=1 and every other HELLISH_* |
it | POLISH_X wins when it is set, even to empty |
HELLISH_PRECMD_FUNCS, HELLISH_PREEXEC_FUNCS |
it | one prefix only, so a hook never runs twice |
$HELLISH_GIT_BRANCH and the other git prompt variables |
it | set under both prefixes |
script.hellish, script.hell |
run by polish | as are .polish, .hsh and .sh |
hellish -c "update --version" |
polish 3.4.1 |
Don't keep both ~/.hellishrc and ~/.polishrc. Only ~/.polishrc is read,
and the old file silently stops loading. To switch, rename it:
mv ~/.hellishrc ~/.polishrc.
What did not move: the history file, the npm package (hellish-shell, which
still installs a hellish command), and the container image names.
The banner¶
This is the table from the welcome banner, explained.
| Banner | Means |
|---|---|
.polishrc your config file |
~/.polishrc, read at every interactive start |
POLISH_* your settings |
POLISH_AUTOSUGGEST=1 and the rest, set in it or exported |
rc.d/*.sh loaded like .hsh |
a module may end in .sh, or have no extension |
Module names¶
In rc.d/, after.d/, plugins/ and themes/, polish loads:
| File | Loaded |
|---|---|
20-aliases.hsh, 20-aliases.sh |
yes, with bash rules |
20-aliases.zsh |
yes, with zsh rules |
20-aliases starting #!/usr/bin/env polish |
yes |
20-aliases starting #!/usr/bin/env hellish or #!/usr/local/bin/hellish |
yes |
README, notes.txt, 20-aliases~, .hidden |
no |
20-aliases starting #!/bin/bash |
no |
Modules load in name order, whatever their extension. A plugin's entry file
is plugin.hsh, else plugin.sh, else a plugin file with the shebang.
The files the installer seeds carry #!/usr/bin/env polish on line 1, or
hellish on a machine that has no polish command.
Every change since 3.3.0: v3.3.0...v3.4.0.
What came in 3.3¶
hellish 3.3 ranks by what you run, not by what you ran last. The dim hint and
make <TAB> put your most-run command first. This section shows how that
works and which settings change it. Every example in it was run on a 3.3
build. Under polish, spell the settings POLISH_*; the HELLISH_* names
below still work.
At a glance¶
This is the table from the welcome banner, explained.
| Keys | What it does | Needs |
|---|---|---|
make <TAB> |
most-run targets first | |
→ ^F End |
take the hint, now your most-run match | export POLISH_AUTOSUGGEST=1 |
Alt-N/P |
step through the matches in the same order | export POLISH_AUTOSUGGEST=1 |
Hints rank what you run most¶
With hints on, typing make used to show the newest line that starts with
it. It now shows the line you run most, weighted toward recent runs:
$ export HELLISH_AUTOSUGGEST=1
$ make re
$ make re
$ make re
$ make clean
$ make re
On the last line you typed make; re is the dim hint. Alt-N
moves to the next match, clean. A run's weight halves for every 64 newer
history lines, so a habit you dropped fades out.
Two settings change the order:
HELLISH_SUGGEST_STRATEGY=recentbrings back newest first: the history above hintsclean. It is read at every prompt.HISTCONTROL=ignoredupsorignorebothstores a back-to-back repeat once, so the threemake reabove count as one run and the hint isclean. Repeats with another command between them still count.
make targets you run first¶
make <TAB> still reads the Makefile itself and never runs make. Targets you
have run now come first, most-run first, and the rest follow alphabetically:
$ make <TAB><TAB>
re clean all fclean test
HELLISH_SUGGEST_STRATEGY=recent orders them newest first here too.
Fixed¶
In scripts:
- A
$(...)no longer stays as literal text when a double-quoted word inside it holds a nested substitution with an odd number of quote bytes.x=$(echo "$(echo "a'b")"); echo "[$x]"prints[a'b], as in bash (#190). - A
caseinside a double-quoted$(...)parses.x="$(case a in a) echo "q'r";; esac)"; echo "[$x]"prints[q'r](#191).
At the prompt:
- On a build linked against GNU readline 8.3, Ctrl-C inside Ctrl-R, Alt-P or Alt-X freed the search state twice. It now cancels the search and returns to a clean prompt (#194).
Every change since 3.2.0: v3.2.0...v3.3.0.
What came in 3.2¶
hellish 3.2 is about the prompt. The up arrow finds what you started typing.
A dim hint from your history can complete the line, and you take it with one
key. make <TAB> knows your targets, and bind puts a shell command on a
key. Every example in this section was run on a 3.2 build.
At a glance¶
This is the table from the welcome banner, explained.
| Keys | What it does | Needs |
|---|---|---|
↑ ↓ |
history by prefix | on by default |
make <TAB> |
Makefile targets | |
bind -x |
key runs a command | |
bindkey |
zsh binds now work | zsh mode |
${var@P} |
render as a prompt | |
$SRANDOM |
and $EPOCHREALTIME |
|
→ ^F End |
take the dim hint | HELLISH_AUTOSUGGEST=1 |
Alt-F |
take one word | HELLISH_AUTOSUGGEST=1 |
Alt-N/P |
older/newer hint | HELLISH_AUTOSUGGEST=1 |
History that matches what you typed¶
Type the start of a command, then press ↑. Up now steps only through history lines that begin with the text before the cursor, and ↓ steps back toward the newest one:
$ git<Up> -> git push the newest line starting with "git"
$ git<Up><Up> -> git status the one before it
On an empty line, Up and Down walk the whole history as before.
- It is on by default.
HELLISH_HISTORY_PREFIX=0(oroff) brings back plain Up/Down. The variable is read at every prompt, so you can change it in the middle of a session. - Configs that already asked for this now get it. That covers bash's
bind '"\e[A": history-search-backward', zsh'sbindkey '^[[A' history-beginning-search-backward, and oh-my-zsh'sup-line-or-beginning-search. Before 3.2, each of them left the arrow dead. - A key you bound yourself keeps your binding.
Inline hints¶
Hints are off until you ask for them. Add this line to ~/.hellishrc, or
type it at the prompt to try it:
export HELLISH_AUTOSUGGEST=1
From then on, when you type the start of a line you ran before, the rest of it appears dimmed after the cursor. The hint is the newest history line that starts with what you typed. It is not part of your line until you take it:
$ echo hello ran earlier
$ ech|o hello you typed "ech", the cursor is at |, "o hello" is dim
| Key | What it does |
|---|---|
| →, End or Ctrl-F | take the whole hint |
| Alt-F or Ctrl-→ | take its next word |
| Alt-N / Alt-P | show an older / a newer match instead |
| Enter | run only what you typed |
- With no hint on screen, these keys keep their usual job: Right moves the cursor, Alt-F moves a word, and Alt-N / Alt-P are readline's history search.
- A word is the hint's leading blanks plus the text up to the next space or tab.
- Cycling skips duplicates. It stops at either end with a bell instead of wrapping around. Any edit starts again from the newest match.
- Hints also work in vi insert mode.
- A history line that holds a newline or a control character is never
offered. A terminal that cannot move the cursor (
TERMunset ordumb) never shows a hint. HELLISH_SUGGEST_MAX=Nsets how many of the newest history lines are searched (default 1000).- In zsh mode, widgets see the hint as
POSTDISPLAY, and can set their own.
Completing make targets¶
Tab after make offers the targets of the Makefile in the
current directory. With this Makefile:
.PHONY: all clean fclean re
NAME = demo
all: $(NAME)
$(NAME): main.o
cc -o $@ $^
%.o: %.c
cc -c $<
clean:
rm -f *.o
fclean: clean
rm -f $(NAME)
re: fclean all
$ make <TAB><TAB>
all clean fclean re
$ make fc<TAB>
$ make fclean
The variable, the pattern rule, $(NAME) and .PHONY are not targets you
would type, so they are not offered.
- The shell reads the file itself;
makeis never run. It reads the first ofGNUmakefile,makefileandMakefile(the order GNU make uses). - It also works for
gmakeand/usr/bin/make, and aftersudo,env X=1,&&or(. includelines are followed one level deep. If you change only an included file, the list is not refreshed: touch the Makefile.- With no Makefile, Tab completes file names as usual.
The full rules are in the manual's make targets section.
Key bindings with bind¶
hellish now has bash's bind builtin, so the lines you would put in
~/.inputrc work in ~/.hellishrc:
bind '"\e[A": history-search-backward' # a key -> a readline command
bind 'set completion-ignore-case on' # a readline setting
bind -x '"\C-t": date' # a key -> a shell command
bind -x runs the command the way bash does. It can read and change the
line you are editing through READLINE_LINE and READLINE_POINT (the
cursor). This key puts sudo in front of the line and leaves the cursor at
the end:
bind -x '"\C-xs": READLINE_LINE="sudo $READLINE_LINE"; READLINE_POINT=${#READLINE_LINE}'
$ apt update<Ctrl-X s>
$ sudo apt update
To see what is bound: bind -p lists key bindings, bind -v the settings,
bind -X the -x commands and bind -l every command name. help bind
shows every option.
bindkey in zsh configs¶
In zsh mode (set -o zsh, emulate zsh, or a sourced .zsh file),
bindkey now understands zsh's key notation (^[[A, ^R, ^[b, \E)
and reaches the line editor's own widgets. These two lines from a zsh
config now do what they say:
bindkey '^[[A' history-beginning-search-backward
bindkey '^[[B' history-beginning-search-forward
Rendering text like the prompt¶
${var@P} expands a value the way the prompt does. It uses the same
renderer as PS1, so the result always matches your prompt:
$ USER=ada; PS1='\u in \W \$ '; cd /usr/share
$ echo "${PS1@P}"
ada in share $
Both escape languages work, bash's \u \w and zsh's %n %~. prompt
preview uses it to draw the themes.
Two new variables¶
$ echo $SRANDOM
2414656789
$ echo $EPOCHREALTIME
1792288722.298309
$SRANDOM is a 32-bit random number, a new one each time you read it.
$EPOCHREALTIME is the time in seconds since the epoch, with microseconds.
Both come from bash: $EPOCHREALTIME from 5.0, $SRANDOM from 5.1.
Fixed¶
At the prompt:
- On some builds, the hint keys did nothing and Up did not search by prefix: the keys kept their stock behaviour. They now work on every build.
- Two small memory leaks in line editing are fixed. One came from walking history with Up or Ctrl-P and then pressing Enter or Ctrl-C; the other from cancelling an Alt-P search.
- In zsh mode, pressing Esc twice (oh-my-zsh's
sudoplugin) printedbuiltin: which: not a shell builtin.which [-ap] namenow exists in zsh mode. PS2is the prompt of every continuation line.- A Ctrl-C at the wrong moment no longer eats the next key.
In scripts:
exec nosuchno longer crashes the shell.- A runtime error names the line it happened on, and a command that cannot run says why, in bash's words and with bash's exit status.
readassigns its variables at end of input, and never a readonly one.- A quoted
"$@"element is never expanded as a glob pattern. export XbeforeXis set keeps the export.- Heredocs work inside function bodies,
evalandsource.
Installing and building:
- The
curl … | shinstaller prints the completePATHinstruction (#164). make reno longer stops on NFS when a hellish frombuild/is still running.
Every change since 3.1.3: v3.1.3...v3.2.0.