5

In case it is not clear fn + left key is simply the HOME button. It takes you to beginning of line. This seems to still work when editing a file (in vim) say so I think zsh does something with the bindings. fn + left now results in an "error" sound.

UPDATE:

posting this link here as it seems where to go for this kind of general stuff: What are the practical differences between Bash and Zsh?

Changing from bash to zsh costs everyone a lot of time and money. Apple has decided to push this on everyone for various reasons. There should be good defaults for everything. Home keys should work, PS1 should be reasonable. Old .bashrc and .profile translations should be automatically generated. Not doing this is stealing from users. We are bailing them out for their "bad" decision to use bash or equivalents bash's decision to change license.

How to make everything "just work" like for bash?

I use iTerm 2 like a normal person. Not sure if that is related.

6
  • 2
    Dropping shade like “garbage” “normal” tends to attract downvotes or make people think you’re just angry and frustrated or venting . No need to feel defensive if you use a specific terminal - maybe editing this to be less subjective in a day or week would be good. Also, saying “I don’t yet know x” seems to bring out the most help here in my experience. – bmike Feb 2 '20 at 17:32
  • @bmike ALL of our time is money. Angry is the correct state to be in when products waste our time. This site and sites like it are an attempt by real humans to survive a little longer by helping each other. ANGRY at things that hurt people is correct and human response. Negative feedback is good feedback. Broken feedback (MacOS) is the real bug here. Unfortunately MacOS is often good option for other reasons. – mathtick Feb 2 '20 at 17:42
  • 3
    I would argue the amount of time Apple has wasted is how long you decide to chsh -s /bin/bash and most of the above looks like straw man discussion, but let’s discuss the larger picture on Ask Different Meta if you’d like. As long as you’re cool with the process, anger can be expressed here in healthy manners that the community supports. – bmike Feb 2 '20 at 17:48
  • 1
    In addition to the things said above, it's not really clear what your question is here. The title is about making "fn + left key" work as in bash (but without explaining what this does in bash, the question text talks about transitioning .bashrc etc. There is a lot of material about this transition both on the site here and on the Internet at large, so the more specific the question is the easier it will be to get good answers. – nohillside Feb 2 '20 at 17:57
  • 1
    I think this link covers the answer pretty well: bytesare.us/cms/index.php/server-how-to/zsh-home-end-keys – BallpointBen Feb 3 '20 at 17:22
7

To get fn-left (Home) and fn-right (End) working, add these two lines to ~/.zshrc (for your user only), or /etc/zshrc (for everybody)

bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
2

Bash is included in macOS 10.15 Catalina still however it is not the default login shell for new accounts.

This was done as Apple has increasingly been removing dependencies from the core OS for security reasons.

In this particular case since version 4 bash switched from the GPLv2 to the GPLv3 license which is not compatible with how Apple distribution their OS. This has prevented Apple from distributing updates beyond version 3.2 of bash.

Zsh was selected by Apple specifically for compatibility reasons and because it's license is compatible with Apple's distribution method.

The good news is you can switch back to bash 3.2, there are two ways to access it:

  1. Type bash into your terminal application.

  2. Modify the default (login) shell in iTerm or Terminal to bash

How to install bash v5

You can install the latest bash using homebrew:

  1. Install homebrew: https://brew.sh/
  2. Run brew install bash
  3. Switch to bash by running bash or editing the default (login) shell in iTerm or Terminal.

How to change the default (login) shell

  1. Find the path to your desired shell in a terminal application which bash it'll be something like /usr/local/bin/bash
  2. Launch System Preferences
  3. Go to 'Users & Groups'
  4. Right click on your username.
  5. Select 'Advance Options...'
  6. Paste your new shell in the 'Login shell:' field
  7. Press 'OK'
  8. Relaunch your terminal applications.
7
  • You can just do chsh -s /bin/bash ... but am looking for an conversion suggestion tool for all the .bashrc, .profile etc. Current strategy is to link all the zsh equiv to the bash and have if/else statements based on $SHELL (and OS). I aim to have a common dotfile setup so this gets a bit hairy. – mathtick Feb 2 '20 at 17:06
  • 1
    Yes but you might as well use the latest version. – unknowndomain Feb 2 '20 at 17:07
  • 1
    @mathtick our monster, drag out, discussion on shells is at apple.stackexchange.com/questions/361870/… Your use case of function keys might make a superb edit to one of the posts that goes into that level of detail if no one answers it here to your satisfaction. – bmike Feb 2 '20 at 17:52
  • 1
    Also, I’m so very happy to have you here @mathtick and unknowndomain. You both have super technical chops from the posts and actions. Thanks for contributing at a deep level of knowledge and care for the user experience. – bmike Feb 2 '20 at 17:54
  • 1
    Thanks for the answer and your contribution here. Not sure it addresses the issues raised in the question though, also both the claim about GPL compatibility and the reasoning behind Apple's decision to go with zsh would benefit from references/links (because AFAIK both haven't been officially communicated/confirmed). – nohillside Feb 2 '20 at 19:00
1

The core of the problem is that bash is using the readline library and zsh has its own keybindings and is not using readline. See Make zsh use readline instead of rle.

If you are at ease with the emacs key bindings (this is the one zsh is using by default), then you could use ctrl+a and ctrl+e to get the functions you are looking for within zsh.

If on the other hand, you are at ease with the vi key bindings, then you could enter within your ~/.zshrc:

bindkey -A viins main

and then you would be able to use 0 and $ to get the functions you are looking for within zsh. You can display all these bindings with:

bindkey

If you are interested to continue with zsh, read man zshzle to discover the functions zsh provides at the line editing level.

<ad section>

After many years of use of many ≠ shells, I feel that zsh has better time saving functions than bash.

</ad section>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .