16 votes

Sensible $WORDCHARS for Most Developers

9 comments

  1. [4]
    LGUG2Z
    Link
    I was thinking this week about how even many experienced developers that I have worked with have not taken the time to customize their $WORDCHARS when using zsh. I think this is such a low hanging...

    I was thinking this week about how even many experienced developers that I have worked with have not taken the time to customize their $WORDCHARS when using zsh. I think this is such a low hanging fruit which makes terminal-time so much more pleasant!

    I would like to think that most people would customize their $WORDCHARS if they knew that it was possible, or how to, which is why I did this little write-up with my proposal for a minimally-sane $WORDCHARS that should save most developers a lot of frustration

    8 votes
    1. Boojum
      Link Parent
      Very nice. I'd completely forgotten about $WORDCHARS. Looking in my .zshrc, I see that I had just removed the forward slash from the default via substitution: WORDCHARS=${WORDCHARS//\//} I like...

      Very nice. I'd completely forgotten about $WORDCHARS. Looking in my .zshrc, I see that I had just removed the forward slash from the default via substitution:

      WORDCHARS=${WORDCHARS//\//}
      

      I like your list, however, and to remove all the ones you suggest, I now have:

      WORDCHARS=${WORDCHARS//[\/_.-]/}
      

      Removing characters from the list this way is documented in A User's Guide to the Z-Shell.

      4 votes
    2. [2]
      vczf
      Link Parent
      Thanks for posting! I had no idea this existed. I use the grml zsh config as my base, which does at least break at / when deleting words from a path, but the other ones are a nice addition.

      Thanks for posting! I had no idea this existed. I use the grml zsh config as my base, which does at least break at / when deleting words from a path, but the other ones are a nice addition.

      1 vote
      1. Boojum
        Link Parent
        By the way, just yesterday I included one more character, =, in my set of characters to remove from the default $WORDCHARS. This came about because I was editing a CMake parameter and wanted to...

        By the way, just yesterday I included one more character, =, in my set of characters to remove from the default $WORDCHARS.

        This came about because I was editing a CMake parameter and wanted to change something like -DCMAKE_BUILD_TYPE=Release to Debug or v.v., and it deleted all the way back to the last _ instead of the = like I had intended. Having = in the set to remove is also useful for typical --foo=bar type options.

        5 votes
  2. [4]
    streblo
    Link
    I switched from zsh to fish a while ago and haven’t looked back. I find in addition to the nicer built-ins, the defaults are all just better than zsh. For example the defaults for alt backspace...

    I switched from zsh to fish a while ago and haven’t looked back. I find in addition to the nicer built-ins, the defaults are all just better than zsh. For example the defaults for alt backspace work like the desired case in the linked post out of the box.

    Occasionally I have to drop into a POSIX shell and I’ll use zsh for that but overall I don’t plan on switching back ever.

    6 votes
    1. [3]
      Minty
      Link Parent
      I have switched from zsh to fish with similar results, but after some years I just got tired of POSIX non-compliance and went back to zsh, so don't delete your old configs :p I still use fish when...

      I have switched from zsh to fish with similar results, but after some years I just got tired of POSIX non-compliance and went back to zsh, so don't delete your old configs :p

      I still use fish when I just want to install it and be ready to go, though. For instance on ephemeral virtual machines.

      5 votes
      1. [2]
        streblo
        Link Parent
        You're right, I guess I should never be too certain about anything. ;P Just curious, what were the pain points that made you switch back? For me, although occasionally I will script in fish I...

        You're right, I guess I should never be too certain about anything. ;P Just curious, what were the pain points that made you switch back?

        For me, although occasionally I will script in fish I still mostly write shell scripts in bash so I'm not really losing out on my knowledge of bash scripting. The only annoying thing is writing wrappers for bash scripts you are expected to source. Unfortunately these are rather common in my job but, for me at least, writing a small wrapper script or just dropping into zsh isn't a large inconvenience compared to the benefits of fish.

        2 votes
        1. Minty
          Link Parent
          Basically the fact I had to script in both and my brain switches/decides between things a bit slow. I already had my zsh configured and extended to act basically the same as fish, and just as fast...

          what were the pain points

          Basically the fact I had to script in both and my brain switches/decides between things a bit slow. I already had my zsh configured and extended to act basically the same as fish, and just as fast (or slow if you're a half-empty glass of a person), so no loss. There's a lot of environments out of my control using bash or even just sh, but 99% zsh stuff is already compatible, so I decided this slow fish switching is too inconvenient.

  3. Minty
    Link
    I've never had any problems with alt/ctrl+backspace, but now I realize I should have. PowerShell already behaves reasonably using its defaults a-zA-Z0-9_$\-\p{L}\p{Nd}, but zsh's are completely...

    I've never had any problems with alt/ctrl+backspace, but now I realize I should have. PowerShell already behaves reasonably using its defaults a-zA-Z0-9_$\-\p{L}\p{Nd}, but zsh's are completely wrong. This change is great!

    3 votes