I installed fish with homebrew on Mac OS Big Sur, Apple Silicon. Then I added /opt/homebrew/bin/fish to /etc/shells. When I now start fish from the default shell, it recognises all commands (like git flow init).
After changing the default shell with chsh -s /opt/homebrew/bin/fish, suddenly it won't recognise anything anymore and always gives a Unknown command.
I haven't found anything regarding this issue and uninstalled fish and brew several times...
Here are the steps I used to setup the fish shell on my M1 MacBook Air. Per the comments on the question, the key to solving the Unknown Command issue is the fish_add_path:
$ brew install fish
$ fish
$ fish_add_path /opt/homebrew/bin
$ echo "/opt/homebrew/bin/fish" | sudo tee -a /etc/shells
$ chsh -s /opt/homebrew/bin/fish
I upgraded Cygwin and now Bash is acting weird. Newlines aren't always returning the cursor to the left side of the screen, but sometimes they do. Here is what I'm experiencing:
$ echo hello
hello
Thu Jan 30 08:31:33 :~
$ python3
Python 3.6.9 (default, Jul 21 2019, 14:33:59)
[GCC 7.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 56+23
79
>>> 2+3
5
>>> exit()
Thu Jan 30 08:31:46 :~
$
I have TERM=xterm-color, and I've tried TERM=cygwin and just TERM= with no difference in behavior.
Another strange thing is that the less command will mess up the newlines when I first open a file, or page down with Ctrl-F, but if I page up or scroll up or down one line at a time, the formatting is fine.
ls -l works fine. cat works fine.
I've determined it's ConEmu. It has something to do with my task command:
C:\cygwin64\bin\bash.exe --login -new_console:P:"<Standard VGA>"
I use this so the background is black. Also, when I logout, the tab closes instead of remaining open.
The default command doesn't have the newline problem, but has the problems stated above:
set CHERE_INVOKING=1 & set "PATH=%ConEmuDrive%\cygwin64\bin;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe -new_console:p %ConEmuDrive%\cygwin64\bin\bash.exe --login -i -new_console:C:"%ConEmuDrive%\cygwin64\Cygwin.ico"
Edit: Of course, it has nothing to do with the -new_console:P:"<Standard VGA>" and everything to do with running bash with %ConEmuBaseDirShort%\conemu-cyg-64.exe. I don't know what it does exactly - I need to look into it further.
Edit #2: It turns out there's an issue with arrow and delete keys being disabled by conemu-cyg-64.exe: https://github.com/Maximus5/ConEmu/issues/2035.
Edit #3: Downloading the latest developer snapshot (which is 2020-01-31 at this time) of Cygwin at https://cygwin.com/snapshots/ fixed the problem with the arrow and delete keys for me.
$ unxz cygwin1-20200131.dll.xz
$ mv cygwin1-20200131.dll /bin/cygwin1.dll
Of course, that isn't going to work while Cygwin is running, but you get the idea.
For me updating to the latest ConEnum release (Version 1.3.18.1106) solved the problem.
Latest Cygwin release fixes this.
.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.
fish --version
> fish, version 3.0.2
uname -a
> Darwin Jerrys-MacBook.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
echo $TERM
> xterm-256color
I have compare my $PATH in bash and fish shell, the order of rvm changed, which cause which pod become different(i used rvm to manage ruby).
How can I make them same order ?
By the way,
I have include all my setting in .bashrc and load it by source ~/.bashrc in .bash_profile, noting in .prfile
And I have nothing in ~/.config/fish/config.fish
The begin character of x,~,=,> just I added mark to compare easily.
----- echo $PATH
=:~/.rvm/gems/ruby-2.2.9/bin
=:~/.rvm/gems/ruby-2.2.9#global/bin
=:~/.rvm/rubies/ruby-2.2.9/bin
X=:/opt/local/bin
X=:/opt/local/sbin
=:~/.nvm/versions/node/v8.11.3/bin
~:/usr/local/bin
~:/usr/bin
~:/bin
~:/usr/sbin
~:/sbin
>:/usr/local/share/dotnet
>:/opt/X11/bin
>:/Library/Frameworks/Mono.framework/Versions/Current/Commands
X-:~/.rvm/bin
X-:~/.local/bin
X-:/usr/local/Cellar/aria2/1.33.1/bin
X-:~/Documents/code/flutter/sdk/flutter/bin
X-:~/Documents/code/flutter/sdk/flutter/bin/cache/dart-sdk/bin
X-:~/Documents/code/flutter/sdk/flutter/.pub-cache/bin
------ fish & echo $PATH
~/usr/local/bin
~/usr/bin
~/bin
~/usr/sbin
~/sbin
>/opt/X11/bin
>/usr/local/share/dotnet
>/Library/Frameworks/Mono.framework/Versions/Current/Commands
=~/.rvm/gems/ruby-2.2.9/bin
=~/.rvm/gems/ruby-2.2.9#global/bin
=~/.rvm/rubies/ruby-2.2.9/bin
X=/opt/local/bin
X=/opt/local/sbin
=~/.nvm/versions/node/v8.11.3/bin
X-~/.rvm/bin
X-~/.local/bin
X-/usr/local/Cellar/aria2/1.33.1/bin
X-~/Documents/code/flutter/sdk/flutter/bin
X-~/Documents/code/flutter/sdk/flutter/bin/cache/dart-sdk/bin
X-~/Documents/code/flutter/sdk/flutter/.pub-cache/bin
Here is a simple workaround from this PR,
# Download patched config
curl -O https://raw.githubusercontent.com/fish-shell/fish-shell/e18354bc6ef937e2e663fc098cc51a2546d4d2d0/share/config.fish
# Install config
mv config.fish /usr/local/share/fish/
here how i solved it (using fish only as interactive on top of my zsh):
in .zshrc:
export ZSHPATH="$PATH"
fish
in .config/fish/config.fish
set PATH $ZSHPATH $PATH
To be simple, download & install the version fish-2.7.1.pkg which don't have this bug on Mac.
According to code commit, next version fish-3.1.0 may fix this bug.
I know this might be more appropriate at Ask Different, but as I tried adding tags there, there was no vim tag, only macvim. So I figured I might get a better audience here.
In the Terminal, I do the following
$ vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jan 31 2010 13:33:49)
When I browse to http://www.vim.org, I see a news item
Vim 7.3 released!
How do I update my built-in vim? I would very much like to do it cleanly (i.e. no duplicate installations, or any additional downloads, no macports, etc.)
I considered using Mercurial (as I already use it for other things), as per the instructions here.
$ hg clone https://vim.googlecode.com.hg/ vim
$ cd vim/src
$ make
But I think that would make a duplicate installation. Despite my "clean" requirement as mentioned above, "unclean" solutions are also welcome, since maybe there really is no other way.
If I understand things correctly, you want to install over your existing Vim, for better or worse :-) This is a bad idea and it is not the "clean" way to do it. Why? Well, OS X expects that nothing will ever change in /usr/bin unbeknownst to it, so any time you overwrite stuff in there you risk breaking some intricate interdependency. And, Let's say you do break something -- there's no way to "undo" that damage. You will be sad and alone. You may have to reinstall OS X.
Part 1: A better idea
The "clean" way is to install in a separate place, and make the new binary higher priority in the $PATH. Here is how I recommend doing that:
$ # Create the directories you need
$ sudo mkdir -p /opt/local/bin
$ # Download, compile, and install the latest Vim
$ cd ~
$ hg clone https://bitbucket.org/vim-mirror/vim or git clone https://github.com/vim/vim.git
$
$ cd vim
$ ./configure --prefix=/opt/local
$ make
$ sudo make install
$ # Add the binary to your path, ahead of /usr/bin
$ echo 'PATH=/opt/local/bin:$PATH' >> ~/.bash_profile
$ # Reload bash_profile so the changes take effect in this window
$ source ~/.bash_profile
Voila! Now when we use vim we will be using the new one. But, to get back to our old configuration in the event of huge f*ckups, we can just delete the /opt directory.
$ which vim
/opt/local/bin/vim
$ vim --version | head -n 2
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 27 2011 20:55:46)
MacOS X (unix) version
See how clean this is.
I recommend not to install in /usr/local/bin when you want to override binaries in /usr/bin, because by default OS X puts /usr/bin higher priority in $PATH than /usr/local/bin, and screwing with that opens its own can of worms.... So, that's what you SHOULD do.
Part 2: The "correct" answer (but a bad idea)
Assuming you're set on doing that, you are definitely on track. To install on top of your current installation, you need to set the "prefix" directory. That's done like this:
hg clone https://bitbucket.org/vim-mirror/vim or git clone https://github.com/vim/vim.git
cd vim
./configure --prefix=/usr
make
sudo make install
You can pass "configure" a few other options too, if you want. Do "./configure --help" to see them. I hope you've got a backup before you do it, though, in case something goes wrong....
Don't overwrite the built-in Vim.
Instead, install it from source in a different location or via Homebrew or MacPorts in their default location then add this line to your .bashrc or .profile:
alias vim='/path/to/your/own/vim'
and/or change your $PATH so that it looks into its location before the default location.
The best thing to do, in my opinion, is to simply download the latest MacVim which comes with a very complete vim executable and use it in Terminal.app like so.
alias vim='/Applications/MacVim.app/Contents/MacOS/Vim' # or something like that, YMMV
Like Eric, I used homebrew, but I used the default recipe. So:
brew install mercurial
brew install vim
And after restarting the terminal homebrew's vim should be the default. If not, you should update your $PATH so that /opt/homebrew/bin is before /usr/bin. E.g. add the following to your .profile:
export PATH=/opt/homebrew/bin:$PATH
Note: Previous versions of Homebrew did install to /usr/local, so in that case you have to use /usr/local/bin instead of /opt/homebrew/bin.
A note to romainl's answer: aliases don't work together with sudo because only the first word is checked on aliases. To change this add another alias to your .profile / .bashrc:
alias sudo='sudo '
With this change sudo vim will behave as expected!
On Yosemite, install vim using brew and the override-system-vi option. This will automatically install vim with the features of the 'huge' vim install.
brew install vim --with-override-system-vi
The output of this command will show you where brew installed vim. In that folder, go down into /bin/vim to actually run vim. This is your command to run vim from any folder:
/usr/local/Cellar/vim/7.4.873/bin/vim
Then alias this command by adding the following line in your .bashrc:
alias vim="/usr/local/Cellar/vim/7.4.873/bin/vim"
EDIT: Brew flag --override-system-vi has been deprecated. Changed for --with-override-system-vi. Source: https://github.com/Shougo/neocomplete.vim/issues/401
brew install vim --override-system-vi
This blog post was helpful for me. I used the "Homebrew built Vim" solution, which in my case saved the new version in /usr/local/bin. At this point, the post suggested hiding the system vim, which didn't work for me, so I used an alias instead.
$ brew install vim
$ alias vim='/path/to/new/vim
$ which vim
vim: aliased to /path/to/new/vim
I just installed vim by:
brew install vim
now the new vim is accessed by vim and the old vim (built-in vim) by vi