Terminal shell tweaks: zsh!

I’m ok with the p10k prompt in zsh.

Something I just implemented that is pretty good (as I often forget longer commands) is expanding alias commands.

I had an issue last month with Plex not coping with h265 video, so I went in the folder and spent a while working out a line which I then put into an alias…

alias convertmkv-mp4='for i in *.mkv; do ffmpeg -i "$i" -c:a copy -c:v copy "${i%.*}.mp4"; done'

Normally executing an ‘alias’ you don’t see the command.

#-------- Global Alias {{{
globalias() {
  if [[ $LBUFFER =~ '[a-zA-Z0-9]+$' ]]; then
    zle _expand_alias
    zle expand-word
  fi
  zle self-insert
}
zle -N globalias
bindkey " " globalias                 # space key to expand globalalias
#}}}

Awesomeness is now level 10…
1 basic idea (helped with autocomplete)
hit space…
2

My personal choices:

Fish for daily shell. Bash or zsh for most scripting. Used zsh on Mac, like better than bash.

Starship prompt is awesome.

Agree with recommendation to create aliases. If using zsh, create a .zsh folder, add allasrc or similar file, and source from .zshrc file. Keeps your .zshrc file less cluttered.

Terminal emulator: after trying many, I’ve found the following to be really good:

alacritty
kitty

I love kitty, it is my first choice. The config is great, it has much of the functionality of tmux, etc. Great terminal emulator!

1 Like

Yes, I had issues with Alacritty - it needs workarounds to run the right size on xorg at 1080p without setting a 3.166666 pixel (Massive) dpi, and the config file is tougher to deal with, so Kitty came out on top.

However, I do miss the ability (with Konsole) to grab a mouse, select text and have a context menu to search internet…

The point with the ALIASes is that they’re actually not a good thing - but now I made it so that after typing the alias, when I press SPACE bar it enters the full text of the alias. I never realised you could do that before today…

That works with Konsole:

I think that is what he is saying. He is using kitty now but misses that ability that konsole had.

2 Likes

Oh, I see… I though it was “With Konsole I miss the ability to search…”

1 Like

honka_animated-128px-36

1 Like

f
flobbadob
But not a dealbreaker…

I haven’t tried kitty yet, but I’ve just started using Alacritty about 2 weeks ago. It is really good. Its very fast and simple. The config isn’t as confusing to me.

Alacritty is my choice, kitty has problems (for me) with espanso, some characters expand incorrectly, e.g. somebody@email.com expands to somebody"email.com (not that I need my email to expand in a terminal!).

@Ben no need to scale Alacritty - just change your font size :wink:

I found a really cool extension last week, but cannot remember it’s name! It expands aliases, so for example, “mm” becomes " | more", will post it’s name when I get home…

Changing font size doesn’t work at all - it needs an override WINIT_X11_SCALE_FACTOR because scaling is determined after the initial launch - TBH I find it amazing that a freshly installed terminal just can’t launch right. -10 stars from me on that aspect (like - why bother?)

Also, KiTTY is actually a bit faster than Alacritty.

Where they differ:
Kitty has better performance than Alacritty. Though Redditors are highly intelligent and state plainly “I use alacritty as my daily driver. Why? Because Rust!”. Personally I’m still okay with C++ (",)

Kitty documentation is far superior to Alacritty and as such it’s far easier to use. Depending on the desktop (whether I’m tiled/floating etc) the tab, tile (and tiling layout switching) and new window shortcuts are extremely flexible.

For customisation/config, Kitty is very superior (maybe 80% vs 50% for Alacritty) though not as easily configured as Konsole.

I get no resize rendering issues with Kitty, Alacritty is no different from Konsole in that regard.

Alacritty maintainer has even less social skills than Kitty’s.

Oh, and did I mention Splits and Tabs - great for handy manpages.

Ranger is wicked in Kitty - with nice image support too…

Stupid stuff:
Mod+F2 opens config in your editor of choice
Mod+? opens your keybindings

1 Like

Thanks for saying this, because it made me look at some things in the fish docs and then light bulb!!! I don’t want aliases anymore in fish, I want ABBR.

I converted 40+ aliases into abbr, and they do exactly what you are describing, right out of the box. The syntax is a bit different:

abbr dog 'cd ~/dog`

alias dog='cd ~dog'

An abbr substitutes the full command upon pressing spacebar. I love it. I think I’ve had that functionality for aliases before in a terminal on my old Mac, but can’t remember for certain. At any rate, I’m sold. I’ve even taken all my personal fish functions and made an abbr for them. Works much better!!

2 Likes

This is really cool! Searching my command history will actually make a lot more sense now.

2 Likes