No such widget `previous-history` - terminal

I'm setting up a new environment and seem to be experiencing an issue either with SBT or my shell on Linux where hitting the Up arrow instead of showing my previously run command, it says:
No such widget `previous-history`
I'm using ZSH as the shell, but I'm not seeing this problem anywhere else, including sbt console. I assumed there was a bindkey configured that was causing this, but I can't seem to find anything set. This also happens in Bash.
Here is the output I see from zsh --sourcetrace:
+/etc/zshenv:1> <sourcetrace>
+/etc/zshrc:1> <sourcetrace>
+/home/mhicks/.zshrc:1> <sourcetrace>
+/home/mhicks/.cache/p10k-instant-prompt-mhicks.zsh:1> <sourcetrace>
[WARNING]: Console output during zsh initialization detected.
When using Powerlevel10k with instant prompt, console output during zsh
initialization may indicate issues.
You can:
- Recommended: Change ~/.zshrc so that it does not perform console I/O
after the instant prompt preamble. See the link below for details.
* You will not see this error message again.
* Zsh will start quickly and prompt will update smoothly.
- Suppress this warning either by running p10k configure or by manually
defining the following parameter:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
* You will not see this error message again.
* Zsh will start quickly but prompt will jump down after initialization.
- Disable instant prompt either by running p10k configure or by manually
defining the following parameter:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
* You will not see this error message again.
* Zsh will start slowly.
- Do nothing.
* You will see this error message every time you start zsh.
* Zsh will start quickly but prompt will jump down after initialization.
For details, see:
https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt
-- console output produced during zsh initialization follows --
+/home/mhicks/.oh-my-zsh/custom/themes/powerlevel10k/gitstatus/gitstatus.plugin.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/oh-my-zsh.sh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/tools/check_for_upgrade.sh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/cache/.zsh-update:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/compfix.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/bzr.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/clipboard.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/cli.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/compfix.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/completion.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/correction.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/diagnostics.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/directories.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/functions.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/git.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/grep.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/cache/grep-alias:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/history.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/key-bindings.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/misc.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/nvm.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/prompt_info_functions.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/spectrum.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/termsupport.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/lib/theme-and-appearance.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/plugins/git/git.plugin.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/custom/example.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/custom/themes/powerlevel10k/powerlevel10k.zsh-theme:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/custom/themes/powerlevel10k/internal/p10k.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/custom/themes/powerlevel10k/internal/configure.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/custom/themes/powerlevel10k/internal/worker.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/custom/themes/powerlevel10k/internal/parser.zsh:1> <sourcetrace>
+/home/mhicks/.oh-my-zsh/custom/themes/powerlevel10k/internal/icons.zsh:1> <sourcetrace>
+/home/mhicks/.sdkman/bin/sdkman-init.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/etc/config:1> <sourcetrace>
+/home/mhicks/.sdkman/etc/config:1> <sourcetrace>
+/home/mhicks/.sdkman/etc/config:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-version.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-update.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-config.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-help.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-cache.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-broadcast.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-install.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-availability.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-upgrade.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-env-helpers.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-utils.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-uninstall.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-offline.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-use.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-selfupdate.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-list.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-current.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-main.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-home.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-default.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-env.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-flush.sh:1> <sourcetrace>
+/home/mhicks/.sdkman/src/sdkman-path-helpers.sh:1> <sourcetrace>
+/home/mhicks/.nvm/nvm.sh:1> <sourcetrace>
+/home/mhicks/.nvm/bash_completion:1> <sourcetrace>
+/home/mhicks/.zcompdump:1> <sourcetrace>
+/home/mhicks/.p10k.zsh:1> <sourcetrace>
EDIT: Confirmed, this does happen in Bash, so I figured wiping my user directory completely and starting over might fix it. Alas, it would seem something I'm doing is causing this to persist, or it's some sort of service running. I created a new home directory, installed ohmyzsh, configured powerlevel10k, installed sdkman, installed SBT, installed Java, and then verified this is still happening.

The output you're seeing in Zsh means that you ↑ key is bound to a non-existing widget. You can very this as follows:
Type bindkey '.
Press ControlV.
Press ↑.
Type ' and press Enter.
You should now see one of the following two cases in your terminal (with % being the prompt):
% bindkey '^[[A'
bindkey '^[[A' previous-history
%
% bindkey '^[OA'
bindkey '^[OA' previous-history
%
Although there is a readline commands called previous-history, there is no widget by that name in Zsh. You apparently somewhere in your dotfiles have code that tries to bind ↑ to previous-history, but fails to actually create the previous-history widget. Perhaps you are trying to use bash code in your zsh dotfiles?
Whatever the case, you can fix this by adding one of the following snippets to your .zshrc
bindkey -d # Delete existing keymaps and reset to default state.
bindkey '^[[A' up-line-or-search
bindkey '^[[B' down-line-or-search
bindkey '^[OA' up-line-or-search
bindkey '^[OB' down-line-or-search

Related

Changing PS1 with conda

I want to change my prompt from ~ $ to ~ > when activating conda.
I tried using env_prompt: in .condarc but it displays > ~ $ instead of the desired ~ > prompt.
(The conda prompt is preceded by the original PS1)
Can someone provide an example on how to implement this in my .bashrc?
Conda's changeps1 functionality is limited to prepending a string to the shell's PS1. This string can be specified using the configuration variable env_prompt (as OP indicates). For completeness, here is how to query the documentation:
env_prompt
$ conda config --describe env_prompt
# # env_prompt (str)
# # Template for prompt modification based on the active environment.
# # Currently supported template variables are '{prefix}', '{name}', and
# # '{default_env}'. '{prefix}' is the absolute path to the active
# # environment. '{name}' is the basename of the active environment
# # prefix. '{default_env}' holds the value of '{name}' if the active
# # environment is a conda named environment ('-n' flag), or otherwise
# # holds the value of '{prefix}'. Templating uses python's str.format()
# # method.
# #
# env_prompt: '({default_env}) '
To customize other aspects of PS1, one must do this independently of Conda. That is, you will need to consult the documentation for your shell (e.g., bash, zsh) or terminal.

rxvt-unicode does not accept Ctrl-F to move the cursor to next letter for Bash and GNU readline and other shells

Am using i3 window manager, rxvt-unicode 9.26, bash 5.1.16, and yash 2.52.
Already on set -o emacs mode.
Using ~/.Xresources file:
!! ~/.Xresources
!!
!! rxvt-unicode (urxvt)
!!
URxvt.geometry: 96x32
URxvt.scrollBar_right: true
URxvt.scrollBar_floating: true
URxvt.scrollstyle: plain
URxvt.cursorBlink: true
URxvt.cursorUnderline: true
URxvt.pointerBlank: true
URxvt.visualBell: false
URxvt.saveLines: 3000
URxvt.fading: 40
URxvt.tabbed.no-tabbedex-keys: true
!! Font list and Spacing
URxvt.font: xft:Cica-12
URxvt.letterSpace: -1
!URxvt.lineSpace: 0
!! Color Scheme and Opacity - gruvbox-dark https://github.com/morhetz/gruvbox
URxvt.depth: 32
URxvt.color0: [90]#282828
URxvt.color1: [90]#cc241d
URxvt.color2: [90]#98971a
URxvt.color3: [90]#d79921
URxvt.color4: [90]#458588
URxvt.color5: [90]#b16286
URxvt.color6: [90]#689d6a
URxvt.color7: [90]#a89984
URxvt.color8: [90]#928374
URxvt.color9: [90]#fb4934
URxvt.color10: [90]#b8bb26
URxvt.color11: [90]#fabd2f
URxvt.color12: [90]#83a598
URxvt.color13: [90]#d3869b
URxvt.color14: [90]#8ec07c
URxvt.color15: [90]#ebdbb2
URxvt.foreground: [90]#ebdbb2
URxvt.background: [90]#282828
URxvt.colorIT: [90]#8ec07c
URxvt.colorBD: [90]#d5c4a1
URxvt.colorUL: [90]#83a598
URxvt.scrollColor: [90]#504945
!URxvt.troughColor: [90]#3C3836
Though C-a, C-e, M-f, M-b and C-b works as in this documentation from Bash Reference Manual -- keybinds to edit command line; all of which moves the cursor, C-f -- the one to move the cursor to next letter -- does not; what am I missing?
I suspected that it is an issue by urxvt, as ctrl-f may be reserved for a certain shortcut.
Now appended these two lines to disable Perl extensions, two of which uses keybinds C-f and C-M-f:
URxvt.perl-ext:
URxvt.perl-ext-common:
I AM VERY SORRY I was a user of startx whose config file is ~/.xinitrc: it has a line xbindkeys whose config file is ~/.xbindkeysrc who has two lines
"xterm"
c:41 + m:0x4
Then I made this to comment, which finally worked.

Ansible lineinfile module special character

When i try to add in sudoers at eof the following file with lineinfile module the special character "!" not added the line any more. Without the special character is added ok.
Any ideea?
ansible 10.x.x.x -m lineinfile -a "path=/etc/sudoers insertafter=EOF line='Defaults:user !requiretty' validate='/usr/sbin/visudo -cf %s' state=present"
Kind of tricky, but works
line: "Defaults:user {{ '!' }}requiretty"
You can use it in a playbook. One would run short of quotation marks in the command-line .

Shell commands in AsciiDoc

I frequently use blocks of code in my asciidoc. The biggest issue I have is that shell commands beginning with '#' (because they use a root's shell) are rendered as comments in the asciidoc. For example:
[source,shell]
----
# firewall-cmd --permanent --new-zone dockerc
----
This make the reading a bit confusing. Is there a way to use a shell piece of code, overriding the 'behaviour' ?
Thanks
Maybe you need to set a source-highlighter
For me the following example worked for HTML:
= Foo
:source-highlighter: coderay
[source,shell]
----
# firewall-cmd --permanent --new-zone dockerc
--------
Or can you post a screenshot of how your output looks like?

To get colors to Less in Ubuntu's Zsh

How can you get similar highlightings to Zsh's Less than Bash's Less in Ubuntu?
I switched from OS X to Ubuntu. My Less do not work as expected in Zsh.
Manuals in my Less are green and black with or without the following code.
# comment these out in Ubuntu
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_me=$'\E[0m' # end mode
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
export LESS_TERMCAP_so=$'\E[38;5;246m' # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m' # end underline
export LESS_TERMCAP_us=$'\E[04;33;146m' # begin underline is now yellow
# | | |
# | |----------------- yellow
# |-------------------- underline
# to have the indication of cursor's location and line numbers, and R
export LESS="-mNR"
# |--------- only ASCII color
The code makes manuals readable in OS X, but it does not work for Ubuntu in Zsh.
Ubuntu has excellent highlightings in Bash's Less. My manuals have the colors yellow, green and black in Bash without my code. Both Zsh and Bash use the same Less at /usr/bin/less. This suggests me that Ubuntu's Bash has some dot-files which configure it somewhere.
Where are highlightings for Ubuntu's Less in Bash?
This works for me in zsh on archlinux:
$ mkdir ~/.terminfo/ && cd ~/.terminfo
Now get the terminfo description:
$ wget http://nion.modprobe.de/mostlike.txt
Now compile it using tic (the terminfo entry-description compiler)
$ tic mostlike.txt
(you may want to delete the mostlike.txt file after compiling)
mostlike.txt is this
# Reconstructed via infocmp from file: /usr/share/terminfo/x/xterm-pcolor
mostlike|manpages with color looking like most,
am, hs, km, mir, msgr, xenl,
cols#80, it#8, lines#24, wsl#40,
acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
bel=^G, bold=\E[1m\E[31m, clear=\E[H\E[2J, cr=^M,
csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C,
cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
dsl=\E]0;\007, ed=\E[J, el=\E[K, enacs=\E)0, fsl=^G,
home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL, il1=\E[L, ind=^J,
is2=\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>, kbs=^H,
kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
kdch1=\E[3~, kf1=\E[11~, kf10=\E[21~, kf11=\E[23~,
kf12=\E[24~, kf13=\E[25~, kf14=\E[26~, kf15=\E[28~,
kf16=\E[29~, kf17=\E[31~, kf18=\E[32~, kf19=\E[33~,
kf2=\E[12~, kf20=\E[34~, kf3=\E[13~, kf4=\E[14~,
kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
kfnd=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~,
kslt=\E[4~, rc=\E8, rev=\E[7m\E[34m, ri=\EM, rmacs=^O,
rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>,
rmso=\E[m, rmul=\E[m,
rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>, sc=\E7,
sgr0=\E[m, smacs=^N, smcup=\E7\E[?47h, smir=\E[4h,
smkx=\E[?1h\E=, smso=\E[1;30m\E[47m, smul=\E[32m,
tbc=\E[3g, tsl=\E]0;, u6=\E[%i%d;%dR, u7=\E[6n,
u8=\E[?1;2c, u9=\E[c,
And then just define an alias in the rc file of your favorite shell:
alias man="TERMINFO=~/.terminfo/ LESS=C TERM=mostlike PAGER=less man"
My default shell is bash so take this with a grain of salt. Start with /etc/profile and see how it sources bash-specific files. You need to re-create that logic for zsh. Maybe the zsh-lovers package can help, at least its title of tips, tricks and examples for the zsh
is suggestive.

Resources