Skip to content

Instantly share code, notes, and snippets.

@gcollic
Last active February 28, 2020 14:58
Show Gist options
  • Save gcollic/1cec481e49593adafac6bc2f9fb712aa to your computer and use it in GitHub Desktop.
Save gcollic/1cec481e49593adafac6bc2f9fb712aa to your computer and use it in GitHub Desktop.
BBL Zsh

BBL Zsh and other command line goodies

Notes on the "how", complementing the demo about the "why".

Make Zsh the default shell

chsh -s $(which zsh)

Install Oh-My-Zsh

ohmyz.sh

Plugin manager and other cool things.

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

Theme

Font with usefull icons

www.nerdfonts.com / downloads

Install a "Nerd Font", with usefull icons included, then configure your terminal to use it. I recommend JetBrainsMono Nerd Font.

Fast and highly customizable theme

Don't use the one provided, they are obsolete and slow. I recommend Powerlevel10k which is fast, have great defaults, a simple configuration form (in command line), and can be customized to look like some other popular ones like pure.

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc.

Launch Zsh and complete configuration.

gitfast

Simpler and faster git integration plugin.

Just add gitfast to the .zshrc plugin list (plugins=(...)).

Fasd

GitHub clvv/fasd / Installation

Like autojump and z, fasd adds more command line for quick action (cd / vim / open / etc) by letting the machine figure out what file or folder you are talking about, loosely matching your history.

Some commands :

  • z
    • smart cd
  • v
    • smart vi
  • o
    • smart open file
  • f
    • smart print full path (to incorporate fasd intelligence in other command)

See link for install depending on your OS, then add fasd to the .zshrc plugin list (plugins=(...)).

zsh-autosuggestions

GitHub zsh-users/zsh-autosuggestions / Installation

Autocompletion suggestions.

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Then add zsh-autosuggestions to the .zshrc plugin list (plugins=(...)).

TheFuck

GitHub nvbn/thefuck / Installation

After a botched command, type fuck to have suggestions on the corrected command, and validate the new one with enter. For exemple, with a failed git push new_local_branch, it proposes automatically the better git push --set-upstream origin new_local_branch.

After installation, add this to your ~/.zshrc :

eval $(thefuck --alias)

Python Pyenv

GitHub pyenv/pyenv / Installation

After installation, add this to ~/.zshrc

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# pyenv-virtualenv: prompt changing will be removed from future release.
# configure to simulate the behavior.
export PYENV_VIRTUALENV_DISABLE_PROMPT=1

Then add pyenv in the plugin list already in this file (plugins=(...)).

Fix powerlevel10k right prompt

If you use a powerlevel10k theme, you might have duplicated information (virtualenv + pyenv). In your ~/.p10k.zsh file, comment out virtualenv from POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS.

Specific pip conf by pyenv environment

If some of your pyenv environment needs a specific pip conf but not all of them, you can create a function which configure the current pyenv environment with a specifice pip conf like this :

# Set a specific pip conf for the current pyenv environment
setspecificpipconf () {
   ln -s /XXX/SPECIFIC_pip.conf `pyenv prefix`/pip.conf
}

Bat

GitHub sharkdp/bat / Installation

Like cat, but with syntax highlighting and git status line indicator.

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