Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save n1snt/454b879b8f0b7995740ae04c5fb5b7df to your computer and use it in GitHub Desktop.
Save n1snt/454b879b8f0b7995740ae04c5fb5b7df to your computer and use it in GitHub Desktop.
Oh my ZSH with zsh-autosuggestions zsh-syntax-highlighting zsh-fast-syntax-highlighting and zsh-autocomplete.md

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Install plugins.

  • autosuggesions plugin

    git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

  • zsh-syntax-highlighting plugin

    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

  • zsh-fast-syntax-highlighting plugin

    git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting

  • zsh-autocomplete plugin

    git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $ZSH_CUSTOM/plugins/zsh-autocomplete

Enable plugins by adding them to .zshrc.

  • Open .zshrc

    nvim ~/.zshrc

  • Find the line which says plugins=(git).

  • Replace that line with plugins=(git zsh-autosuggestions zsh-syntax-highlighting fast-syntax-highlighting zsh-autocomplete)

References

@vimkim
Copy link

vimkim commented Jun 13, 2024

This is a time saver so useful

@basit26374
Copy link

It's a time saver. Thanks

btw, I got error during clone repo.

➜ ~ git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting
Cloning into '/home/abdul-basit/.oh-my-zsh/custom/plugins/fast-syntax-highlighting'...
remote: Enumerating objects: 3365, done.
remote: Counting objects: 100% (97/97), done.
remote: Compressing objects: 100% (64/64), done.
error: RPC failed; curl 56 GnuTLS recv error (-9): Error decoding the received TLS packet.
error: 7746 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

@ahmedhosnypro
Copy link

ahmedhosnypro commented Jun 13, 2024

for perfiction
faster to configure above plugins, assuming fresh install

sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting fast-syntax-highlighting zsh-autocomplete)/g' ~/.zshrc

@mooxiu
Copy link

mooxiu commented Jun 24, 2024

他们不能正常工作! 我的终端随机崩溃,我不知道为什么 我猜 zsh-autocomplete 与其他终端冲突, 特别是当我按下上一个命令的向上箭头时,有时整个终端崩溃, 我不确切知道,但问题可能来自快速语法突出显示

follow these steps:

1. `cd $ZSH_CUSTOM/plugins/zsh-autocomplete`

2. `git pull --tags`

3. `git reset --hard 23.05.24`

This is a bug of zsh-autocomplete, see issue marlonrichert/zsh-autocomplete#645 and do not use the main/HEAD until a fix.

This is gold, thanks!

@VidarrKerr
Copy link

Thank Yooooooooooooooouuuuuuuuuuuuuuuuuuuu!

@cleitonpena
Copy link

It's never been so uncomplicated. Congratulations to you, n1snt

@renatoastra
Copy link

Thanks for you hard work on this.

@to3d
Copy link

to3d commented Aug 11, 2024

I love it so much

@bellaj
Copy link

bellaj commented Aug 17, 2024

thanks for the gist

@Gsantomaggio
Copy link

Thank you

@mrhassell
Copy link

他们不能正常工作! 我的终端随机崩溃,我不知道为什么 我猜 zsh-autocomplete 与其他终端冲突, 特别是当我按下上一个命令的向上箭头时,有时整个终端崩溃, 我不确切知道,但问题可能来自快速语法突出显示

follow these steps:

  1. cd $ZSH_CUSTOM/plugins/zsh-autocomplete
  2. git pull --tags
  3. git reset --hard 23.05.24

This is a bug of zsh-autocomplete, see issue marlonrichert/zsh-autocomplete#645 and do not use the main/HEAD until a fix.

  • [new tag] 23.05.24 -> 23.05.24
  • [new tag] 23.07.13 -> 23.07.13

That's all. It's fixed.

@davidj4tech
Copy link

davidj4tech commented Sep 7, 2024

If I may have everyone's attention, I'm looking for a way to have aliases being suggested to me while I'm typing a full command.

And maybe even vice versa, so that you don't lose track of the command hidden behind the alias.

Did you happen to find a solution for this?

Nishant: great tip by the way. I love it!

@mpartipilo
Copy link

If I may have everyone's attention, I'm looking for a way to have aliases being suggested to me while I'm typing a full command.

And maybe even vice versa, so that you don't lose track of the command hidden behind the alias.

Did you happen to find a solution for this?

Unfortunately no. Your idea of a preview of the alias expansion sounds good as well.

I have been thinking of heading down the rabbit hole of writing my own ZSH plugin. I have tried looking into how zsh-autosuggestions works, but the ZSH code looks to me like dark magic.

@sshailabh
Copy link

Thanks for writing it down.

@gloatoriginal
Copy link

My friend turned me onto zsh & omz recently, love this write up thank you!

@mrhassell
Copy link

If I may have everyone's attention, I'm looking for a way to have aliases being suggested to me while I'm typing a full command. Does anyone know a way to do this? So far I have only found omz plugins alias-tips and alias-finder, but those only show the alias tips after the command has been executed, which usually goes off screen with the command's output and requires scrolling back to see them.

e.g.

 ↳  git
Alias tips:
g=git
ga='git add'
gb='git branch'
gc='git commit --verbose'
gd='git diff'
gf='git fetch'
gg='git gui citool'
gl='git pull'
gm='git merge'
gp='git push'
gr='git remote'

I'm not sure that you want g for git... ;)

@mpartipilo
Copy link

If I may have everyone's attention, I'm looking for a way to have aliases being suggested to me while I'm typing a full command. Does anyone know a way to do this? So far I have only found omz plugins alias-tips and alias-finder, but those only show the alias tips after the command has been executed, which usually goes off screen with the command's output and requires scrolling back to see them.
e.g.

 ↳  git
Alias tips:
g=git
ga='git add'
gb='git branch'
gc='git commit --verbose'
gd='git diff'
gf='git fetch'
gg='git gui citool'
gl='git pull'
gm='git merge'
gp='git push'
gr='git remote'

I'm not sure that you want g for git... ;)

I agree with you. That alias is part of the Oh-My-Zsh plugin. If I typed ‘git’ and I saw ‘g’ as a proposed alias I would likely delete it right away.

Anyway, it looks like I’ll have to develop the feature I want by myself. That’s part of the beauty of it, right?

@mrhassell
Copy link

101%! Open sauce, hot dog! Out of interest, are you working on a port, or customisation for your own needs? Either way, I highly recommend checking out; starship.rs = best wishes! :)

@matijaoe
Copy link

matijaoe commented Oct 2, 2024

Do we want to mix all of those? Aren't some of them competing?

@mrhassell
Copy link

or complimenting?

@matijaoe
Copy link

@mrhassell I do not know, that's why I'm asking 🙂 I'm all for them complimenting each other.

@chojuninengu
Copy link

this is so amazing

@Eboubaker
Copy link

Eboubaker commented Nov 7, 2024

in the end of .zshrc add these lines to stop zsh-autocomplete from overriding <- and -> keys to make the menu cursor move

bindkey -M menuselect "^[OD"   .backward-char # ←
bindkey -M menuselect "^[OC"    .forward-char # →
bindkey -M menuselect "^[b"    .backward-word # ⌥ + ←
bindkey -M menuselect "^[f"     .forward-word # ⌥ + →
bindkey -M menuselect "^A" .beginning-of-line # ⌘ + ←
bindkey -M menuselect "^E"       .end-of-line # ⌘ + →

now it will move inside the command itself, hope this helps!

@SterlingReeves
Copy link

Thank you so much for your help.

@scardracs
Copy link

This is the most useful gist I've seen in a while! Ty!

@slevysh
Copy link

slevysh commented Nov 19, 2024

For what use both plugins zsh-syntax-highlighting and fast-syntax-highlighting instead one of them?

@Sh4dowKaix64
Copy link

Woww thanks

@LeAnhTuan12101994
Copy link

Thanks <3

@gloatoriginal
Copy link

Thank you for the write-up and easy to install commands, I have installed this on all my linux machines and each time it's cut-and-dry copy-and-paste commands, thank you!

@seungjulee
Copy link

I find fzf-tab to be better than zsh-autocomplete. You can't use both as it collides.

refer to this gist if you wanna use fzf for autocomplete

https://gist.github.com/seungjulee/d72883c193ac630aac77e0602cb18270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment