switch to zsh

This commit is contained in:
Matthias Kretschmann 2019-08-18 02:07:17 +02:00
parent cfa1231b94
commit 0c64970cf4
Signed by: m
GPG Key ID: 606EEEF3C479A91F
16 changed files with 73 additions and 421 deletions

View File

@ -6,7 +6,6 @@ before_install:
- sudo apt-get install -y shellcheck
script:
- bash -c 'shopt -s globstar; shellcheck **/bash*'
- bash -c 'shopt -s globstar; shellcheck **/*.sh'
matrix:

View File

@ -1,9 +1,4 @@
#!/usr/bin/env bash
# ----------------------------------------------------------------------
# ALIASES
# ----------------------------------------------------------------------
alias ll='ls -la'
# Easier navigation: .., ..., ~

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
# Set architecture flags
export ARCHFLAGS="-arch x86_64"
# Prefer US English and use UTF-8
export LC_ALL="en_US.UTF-8"
export LANG="en_US"
# LSCOLORS
export CLICOLOR=1
export LSCOLORS=gxfxcxdxbxegedabagacad
# pip should only run if there is a virtualenv currently activated
#export PIP_REQUIRE_VIRTUALENV=true
# cache pip-installed packages to avoid re-downloading
# export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache
# go
export GOPATH=$HOME/.go
export GOROOT=/usr/local/opt/go/libexec
# ffi
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

View File

@ -1,47 +0,0 @@
#!/usr/bin/env bash
# adapted based on https://github.com/necolas/dotfiles/blob/master/shell/bash_paths
# Directories to be prepended to PATH
declare -a dirs_to_prepend=(
"/usr/local/sbin"
"/usr/local/bin" # Ensure that this bin always takes precedence over `/usr/bin`
# "$(brew --prefix node)/bin" # Add npm/yarn-installed package bin
"$(brew --prefix openssl)/bin" # Add newer OpenSSL
"$(brew --prefix ruby)/bin"
"/usr/local/lib/ruby/gems/2.5.0/bin"
"$GOPATH/bin"
"$GOROOT/bin"
"$HOME/.bin"
# "$HOME/.rvm/bin"
)
# Directories to be appended to PATH
declare -a dirs_to_append=(
"/usr/bin"
)
# Prepend directories to PATH
for index in ${!dirs_to_prepend[*]}
do
if [ -d "${dirs_to_prepend[$index]}" ]; then
# If these directories exist, then prepend them to existing PATH
PATH="${dirs_to_prepend[$index]}:$PATH"
fi
done
# Append directories to PATH
for index in ${!dirs_to_append[*]}
do
if [ -d "${dirs_to_append[$index]}" ]; then
# If these bins exist, then append them to existing PATH
PATH="$PATH:${dirs_to_append[$index]}"
fi
done
unset dirs_to_prepend dirs_to_append
export PATH
# define CDPATHs which are autocompleted from when doing cd
export CDPATH=$CDPATH:~/Code

View File

@ -1,130 +0,0 @@
#!/usr/bin/env bash
########################################################################
# bash_profile, basically from the whole internet
# and a lot from @necolas, @mathiasbynens & @rtomayko
#
# https://github.com/mathiasbynens/dotfiles
# https://github.com/necolas/dotfiles
# https://github.com/rtomayko/dotfiles
########################################################################
# shellcheck source=/dev/null
# ----------------------------------------------------------------------
# Load ~/.private, ~/.bash_prompt
# ----------------------------------------------------------------------
for FILE in ~/.{bash_exports,bash_paths,bash_prompt,bash_aliases,private,inputrc}; do
[ -r "$FILE" ] && [ -f "$FILE" ] && source "$FILE"
done;
unset FILE;
# ----------------------------------------------------------------------
# SHELL OPTIONS
# ----------------------------------------------------------------------
# Append to the Bash history file, rather than overwriting it
shopt -s histappend
# Save multi-line commands as one command
shopt -s cmdhist
# Avoid duplicate entries
HISTCONTROL="erasedups:ignoreboth"
# Don't record some commands
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear"
# fuck that you have new mail shit
unset MAILCHECK
# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob
# Turn on recursive globbing (enables ** to recurse all directories)
shopt -s globstar 2> /dev/null
# Prepend cd to directory names automatically
shopt -s autocd 2> /dev/null
# Correct spelling errors during tab-completion
shopt -s dirspell 2> /dev/null
# Correct spelling errors in arguments supplied to cd
shopt -s cdspell 2> /dev/null
# Update window size after every command
shopt -s checkwinsize
# Automatically trim long paths in the prompt (requires Bash 4.x)
PROMPT_DIRTRIM=4
# Enable some Bash 4 features when possible:
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
# * Recursive globbing, e.g. `echo **/*.txt`
for option in autocd globstar; do
shopt -s "$option" 2> /dev/null;
done
# Add tab completion for many Bash commands
if command -v brew &> /dev/null && [ -f "$(brew --prefix)/share/bash-completion/bash_completion" ]; then
source "$(brew --prefix)/share/bash-completion/bash_completion";
elif [ -f /etc/bash_completion ]; then
source /etc/bash_completion;
fi
if type brew 2&>/dev/null; then
for completion_file in "$(brew --prefix)"/etc/bash_completion.d/*; do
source "$completion_file"
done
fi
# Perform file completion in a case insensitive fashion
bind "set completion-ignore-case on"
# Treat hyphens and underscores as equivalent
bind "set completion-map-case on"
# Display matches for ambiguous patterns at first tab press
bind "set show-all-if-ambiguous on"
# Immediately add a trailing slash when autocompleting symlinks to directories
bind "set mark-symlinked-directories on"
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2- | tr ' ' '\n')" scp sftp ssh;
# Add `killall` tab completion for common apps
complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal" killall;
# aws-cli tab completion
complete -C aws_completer aws
# ----------------------------------------------------------------------
# rvm
# ----------------------------------------------------------------------
# Load RVM into a shell session *as a function*
# shellcheck source=/dev/null
# [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
# ----------------------------------------------------------------------
# nvm
# ----------------------------------------------------------------------
if [ -s "$HOME/.nvm" ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
fi
# ----------------------------------------------------------------------
# ssh hack for SSH_AUTH_SOCK
# ----------------------------------------------------------------------
if [ -S "$SSH_AUTH_SOCK" ]; then
unset SSH_AUTH_SOCK
fi

View File

@ -1,125 +0,0 @@
#!/usr/bin/env bash
########################################################################
# bash_prompt, from @mathiasbynens
# slightly modified
# https://github.com/mathiasbynens/dotfiles/blob/master/.bash_prompt
########################################################################
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM='gnome-256color';
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM='xterm-256color';
fi;
prompt_git() {
local s='';
local branchName='';
# Check if the current directory is in a Git repository.
if [ "$(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}")" == '0' ]; then
# check if the current directory is in .git before running git checks
if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then
# Ensure the index is up to date.
git update-index --really-refresh -q &>/dev/null;
# Check for uncommitted changes in the index.
# shellcheck disable=SC2091
if ! $(git diff --quiet --ignore-submodules --cached); then
s+='+';
fi;
# Check for unstaged changes.
# shellcheck disable=SC2091
if ! $(git diff-files --quiet --ignore-submodules --); then
s+='!';
fi;
# Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?';
fi;
# Check for stashed files.
# shellcheck disable=SC2091
if $(git rev-parse --verify refs/stash &>/dev/null); then
s+='$';
fi;
fi;
# Get the short symbolic ref.
# If HEAD isnt a symbolic ref, get the short SHA for the latest commit
# Otherwise, just give up.
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
git rev-parse --short HEAD 2> /dev/null || \
echo '(unknown)')";
[ -n "${s}" ] && s=" ${s}";
echo -e "${1}${branchName}${orange}${s}";
else
return;
fi;
}
# shellcheck disable=SC2034
if tput setaf 1 &> /dev/null; then
tput sgr0; # reset colors
bold=$(tput bold);
dim=$(tput setaf 8);
reset=$(tput sgr0);
black=$(tput setaf 16);
gray=$(tput setaf 8);
blue=$(tput setaf 4);
green=$(tput setaf 2);
cyan=$(tput setaf 6);
orange=$(tput setaf 3);
purple=$(tput setaf 5);
red=$(tput setaf 1);
magenta=$(tput setaf 13);
violet=$(tput setaf 13);
white=$(tput setaf 15);
yellow=$(tput setaf 11);
else
bold='';
reset="\e[0m";
black="\e[1;30m";
blue="\e[1;34m";
cyan="\e[1;36m";
green="\e[1;32m";
orange="\e[1;33m";
purple="\e[1;35m";
red="\e[1;31m";
violet="\e[1;35m";
white="\e[1;37m";
yellow="\e[1;33m";
fi;
# Highlight the user name when logged in as root.
if [[ "${USER}" == "root" ]]; then
userStyle="${red}";
else
userStyle="${gray}";
fi;
if [[ "${SSH_TTY}" ]]; then
PS1="\[\033]0;\W • \h\007\]"; # Set the terminal title
PS1+="\n";
PS1+="\[${userStyle}\]\u "; # username
PS1+="\[${orange}\]\h \[${reset}\]"; # host
else
PS1="\[\033]0;\W\007\]"; # Set the terminal title
PS1+="\n";
fi;
PS1+="\[${cyan}\]\w"; # working directory full path
PS1+="\$(prompt_git \" \[${gray}\]\")"; # Git repository details
PS1+="\n";
PS1+="\[${white}\]→ \[${reset}\]"; # `→` (and reset color)
export PS1;
PS2="\[${white}\]→ \[${reset}\]";
export PS2;

4
bashrc
View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
# shellcheck source=/dev/null
[ -n "$PS1" ] && source ~/.bash_profile;

View File

@ -15,16 +15,7 @@ brew upgrade --all
# Install what we need
brew install \
coreutils \
bash \
bash-completion2
# Switch to using brew-installed bash as default shell
if ! grep -F -q '/usr/local/bin/bash' /etc/shells; then
echo '/usr/local/bin/bash' | sudo tee -a /etc/shells;
chsh -s /usr/local/bin/bash;
fi;
brew install \
zsh
git \
node \
wget \

View File

@ -1,17 +0,0 @@
#!/usr/bin/env bash
# Install RVM
curl -sSL https://get.rvm.io | bash
# handle requirements
rvm requirements
# Install a Ruby
rvm install 2.5
rvm use --default 2.5
rvm rubygems latest
# Install gems
gem install \
bundler \
jekyll

View File

@ -10,7 +10,7 @@
set e
# list of files/folders to symlink in homedir
FILES="bash_aliases bashrc bash_profile bash_paths bash_prompt bash_exports gitconfig gitignore hushlogin inputrc private bin tmux.conf vimrc"
FILES="aliases exports private zshrc gitconfig gitignore hushlogin bin tmux.conf vimrc"
# ----------------------------------------------------------------------
# create the private file first, will be symlinked but ignored by git
@ -37,13 +37,6 @@ for FILE in $FILES; do
done
# ----------------------------------------------------------------------
# source what we just created
# ----------------------------------------------------------------------
# shellcheck source=/dev/null
source "$HOME/.bash_profile"
# ----------------------------------------------------------------------
# Homebrew
# ----------------------------------------------------------------------
@ -57,17 +50,22 @@ echo "=============================================$(tput sgr0)"
echo "$(tput setaf 64)---------------------------------------------"
echo " ✓ done$(tput sgr0)"
# Switch to using brew-installed zsh as default shell
if ! grep -F -q '/usr/local/bin/zsh' /etc/shells; then
echo '/usr/local/bin/zsh' | sudo tee -a /etc/shells;
chsh -s /usr/local/bin/zsh;
fi;
# install https://github.com/robbyrussell/oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
npm i -g pure-prompt
# ----------------------------------------------------------------------
# Ruby
# source what we just created
# ----------------------------------------------------------------------
# echo "$(tput setaf 136) Ruby all the things. "
# echo "=============================================$(tput sgr0)"
# ./bin/install-ruby.sh
# echo "$(tput setaf 64)---------------------------------------------"
# echo " ✓ done$(tput sgr0)"
# shellcheck source=/dev/null
source "$HOME/.zshrc"
echo "$(tput setaf 64)============================================="
echo " ✓ all done"

View File

@ -8,7 +8,7 @@
########################################################################
# list of files/folders to symlink in homedir
FILES="bash_aliases bashrc bash_profile bash_paths bash_prompt bash_exports editorconfig gitconfig gitignore hushlogin inputrc private bin tmux.conf vimrc"
FILES="aliases exports private zshrc editorconfig gitconfig gitignore hushlogin bin tmux.conf vimrc"
for FILE in $FILES; do
@ -29,6 +29,6 @@ done
# ----------------------------------------------------------------------
# shellcheck source=/dev/null
source "$HOME/.bash_profile"
source "$HOME/.zshrc"
exit

View File

@ -32,9 +32,12 @@ brew cleanup
echo ""
echo ""
echo "$(tput setaf 3) Update npm"
echo "$(tput setaf 3) Update Node.js & npm"
echo "------------------------------$(tput sgr0)"
# shellcheck source=/dev/null
[ -s "$HOME/.nvm" ] && . "$HOME/.nvm/nvm.sh"
# Update to latest nvm Node.js
nvm install node

25
exports Normal file
View File

@ -0,0 +1,25 @@
# Set architecture flags
export ARCHFLAGS="-arch x86_64"
# Prefer US English and use UTF-8
export LC_ALL="en_US.UTF-8"
export LANG="en_US"
# ---------------------------------------------------
# PATH
# ---------------------------------------------------
export PATH=$HOME/.bin:/usr/local/bin:"$(brew --prefix openssl)/bin":"$(brew --prefix ruby)/bin":"/usr/local/lib/ruby/gems/2.6.0/bin":"$(brew --prefix python)/libexec/bin":"$HOME/.go/bin":"$(brew --prefix go)/libexec/bin":$PATH
# define CDPATHs which are autocompleted from when doing cd
export CDPATH=$CDPATH:~/Code
# nvm
if [ -s "$HOME/.nvm" ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
fi
# pip should only run if there is a virtualenv currently activated
#export PIP_REQUIRE_VIRTUALENV=true
# cache pip-installed packages to avoid re-downloading
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache

31
inputrc
View File

@ -1,31 +0,0 @@
#!/usr/bin/env bash
# Use case-insensitive TAB autocompletion
set completion-ignore-case on
# Auto list tab completions (use instead of TAB-cycling)
set show-all-if-ambiguous on
# Immediately add a trailing slash when autocompleting symlinks to directories
set mark-symlinked-directories on
# Do not autocomplete hidden files unless the pattern explicitly begins with a dot
set match-hidden-files off
# Show all autocomplete results at once
set page-completions off
# Show extra file information when completing, like `ls -F` does
set visible-stats on
# Be more intelligent when autocompleting by also looking at the text after
# the cursor. For example, when the current line is "cd ~/src/mozil", and
# the cursor is on the "z", pressing Tab will not autocomplete it to "cd
# ~/src/mozillail", but to "cd ~/src/mozilla". (This is supported by the
# Readline used by Bash 4.)
set skip-completed-text on
# Allow UTF-8 input and output, instead of showing stuff like $'\0123\0456'
set input-meta on
set output-meta on
set convert-meta off

View File

@ -1,6 +1,6 @@
# dotfiles
> 👩‍🎤 personal dotfiles, scrambled together from the interwebz. Highly macOS oriented.
> 👩‍🎤 personal dotfiles, scrambled together from the interwebz. Highly macOS oriented, with zsh, oh-my-zsh, Homebrew.
[![Build Status](https://travis-ci.com/kremalicious/dotfiles.svg?branch=master)](https://travis-ci.com/kremalicious/dotfiles)
@ -29,9 +29,9 @@ git pull
## Custom scripts
Script | Description
--- | ---
`colors.sh` | print out all available colors with their values in the Terminal
`tor.sh` | start Tor and switch the system-wide proxy settings in macOS. [More info](https://kremalicious.com/simple-tor-setup-on-mac-os-x/)
`updaterepos.sh` | recursively updates all git repositories within the given folder
`update-everything.sh` | update macOS, Mac App Store apps, Homebrew packages, (global) npm packages, Ruby via rvm, and refresh GPG keys all in one command. Aliased to `update`
| Script | Description |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `colors.sh` | print out all available colors with their values in the Terminal |
| `tor.sh` | start Tor and switch the system-wide proxy settings in macOS. [More info](https://kremalicious.com/simple-tor-setup-on-mac-os-x/) |
| `updaterepos.sh` | recursively updates all git repositories within the given folder |
| `update-everything.sh` | update macOS, Mac App Store apps, Homebrew packages, (global) npm packages, Ruby via rvm, and refresh GPG keys all in one command. Aliased to `update` |

20
zshrc Normal file
View File

@ -0,0 +1,20 @@
# https://github.com/sindresorhus/pure
autoload -U promptinit; promptinit
prompt pure
# CASE_SENSITIVE="true"
DISABLE_UPDATE_PROMPT="true"
DISABLE_AUTO_TITLE="true"
ENABLE_CORRECTION="true"
HIST_STAMPS="yyyy-mm-dd"
# Oh My Zsh
export ZSH="/Users/m/.oh-my-zsh"
ZSH_THEME=""
plugins=(git)
source $ZSH/oh-my-zsh.sh
# User configuration
source ~/.exports
source ~/.aliases
source ~/.private