I was editing my .zshrc the other day and wondered what cool things people are doing with it.
Here's my config
# Created by manan for 4.4.2
#Customise the Powerlevel9k prompts
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
ssh
dir
vcs
newline
status
)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
# POWERLEVEL9K_RPROMPT_ON_NEWLINE=true
# POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND='red'
# POWERLEVEL9K_BATTERY_DISCONNECTED_BACKGROUND='blue'
# Options for setting colors to directories.
# POWERLEVEL9K_DIR_HOME_BACKGROUND=red
# POWERLEVEL9K_DIR_HOME_FOREGROUND=white
# POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND=red
# POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND=white
POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_BACKGROUND=yellow
POWERLEVEL9K_DIR_WRITABLE_FORBIDDEN_FOREGROUND=black
# POWERLEVEL9K_DIR_DEFAULT_BACKGROUND=red
# POWERLEVEL9K_DIR_DEFAULT_FOREGROUND=white
# Load Nerd Fonts with Powerlevel9k theme for Zsh
POWERLEVEL9K_MODE='nerdfont-complete'
source ~/Spaces/Editor-Settings/powerlevel9k/powerlevel9k.zsh-theme
HOMEBREW_FOLDER="/usr/local/share"
source "$HOMEBREW_FOLDER/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
source "$HOMEBREW_FOLDER/zsh-autosuggestions/zsh-autosuggestions.zsh"
source "$HOMEBREW_FOLDER/zsh-history-substring-search/zsh-history-substring-search.zsh"
autoload -Uz compinit;
typeset -i updated_at=$(date +'%j' -r ~/.zcompdump 2>/dev/null || stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null)
if [ $(date +'%j') != $updated_at ]; then
compinit -i
else
compinit -C -i
fi
zmodload -i zsh/complist
#History setup
HISTFILE=$HOME/.zsh_history
HISTSIZE=100000
SAVEHIST=$HISTSIZ
setopt hist_ignore_all_dups # remove older duplicate entries from history
setopt hist_reduce_blanks # remove superfluous blanks from history items
setopt inc_append_history # save history entries as soon as they are entered
setopt share_history # share history between different instances of the shell
setopt auto_cd # cd by typing directory name if it's not a command
setopt correct_all # autocorrect commands
setopt auto_list # automatically list choices on ambiguous completion
setopt auto_menu # automatically use menu completion
setopt always_to_end # move cursor to end if word had one match
zstyle ':completion:*' menu select # select completions with arrow keys
zstyle ':completion:*' group-name '' # group results by category
zstyle ':completion:::::' completer _expand _complete _ignored _approximate #enable approximate matches for completion
#Plugins setup
source <(antibody init)
antibody bundle zdharma/fast-syntax-highlighting > ~/.zshrc.log
antibody bundle zsh-users/zsh-autosuggestions > ~/.zshrc.log
antibody bundle zsh-users/zsh-history-substring-search > ~/.zshrc.log
antibody bundle zsh-users/zsh-completions > ~/.zshrc.log
antibody bundle /Users/manan/Spaces/Editor-Settings/ZSH-Plugins/oh-my-zsh-master/plugins/osx > ~/.zshrc.log
# antibody bundle robbyrussell/oh-my-zsh path:plugins/heroku > ~/.zshrc.log
antibody bundle robbyrussell/oh-my-zsh path:plugins/node > ~/.zshrc.log
antibody bundle robbyrussell/oh-my-zsh path:plugins/web-search > ~/.zshrc.log
antibody bundle robbyrussell/oh-my-zsh path:plugins/sudo > ~/.zshrc.log
antibody bundle robbyrussell/oh-my-zsh path:plugins/react-native > ~/.zshrc.log
# antibody bundle robbyrussell/oh-my-zsh path:plugins/kubectl > ~/.zshrc.log
# antibody bundle robbyrussell/oh-my-zsh path:plugins/npm > ~/.zshrc.log
antibody bundle JamesKovacs/zsh_completions_mongodb > ~/.zshrc.log
source /usr/local/aws/bin/aws_zsh_completer.sh
autoload -Uz compinit;compinit -i
# Aliases
alias grep=ack
alias digitalocean="ssh digitalocean"
alias ls="colorls"
alias python="python3"
alias pip="pip3"
alias easy-install="easy_install-3.7"
alias config="vi $HOME/.zshrc"
alias projects="cd $HOME/Spaces/Projects"
alias reload="source $HOME/.zshrc"
# Git aliases
alias gi="git init"
alias gs="git status -sbu"
alias gco="git checkout"
alias gcob="git checkout -b"
alias gp="git push"
alias gm="git merge"
alias ga="git add ."
alias gcm="git commit -m"
alias gpl="git pull"
alias gst="git stash"
alias gstl="git stash list"
alias glg='git log --graph --oneline --decorate --all'
# Exports
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-toolsz
export GOPATH=/Users/manan/.golib
export PATH=$GOPATH/src:$PATH
export GOPATH=$GOPATH:/Users/manan/Spaces/Projects/Go
export PATH="/usr/local/opt/libpcap/bin:$PATH"
fpath=(/usr/local/share/zsh-completions $fpath)
export PATH="/usr/local/opt/icu4c/bin:$PATH"
export PATH="/usr/local/opt/icu4c/sbin:$PATH"
export PYTHON3PATH=/Library/Frameworks/Python.framework/Versions/3.7
export PATH=$PYTHON3PATH/bin:$PATH
export PATH=/usr/local/aws/bin:$PATH
export PATH=$PATH:$HOME/sdk/flutter/bin
# added by travis gem
[ -f /Users/manan/.travis/travis.sh ] && source /Users/manan/.travis/travis.sh
# Misc
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# Tab title
precmd() {
# sets the tab title to current dir
echo -ne "\e]1;${PWD##*/}\a"
}
# Create a new react app
react-app() {
npx create-react-app $1
cd $1
npm i -D eslint
npm i -D eslint-config-prettier eslint-plugin-prettier
npm i -D eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks
cp "${HOME}/.eslintrc.json" .
cp "${HOME}/.prettierrc" .
echo $1 > README.md
rm -rf yarn.lock
cd src
rm -f App.css App.test.js index.css logo.svg serviceWorker.js
mkdir components views
git add -A
git commit -m "Initial commit."
cd ..
clear
code .
}
Feel free to show your .bashrc
or any other configs that you have. You can find my collection here.
Top comments (19)
I've always liked adding this little snippet to my .zshrc:
So just use
editZsh
to edit your .zshrc and it will be safe!When switching machines, I only have to get my .zshrc from the Drive and here we go again.
Hey Tommy, I actually use yadm to manage my dotfiles. They are then pushed on to GitHub here. So whenever I want to set up a new machine the only thing I need to do is just clone that repo.
Thanks for sharing. I improved my .zshrc a lot since I saw this post. As I use my .zshrc on different machines I implemented an update before the edit.
And as I search for quite often for some strings inside of files I wrote a "find in files" function
Nice, I usually just version my entire Home directory, the process being to first add a .gitignore with * so that by default everything is ignored, and then I can force-add whatever I want to version (remember gitignore doesn't apply to anything that is already versioned).
That way I can also version my fonts folder, background-images folder and whatnot.
Duh.... that is a great idea!!
D'oh! I should've known something like this exists - I'm gonna dive into that, thanks!
I think most people just install oh-my-zsh and forget about .zshrc. Is what I did at first. So I think the first place to look is the oh-my-zsh repository, they have some really useful stuff in the plugins folder.
This are my favorite.
They do a little bit of magic in another file to make sure terminfo has a value.
I actually uninstalled oh-my-zsh and kept what I needed. The zsh specific stuff is here. And what is (mostly) POSIX compliant is here.
I 100% agree with this I think most people just install oh-my-zsh and forget about .zshrc.
I was one of those until today, I'd never thought about how handy could be to have some aliases here and there
I am not 100% certain if aliasing actually saves some time but it sure does save you some keyboard clicks.
I use
fish
.But before i switched, i used a plain
oh-my-zsh
with some plugins made by myself. I really liked it, and occasionally miss it. However, despite a few quirks, i don’t regret switching tofish
for my interactive sessions; scripting is still better in good oldbash
or, if portability is a must, plainsh
.I love your react-app shortcut!
Thanks a lot
FYI: There is powerlevel10k now.
Nice, but why ? The project says it's a drop-in replacement for powerlevel9k but then why not just use the original ? It's still active as far as I know so is there some sort of issue why I would want to use the replacement ?
This is an honest question, and if the answer turns out to be why-not, well I'm down with that answer as well, after all that's the beauty of open-source.
Not quite. Here's what it says:
I guess this depends on one's point of view. Commit activity graph shows last commit in March.
Cool. Thanks for the quick reply and insight on the differences between the two projects.
I'm quite a sucker for 'fast' and lightweight, so now I'm going to have to try it.
It would be very cool to see what your terminal looks like! Could you attach a screenshot that shows the result of your configs?
Sure Louis here it is.