> Ctrl-q "parks" the command What is the zsh functionality behind this? I couldn't test it because my terminal eats Ctrl-q and a search for "zsh ctrl-q" didn't turn up anything useful.
Yes please -- this sounds great, I used to use `ctrl-u` then `ctrl-y` with bash, and that doesn't work with zsh, alas. I tried searching for `zsh "park" command` and got nothing useful.
Zsh Tricks to Blow Your Mind
151–160 of 218 posts
Re: Zsh Tricks to Blow Your Mind
#152Earlier quoted context omitted.
As many others here have noted, terse syntax for things like `repeat` loops or normal `for`/`while` loops or shell var expansion can all be addictive, but some specific things I miss in Bash that are easy in Zsh are: 1) auto cd to any evar just from its name e.g. lb=/usr/local/bin; lb ($lb works in bash, but I always forget the $. I know I could do aliases...Yuck.) 2) auto cd does not seem to use $CDPATH this is a re…
> Zsh's extended history format that includes both the time started as well as duration of all my commands. Woah, how do I enable this? From what I can tell this information is not being stored in $HISTFILE: ... : 1613659860:0;sleep 1 : 1613659863:0;sleep 3 : 1613659871:0;exec zsh : 1613659880:0;vim $HISTFILE
From the Zsh man page:
EXTENDED_HISTORY Save each command's beginning timestamp (in seconds since the epoch) and the duration (in seconds) to the history file. The format of this prefixed data is: `: :;'.
(EDIT: My best guess explanation is some competing/conflicting setopt, but the Zsh mailing list could almost surely help you. Also, `history -fD` may show the correct answer even if the saved file has all 0s.)
Re: Zsh Tricks to Blow Your Mind
#153My favourite feature of zsh (it might be oh-my-zsh), is the tab expansion of unambiguous abbreviated paths. Say if you do: $ cd /u/b/l That will expand into /usr/bin/local. If there are ambiguities at any point, it will expand as much as it can and let you fix it at the point where a decision needs to be made (pressing tab again will show you the options, like Bash et al). For example: $ /u/b/gr $ /usr/bin/gr grep gr…
Re: Zsh Tricks to Blow Your Mind
#154Earlier quoted context omitted.
> Zsh's extended history format that includes both the time started as well as duration of all my commands. Woah, how do I enable this? From what I can tell this information is not being stored in $HISTFILE: ... : 1613659860:0;sleep 1 : 1613659863:0;sleep 3 : 1613659871:0;exec zsh : 1613659880:0;vim $HISTFILE
Not sure why you are getting all zeros in your duration column. Should be setopt ExtendedHistory (Zsh setopts, like Nim identifiers, are "style insensitive"). From the Zsh man page: EXTENDED_HISTORY Save each command's beginning timestamp (in seconds since the epoch) and the duration (in seconds) to the history file. The format of this prefixed data is: `: : ; '. (EDIT: My best guess explanation is some competing/con…
Re: Zsh Tricks to Blow Your Mind
#155None of these blew my mind. If you like terminal productivity I recommend: fzf, Facebook path picker (aka fpp), fd, ripgrep, lf, tig. Some honorable mentions: tokei, hyperfine, lazydocker, ctop, ncspot.
Re: Zsh Tricks to Blow Your Mind
#156Been using zsh for years and many of these were new to me. I love #3 and use it daily. I find it most helpful to use this trick to type ".." or "..." and quickly navigate back a dir or two. Of course you can do this in bash (and other shells) with aliases, it does not come out of the box like so many niceties in zsh.
I have a favorite alias `u` (stands for "up") to go up a directory. 50% keystroke savings ;)
.() { if [ $# -eq 0 ]; then cd ..; else source $\*; fi; }
then alias ..='cd ../..'
alias ...='cd ../../..'
.
.
So that "however many periods" goes up however many directory levels. Seems a coherent shorthand to me,
though I guess uuuu also works.Re: Zsh Tricks to Blow Your Mind
#157Earlier quoted context omitted.
Yes please -- this sounds great, I used to use `ctrl-u` then `ctrl-y` with bash, and that doesn't work with zsh, alas. I tried searching for `zsh "park" command` and got nothing useful.
It's a feature of the zsh line editor called "push-line". http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
bindkey '^q' push-line
works perfectly. Day improved!Re: Zsh Tricks to Blow Your Mind
#158Earlier quoted context omitted.
Not sure why you are getting all zeros in your duration column. Should be setopt ExtendedHistory (Zsh setopts, like Nim identifiers, are "style insensitive"). From the Zsh man page: EXTENDED_HISTORY Save each command's beginning timestamp (in seconds since the epoch) and the duration (in seconds) to the history file. The format of this prefixed data is: `: : ; '. (EDIT: My best guess explanation is some competing/con…
Thank you! How strange. `history -fD` does work, but only for commands in the current zsh session. It seems durations are being stored in memory but written out as 0's. I'll try the mailing list soon :)
[1] https://unix.stackexchange.com/questions/396809/zsh-share-hi...
Re: Zsh Tricks to Blow Your Mind
#159A lot of these can be easily done in Bash, too! 1. `mkcdir () { mkdir -- "$1" && cd -- "$1"; }` 2a. `bind '"\e[A":history-search-backward'; bind '"\e[B":history-search-forward'` 2b. Default behavior for Bash. 3. `shopt -s autocd` 4. `mmv`, `perl-rename` 5. `qalc` from libqalculate: https://github.com/Qalculate/libqalculate 8. Default behavior for Bash. 9. Default behavior for Bash.
This is always my complaint about posts like this. I read them looking for the killer feature to make me consider switching from bash and it's always stuff bash does natively or with a one line alias.