Comments (18)
That fix works when using vi mode. Also, it can be right after the sourcing of mcfly.bash.
from mcfly.
@cantino Have a look here!
I think that it can solve the second issue (that i found too).
Actually in my setup i have set -o vi
in my ~.bashrc
file to have vi mode only in Bash. So sadly i don't know much about the first issue...
from mcfly.
Merged in 071a837 and released in 0.3.0, thanks!
from mcfly.
Weird. If you look at your terminal, do you see lines like
~$ #mcfly:
~$ mcfly search
in the history?
from mcfly.
I do indeed. And it looks like the command that gets pre-filled isn't necessarily mcfly search
; it's the last thing that was successfully run before the terminal emulator was opened - not sure if that gives any hints?
from mcfly.
What OS are you running?
from mcfly.
I get the same error. I am on Gentoo Linux.
$ bash --version
GNU bash, version 4.4.23(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ echo $PS1
\[\033[1;36m\]\u@\h\[\033[01;37m\] \w\n $\[\033[00m\]
from mcfly.
Also shopt:
$ shopt
autocd on
cdable_vars off
cdspell on
checkhash off
checkjobs off
checkwinsize on
cmdhist on
compat31 off
compat32 off
compat40 off
compat41 off
compat42 off
compat43 off
complete_fullquote on
direxpand off
dirspell off
dotglob off
execfail off
expand_aliases on
extdebug off
extglob on
extquote on
failglob off
force_fignore on
globasciiranges off
globstar off
gnu_errfmt off
histappend on
histreedit off
histverify off
hostcomplete on
huponexit off
inherit_errexit off
interactive_comments on
lastpipe off
lithist off
login_shell on
mailwarn off
no_empty_cmd_completion on
nocaseglob off
nocasematch off
nullglob off
progcomp on
promptvars on
restricted_shell off
shift_verbose off
sourcepath on
xpg_echo off
from mcfly.
Sorry, missed the notify on the reply. I'm on Arch.
$ bash --version
GNU bash, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)
and
$ shopt
autocd off
cdable_vars off
cdspell off
checkhash off
checkjobs off
checkwinsize on
cmdhist on
compat31 off
compat32 off
compat40 off
compat41 off
compat42 off
compat43 off
complete_fullquote on
direxpand off
dirspell off
dotglob off
execfail off
expand_aliases on
extdebug off
extglob off
extquote on
failglob off
force_fignore on
globasciiranges off
globstar off
gnu_errfmt off
histappend on
histreedit off
histverify off
hostcomplete on
huponexit off
inherit_errexit off
interactive_comments on
lastpipe off
lithist off
login_shell off
mailwarn off
no_empty_cmd_completion off
nocaseglob off
nocasematch off
nullglob off
progcomp on
promptvars on
restricted_shell off
shift_verbose off
sourcepath on
xpg_echo off
and
function prompt_exit_status() {
if [ $? -eq 0 ]; then
echo "${green}»${reset}"
else
echo "${red}»${reset}"
fi
}
function prompt_dir_writable() {
if [ -w "$PWD" ]; then
echo "${green}"
else
echo "${red}"
fi
}
function prompt() {
PS1="$(prompt_exit_status) $(prompt_dir_writable)\W${reset} \\$ "
}
PS2="${yellow}>${reset} "
PROMPT_COMMAND=prompt
where red/green/reset are tput
colours.
from mcfly.
Maybe you are using vi mode in your shell.
In this case change the end of mcfly.bash with this:
if [[ $- =~ .*i.* ]]; then
bind "'\C-r': '\e0imcfly: \e# mcfly search\C-j'"
fi
from mcfly.
I'm not using vi mode, as far as I know. Changing the end of mcfly.bash as suggested above gives me the same behaviour, except that the commented line that appears in my history is now #0imcfly:
instead of just #mcfly:
.
I realised I had some history-search binds too:
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
but disabling them didn't seem to make a difference either.
from mcfly.
@lycurgus What do you have in ~/.inputrc
and possibly /etc/inputrc
? Try moving those files away temporarily.
I have this:
# Possibly fix some issues
$include /etc/inputrc
# List all matches in case multiple possible completions are possible
set show-all-if-ambiguous on
# Immediately add a trailing slash when autocompleting symlinks to directories
set mark-symlinked-directories on
# Use the text that has already been typed as the prefix for searching through
# commands (i.e. more intelligent Up/Down behavior)
"\e[B": history-search-forward
"\e[A": history-search-backward
# Do not autocomplete hidden files unless the pattern explicitly begins with a dot
set match-hidden-files off
# Show all autocomplete results at once
set page-completions off
# If there are more than 200 possible completions for a word, ask to show them all
set completion-query-items 200
# Show extra file information when completing, like `ls -F` does
set visible-stats on
# Be more intelligent when autocompleting by also looking at the text after
# the cursor. For example, when the current line is "cd ~/src/mozil", and
# the cursor is on the "z", pressing Tab will not autocomplete it to "cd
# ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the
# Readline used by Bash 4.)
set skip-completed-text on
# Allow UTF-8 input and output, instead of showing stuff like $'\0123\0456'
set input-meta on
set output-meta on
set convert-meta off
# vi mode
set editing-mode vi
$if mode=vi
set keymap vi-command
# these are for vi-command mode
"\e[A": history-search-backward
"\e[B": history-search-forward
set keymap vi-insert
# these are for vi-insert mode
"\e[A": history-search-backward
"\e[B": history-search-forward
$endif
# Disable control echo
# set echo-control-characters off
# Show mode (+ = insert mode)
set show-mode-in-prompt on
# Make Tab autocomplete regardless of filename case
set completion-ignore-case on
from mcfly.
I don't have a ~/.inputrc
. My /etc/inputrc
is as follows, unchanged since system installation:
# do not bell on tab-completion
#set bell-style none
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
$if mode=emacs
# for linux console and RH/Debian xterm
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[7~": beginning-of-line
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
# for rxvt
"\e[8~": end-of-line
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
$endif
from mcfly.
After some experimentation it seems it's the PROMPT_COMMAND
, as mentioned above, that was the problem. My .bashrc
was sourcing the prompt file after mcfly.bash
and evidently clobbering important things.
Problem solved, at least for me - not sure if this discovery is useful to anyone else.
from mcfly.
Glad you figured it out @lycurgus! I wonder if there's anything we should change in mcfly? Should we source the existing PROMPT_COMMAND first instead of at the end, perhaps?
@asdalo21 & @Tatsh: do you know if it's possible to detect vi
mode programmatically / automatically so that we could support both?
from mcfly.
@cantino I think the only thing that could help is noting in the documentation that mcfly needs to be sourced in .bashrc after any existing modification to PROMPT_COMMAND happens - the key problem was that my change to PROMPT_COMMAND didn't preserve any existing command(s) so no matter what mcfly did, my setup would have broken it. I could also have made my PROMPT_COMMAND $PROMPT_COMMAND;prompt
, so perhaps that option should be presented as well in case someone has a technical limitation that prevents putting mcfly after other PROMPT_COMMAND modifications.
As for detecting vi-mode - it looks like set -o
prints the current state of all the flags, so you should be able to grep that for vi on
or vi off
.
from mcfly.
@cantino as @lycurgus said one way is to grep set -o
:
if [[ $- =~ .*i.* ]]; then
if set -o | grep "vi " | grep -q on; then
bind "'\C-r': '\e0imcfly: \e# mcfly search\C-j'"
else
bind "'\C-r': '\C-amcfly: \e# mcfly search\C-j'"
fi
fi
from mcfly.
Thanks @asdalo21!
To test this with vi
mode, I put this in my ~/.inputrc
:
set editing-mode vi
set keymap vi-command
Two issues:
- It seems like
~/.inputrc
is loaded after~/.bashrc
? I find thatset -o | grep "vi " | grep -q on
doesn't return true unless I include
if [[ -f ~/.inputrc ]]; then
bind -f ~/.inputrc
fi
before it in mcfly.bash
. However, if I do that, then the bind
command seems to no longer have any effect.
- When I run
bind "'\C-r': '\e0imcfly: \e# mcfly search\C-j'"
in the shell when in vi mode, it does seem to work, but only in vi input mode. When in vi command mode, I get(reverse-i-search)
':. Maybe it needs a second
bind`?
from mcfly.
Related Issues (20)
- feature request - CLI option to dump the sqlite3 db HOT 7
- Integrate with Atuin HOT 5
- thread 'main' panicked : database disk image is malformed HOT 3
- thread 'main' panicked at 'McFly error occurs each time I run some command. HOT 2
- Can't search command with '-' arguments in PowerShell
- have sane default colors HOT 2
- mcfly prints arguments when moving files around HOT 2
- Draft releases messed up HOT 4
- zsh-vi-mode conflict
- Allow <TAB> to cycle through options instead of select HOT 3
- Allow ENTER to select the command and put it on commandline
- Handle multiple commands separated by "\n" in Fish shell HOT 2
- F3 key does not work with 'vim' key scheme HOT 1
- Powershell support documentation HOT 1
- F3 breaks standard terminal's line limit HOT 3
- Request for Dynamic Fuzz Search Toggle Within Search Interface HOT 1
- Vulnerabilities mio and zerocopy dependency HOT 1
- Panic in `src/fake_typer.rs` - broken edit and run commands HOT 8
- Bug in mcfly.fish HOT 5
- Installing mcfly on Ubuntu 24.04 doesn't bind CTRL+R and "mcfly search" throws error HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mcfly.