5 ms·
I've been using ZSH ever since macOS moved to using it as the default shell. I honestly can't say I've noticed any differences. What are some features I should
by doctoboggan 4y ago
I've been using ZSH ever since macOS moved to using it as the default shell. I honestly can't say I've noticed any differences. What are some features I should be using to get the most out of ZSH?
- jw1224 4y agoHave you seen https://ohmyz.sh/ https://ohmyz.sh/ ? It’s indispensable, can’t imagine zsh without it now…
- _joel 4y agoexactly this, I love it.
- fernandotakai 4y agoi prefer zpresto https://github.com/sorin-ionescu/prezto https://github.com/sorin-ionescu/prezto
- SemanticStrengh 4y agowhat makes you prefer it?
- konart 4y agoLook into https://ohmyz.sh/ https://ohmyz.sh/ or https://github.com/zdharma-continuum/zinit https://github.com/zdharma-continuum/zinit (or any other plugin managers) and some nice plugins.
- vbezhenar 4y agoI really like right prompt. My config is: PS1="%# " RPS1="%40<...<%~" This way I have current directory information without eating precious space. Other than that, I don't really use much zsh-specific functionality.
- codewiz 4y agoIf you use the right prompt, make it automatically disappear so it doesn't get copied along when you select text in the terminal: setopt transient_rprompt
- I_complete_me 4y agoI use a 2 line prompt which obviates the need for that but nice tip all the same.
- vbezhenar 4y agoThanks, that's very useful!
- bombcar 4y agoWhat does right prompt do, and what happens if the text you're typing runs into it?
- vbezhenar 4y ago> What does right prompt do It displays configured text at right side of your terminal. My example displays current directory truncated to 40 characters. > and what happens if the text you're typing runs into it? It disappears.
- arccy 4y agothe fact that you can tab/navigate through autocomplete instead of having it fill up your screen every time you move
- pletnes 4y agoTab completion and zmv are neat, nothing new to learn, no complicated configs.
- pxeger1 4y agoSome of my favourite features which are built in to the shell, not part of third-party plugin systems, include: The "command1 =(command2)" syntax, which runs "command2", pipes its output to a new temporary file, runs "command1" with that file's name as an argument, and then removes the temporary file, all in one operation. It's like "<(command2)", which is in Bash and Zsh, but allows "command1" to perform a seek on the file because it's not a pipe. Redirections like ">file" where there's no command implicitly use cat, so ">file" just pipes STDIN to the file. Same for "<file", which pipes file to STDOUT. "command &>/dev/null" is shorthand for "command >/dev/null 1>&2". Floating-point arithmetic built-in (Bash has integer arithmetic only), including C math functions like sin, log, floor. Implicit insertion of "tee" where you obviously want it; for example, "command >file1 >file2" is the same as "command | tee file1 > file2" You don't need to quote variable expansions like $1 (except arrays). You still have to do so for command expansions $(command More expressive pattern syntax, including backreferences, approximate matching (using Damerau-Levenshtein distance), and flags/qualifiers to limit searching to specific kinds of file. E.g. "ls *(-@)" lists all broken symbolic links. The string =foo is expanded to the path to the "foo" command in $PATH, which allows you to do, for example, "vim =myscript" without needing to remember where "myscript" is exactly. Lots of parameter expansion flags for various string operators (search/replace, sorting, case translation, splitting and joining, ...). POSIX extended regex and optional PCRE support for pattern matching. zle, which does a similar job to readline in bash, but with an enormous number of useful features built-in. Generalised tilde expansion: ~ is the current user's $HOME, but ~john is the user john's home directory. You can make up your own using "hash -d foo=/path/too/foo"; now "~foo" refers to "/path/to/foo". Dynamic version of the above: ~[string] uses the function zsh_directory_name to expand "string" into any path; see the manual "zshexpn(1) § Filename Generation § Dynamic named directories". Easily create more explicit pipes using file descriptors: # open exec {fd}>file command1 >&$fd command2 >&$fd #... # close exec {fd}>&- Additional concise and useful syntax for loops, function definitions, etc.: while (( x < 5 )) { echo $x; let x++ } # more obvious than " repeat 5 echo hi # does what it says on the tin myfunc() echo hi # declares a function for ((x = 0; x++; x < 5)) { echo $i } # C-style for-loop The equivalent of "try-finally" in some programming languages: { # do some stuff which might error } always { # do some important cleanup } This construct also enables special support for another feature: actual exceptions with throw/catch. Very flexible prompt expansion: conditionals using %(condition.true.false). Optionally, command expansion "$()" can be enabled in prompts. All kinds of extra optional modules which can be loaded using "zmodload", for manipulating xattrs, POSIX Capabilities, TCP sockets, an FTP client!?; also, built-in plugin functions which can be loaded with "autoload": a full calendar application, an interactive calculator, colours, regex replace, tetris! > Zsh was once accused of not being as complete as Emacs, because it lacked a Tetris game. This function was written to refute this vicious slander. autoload -U tetriscurses tetriscurses Ability to set the value of argv[0] received by a command, rather than just the name it was invoked by, e.g. "ARGV0=ls busybox" Options to emulate the behaviour of other shells: pure POSIX sh, ksh, etc.? Sorry, that was perhaps a bit more than "some of my favourites". It really does have a lot of stuff.