.inputrc commands vi-cmd-mode-string and vi-ins-mode-string are not working. No prefix is shown at the beginning of the bash prompt. But the input mode is indeed vim (I can switch between command / insert mode).
I'm on macOS Catalina 10.15.1. I've installed bash with brew install bash (also tested brew install --HEAD to compile locally).
My bash version is 5.0.11. Should be enough for vi-ins|cmd-mode-string that is available since bash 4.4 (https://stackoverflow.com/a/32614367/2058840)
bash --version
GNU bash, version 5.0.11(1)-release (x86_64-apple-darwin19.0.0)
Copyright (C) 2019 Free Software Foundation, Inc.
I've also install readline via brew, but this changes nothing.
My .inputrc :
$if Bash
set editing-mode vi
$endif
$if mode=vi
set show-mode-in-prompt on
set vi-cmd-mode-string bbbbb
set vi-ins-mode-string aaaaa
$endif
What am I missing here? With this bash version, I expect bbbb or aaaa to be shown as the bash prompt prefix.
Ok. Just found out it's not a problem with the homebrew bash version.
My macOS user config still use the default bash version /bin/bash (bash 3) instead of the homebrew one /usr/local/bin/bash.
You can change yours with https://www.howtogeek.com/444596/how-to-change-the-default-shell-to-bash-in-macos-catalina/.
It took me time to understand that because of the bash --version test. This test the version of the first bash accessible in your $PATH. Not the bash used to open your shell.
Related
I have tried to run:
uninstall_oh_my_zsh
but i get a message stating that: -bash: uninstall_oh_my_zsh: command not found
Other commands i have tried are:
chmod +x ~/.oh-my-zsh/tools/uninstall.sh
I get a response stating that: No such file or directory
sh ~/.oh-my-zsh/tools/uninstall.sh
Ran:
chsh -s /bin/bash
To change default terminal from /bin/zsh to /bin/bash
I also tried:
rm -rf ~/.oh-my-zsh
rm ~/.zshrc
cp ~/.zshrc.pre-oh-my-zsh ~/.zshrc
source ~/.zshrc
None of them have worked thus far, when i open my terminal. I get a message stating that:
The default interactive shell is now zsh.
To update your account to use zsh, please run chsh -s /bin/zsh
You don't have Oh My Zsh (a set of configuration files for zsh and a way to manage them) installed in the first place.
The warning is coming from /bin/bash itself; it's hard-coded into the executable supplied by macOS.
$ strings /bin/bash | grep "default interactive shell"
The default interactive shell is now zsh.
Though they don't say so, I suspect the warning is there because they plan to remove bash from future versions of macOS entirely. They stopped providing newer versions of bash years ago.
Your default shell is already /bin/bash; the warning is recommending that you switch to /bin/zsh.
You can continue to use bash, though I recommend installing a newer version (3.2 is old) using something like Homebrew, then changing your login shell to the new version.
However, unless you are really committed to using bash, I suggest given zsh a try.
I'm new to macOS coming from Windows and Linux. I want to use bash and found how to upgrade bash on Catalina, version now:
GNU bash, version 5.0.18(1)-release (x86_64-apple-darwin19.5.0), also installed coreutils.
I'm trying to set direxpand in .bashrc (which works as expected in *nix variants):
shopt -s direxpand
But when .bashrc is sourced I get an error:
-bash: shopt: direxpand: invalid shell option name
Spent a couple of hours searching online and can't find an answer, can anyone help?
Update 28/07/20 14:08 GMT
Interesting, following other advice before posting, I installed bash with brew and had to set my shell to /usr/local/bin/bash for the terminal app to use it.
So output from bash --version:
GNU bash, version 5.0.18(1)-release (x86_64-apple-darwin19.5.0)
But echo $BASH_VERSION gives:
3.2.57(1)-release
So something not right there?
Also, output from running shopt does not show direxpand.
Solved 28/07/20 20:00 GMT
For anyone with a similar problem, here's what I found.
bash installed with Catalina did not include the same shell options I have in linux.
The full solution is to install coreutils and bash with brew:
brew install coreutils bash
Then add the new version of bash to shells:
sudo vi /etc/shells add /usr/local/bin/bash
Then change your user shell:
chsh -s /usr/local/bin/bash
Then in terminal preference > general > shells open with > command (complete path) add the new bash /usr/local/bin/bash
After that shopt -s confirms that direxpand is now an option and my .bashrc works as expected.
When running shopt without arguments you can see the available shopt options you can set. In your case I expect direxpand it's not there.
The workings of the direxpand shopt option depends on the readline library. If bash is compiled without readline support this option will not be there. I expect that is the case for you.
An option would be to compile bash yourself. The accepted answer of this question will show you how to compile bash yourself. You can add the --enable-readline option in configure to force turn on readline support.
Note: compiling yourself might require you to get the readline library in your OS. I expect bash was compiled without it because it is not easily available, but that is for you to figure out.
I have homebrew's bash package installed. When I open a new shell:
bash --version gives GNU bash, version 5.0.7(1)-release (x86_64-apple-darwin18.5.0)
which bash gives /usr/local/bin/bash as expected.
But:
echo $BASH_VERSION yields 3.2.57(1)-release
I'm wondering if this is something I should address for scripts that might use this environment variable.
It means that the shell you're in is Bash 3.2, but bash points to Bash 5.0. Try bash and then, in the new shell, echo $BASH_VERSION – I guess it'll be 5.0. To change your login shell, add /usr/local/bin/bash to /etc/shells and change the default shell with
chsh -s /usr/local/bin/bash
sudo chsh -s /usr/local/bin/bash
After logging out and in again, $BASH_VERSION should be updated.
As for shebang lines, I recommend
#!/usr/bin/env bash
as it's portable and will use the first Bash in your $PATH.
The source of my problem was a terminal app preference setting. The "Command (complete path)" was set to /bin/bash. After setting it to "Default login shell", echo $BASH_VERSION reported the version I expected. The other problem is I stupidly ran the bash --version command in iTerm2, not terminal. So it gave a different response than what terminal would have.
Your login shell (see echo $SHELL) is probably /bin/bash and that is the one setting $BASH_VERSION. If you need to use a specific version in scripts, use the full path in the #! line.
Make sure to check that the terminal you are using is using the default login shell and not a custom one.
The ${parameter[^|^^|,|,,][pattern]} parameter substitution is giving me a bad substitution error.
$ echo $greeting
hello world
$ echo "${greeting^}."
-bash: ${greeting^}.: bad substitution
I updated to the latest bash version and keep getting the error.
GNU bash, version 4.4.19(1)-release (x86_64-apple-darwin17.3.0)
I've looked everywhere and the only suggestion I've found is making sure it's running bash 4.
$ echo $SHELL
/bin/bash
I'm running macOS High Sierra.
Your default shell is not the bash shell (downloaded from brew install bash) that contains the v4 which supports the parameter expansion syntax you are referring to.
On macOS echo $BASH_VERSION will tell you the version of the current shell. bash --version tells you the version of the first bash in your $PATH. So the way you were looking at the version was not telling you the version that you were running.
You need to add the recent version of bash to the file /etc/shells as the last line and use the command to set the shell as the default on Terminal
chsh -s /usr/local/bin/bash "$USER"
After this close and re-open the Terminal to make it effect. Without adding this default option in your Terminal, you could only use the recent bash only on scripts with interpreter she-bang set to #!/usr/local/bin/bash
See also this Ask Different answer to - Update bash to version 4.0 on OSX
While Googling for another bash tip, I found this page on .inputrc http://ss64.com/bash/syntax-inputrc.html, which exactly fixed what I was trying to do (put a trailing / on symlinks to directories), but as I read further, I saw that there was a way to skip completed text as well. "Awesome", I said to myself, "this bugs me about twice a week". So, I put that into my .inputrc as well, but it doesn't work, or even seem to recognize what's going on. After logging out, and logging back in, this is what I'm seeing:
$ tail .inputrc
set mark-symlinked-directories on
set skip-completed-text on
$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.
$ bind -V | grep completed
$ bind -V | grep skip
$
That is, bash doesn't seem to recognize it's there at all... Is there something wrong with the version of bash supplied in Mountain Lion? Anything blindingly obvious I've forgotten to do?
skip-completed-text is new to bash version 4.
The: skip-completed-text is only in bash4.
On my Mac:
$ bash --version
GNU bash, version 4.2.37(2)-release (i386-apple-darwin12.1.0)
If you want install some opensource utilities i recommending you using macports (www.macports.org). Installing macports will give you one command called port and with it you can install things dead simply, like:
$ port install bash
will install bash 4 for you.
Bash v4 won't make it to OSX. Might I suggest zsh, which is not GPL3.