6 ms·
Me too! This github repo, along with r/selfhosted [0] and this [1] are everything you'd need. I've been keeping track [2] of the things I've had to do to when
by pixelHD 8y ago
Me too!
This github repo, along with r/selfhosted [0] and this [1] are everything you'd need.
I've been keeping track [2] of the things I've had to do to whenever I used to switch my VPS providers. Its not perfect - I don't restrict ssh, nor do I restrict the database access, but I mention that, and you can choose not to do that.
[0]: https://www.reddit.com/r/selfhosted/ https://www.reddit.com/r/selfhosted/
[1]: https://selfhosted.libhunt.com/ https://selfhosted.libhunt.com/
[2]: https://github.com/itsmehemant123/basic-vps-setup https://github.com/itsmehemant123/basic-vps-setup
- dvfjsdhgfv 8y agoI'm wondering - why bother with Zsh? Modern Bash is quite advanced - is there any killer feature worth having it installed on all machines? I remember trying it out 10 years ago and it was always kind of "well, that features are nice to have" - but it turned out I rarely used them in the end.
- craftyguy 8y agoLazy completion is nice, e.g. type: 'ls /u/s/i' and tab could expand to '/usr/share/icons'
- dvfjsdhgfv 8y agoMmkay, that's two tabs less than in Bash, I'm not sold that.
- Yetanfou 8y agoNot to mention that /u/s/i is not discoverable and as such something else to remember while /u <tab> /s <tab> (will expand to /usr/sbin /usr/share /usr/src so /sh <tab> is better) /i <tab> is. Tools which are not omni-present yet claim to save time by making the user remember tool-specific syntax are often not worth the effort of learning that syntax unless the savings in time or effort are substantial - in which case the tool would probably be more wide-spread to begin with.
- craftyguy 8y agoWell, that was a silly example I typed on my phone. Imagine longer paths, sometimes half a dozen or more directories deep, where multiple directories at a given level may start with the same character(s) but zsh is able to figure out which one you really want based on the subdirectories you specified.
- LyndsySimon 8y agoThe big thing for me is programmable autocompletion. I can autocomplete things that the shell itself doesn't even know about, like git branches and aws-cli commands - including autocompleting paths inside an s3 bucket.
- icebraining 8y agoBash has programmable completion as well. See for example: https://github.com/scop/bash-completion https://github.com/scop/bash-completion
- LyndsySimon 8y agoThe last time I looked into this, bash's programmable completion was both an order of magnitude slower and didn't allow tab-completion. Has that changed?
- icebraining 8y agodidn't allow tab-completion What does this mean? I didn't know there was any other kind! I don't know if it's slower, I haven't used zsh in a while, but the completion support for git (e.g. branches) is pretty fast for me.
- LyndsySimon 8y agoWhen I last used it, I could partially type a command, press tab, and the completions would display below the line I was on. It did not modify the input line or the cursor position In zsh, I press tab and the rest of the command is inserted onto the line I’m typing. If there are multiple options I can continue to press tab to cycle through them. I just have to press enter on the one I want. Again, maybe it’s changed, but the last time I used bash I wasn’t able to do this.
- icebraining 8y agoAh, ok. No, it definitively inserts onto the line.
- kamaraju 8y agoYou can configure zsh to use glob pattern matching when reverse searching the history using ctrl-r . For example you can do ctrl-r wordA*wordB and it will match commands where wordA is followed by wordB with zero or more number of characters in between. I wrote about it in http://raju.shoutwiki.com/wiki/Search_command_line_history_using_glob_pattern_matching http://raju.shoutwiki.com/wiki/Search_command_line_history_u... . AFAIK bash does not have this and it is the killer feature for me.
- jolmg 8y ago* Multiline Command Editing With Support In Keybindings And History File Format For me, the killer feature is multiline command editing. Sometimes there is a need to do an ad-hoc complex set of actions, and it's nice to keep everything together in 1 command you can incrementally test and develop. Note, I'm not talking about hitting enter on an incomplete command and getting a PS2 prompt. That sucks because each of those lines is separate in the history, and you have to navigate for each line in turn when you want to reuse it. I'm talking about multiline commands that stay as one in the history and are comfortably editable on the command line. Here is an example with my prompt: / 2018.04.30 16:06:50 | 0 - !71361 - %0 - jol@vento - ~some_project for ip in 10.1.{1..10}0.5; do ssh some_user@$ip ' cp things places ed files << EOF i things . /others/d w EOF # other tedious stuff ' done \ 2018.04.30 16:10:42 output if there's any / 2018.04.30 16:10:42 | 0 - !71362 - %0 - jol@vento - ~some_project It's got vi keybindings that are meant for multiple lines like 'o' inserts a new line below, 'O' inserts a new line above, 'dd' deletes a line, etc. You can kind of do the same in bash, by pressing Ctrl-V Ctrl-J you can insert a newline and continue editing, but pressing up/down (or j/k if on vi keybindings) won't move between the lines, but rather navigates the history. Vi keybindings in bash don't implement those that are meant for multiline editing. Also the history format for bash doesn't seem to support multiline commands. If I make one and get the last command from history, it's all been joined in one line. bash will even insert ';' where needed to replace the newlines. * Temporary Regular File `=(cmd)` Process Substitution Both bash and zsh have process substitution of the form `<(cmd)` and `>(cmd)`, which substitute themselves with the path of a named pipe to communicate with the subprocess that runs concurrently. However, zsh additionally has `=()` which is a subprocess that runs before the substitution and whose output is collected in a temporary regular file which path is substituted in place after it finishes, and destroys it when the process which received the path dies. This is really useful for programs that need more than one pass when reading the file. I've used it, for example on `viewnior =(maim -s)` to display in an image viewer the window that I select with the mouse. * Very Feature-Rich Extended Glob I know bash has extended globs too, but I don't know how they compare. Here is something I found in my history for a yesod project: printf "%s\n" **/^(.*|*[~#])~(front-end|config|dist|yesod-devel|static)*(.oe[REPLY=\${REPLY:#*/*}]on) I can't remember exactly what I was looking for when I did this, but this lists all regular files (not directories or symlinks, etc.) under a tree that do not begin in '.' or end in a '~' or '#' and that are not part of the top-level directories front-end, config, etc. ordered first by being under another directory (not top-level from the search; so I'd get top-level files at the end) and then by name. A more common glob that I do is '* (oc[1])' to get the newest file in a directory or '* (oc[1,5])' to get the newest 5 or so. Neither should have a space between the asterisk and the brace, I added so HN would not turn it into italics. * Timestamps In History File Now that I mentioned the history, I notice that zsh has each command time-stamped in the history file while bash does not. I remember using this before to look for a command I remember doing in a time-range of a month of so years back from then. * By Default Enabled Terminal Paste Protection By Bracket Escape Sequences By default if you paste stuff in a terminal with bash and it contains, for example, newlines, it will execute it. zsh on the other hand will put everything as a multiline command and wait for you to hit Enter, allowing you to edit, before executing. There's been times when I've accidently pasted paragraphs of text and this saved me from executing who knows what. If you use a terminal that asides from bracketing pastes in a special escape sequence, also ensures that what you paste cannot include the closing bracket by e.g. filtering it out, then you can paste code from the browser directly without worries of css or javascript shenanigans causing you to run hidden code without seeing it first. I wrote an SE answer showing how to configure urxvt for that once: https://security.stackexchange.com/questions/39118/how-can-i-protect-myself-from-this-kind-of-clipboard-abuse/184112#184112 https://security.stackexchange.com/questions/39118/how-can-i... * Short-hand compound statements You can for example skip the do-done in a for loop and the then-fi in an if conditional if you only got one command to run: for p in *; if [[ $p == *-yesod ]] echo "==$p" && git -C "$p" remote -v * Dynamic directories I can't find support for this in bash. Basically, you can extend the use of '~' to not only be shortcuts to home directories, but also directories of your chosing as if they were bookmarks. For example, say I have my software projects in directories like ~/work-for/client/some_client/some_project, I can refer to it simply as ~some_project. The neat thing about this over, say, a simple variable is that file completion recognizes it and allows me to work with it without having to expand it. * Others I've also found use in anonymous functions, menu complete, and other stuff, but I think I've covered the most important for me.