dotfiles/zsh/zshrc.symlink

221 lines
5.9 KiB
Text

source /etc/zshrc
source $HOME/.zsh/secret
## Path
# Default path
export PATH="/sbin"
PATH="/usr/sbin:$PATH"
PATH="/bin:$PATH"
PATH="/usr/bin:$PATH"
PATH="/usr/local/sbin:$PATH"
PATH="/usr/local/bin:$PATH"
# Local path
PATH="$HOME/dotfiles/bin:$PATH"
# Composer (PHP)
PATH="$HOME/.composer/vendor/bin:$PATH"
# Python
export PYTHONPATH="$PYTHONPATH:$HOME/dotfiles/lib/python"
## Completion
# Load up the extra Z Shell completions
fpath=("$HOME/.zsh/zsh-completions/src" $fpath)
# Ensure we can run the compinit to make them work.
autoload compinit
# Initialise better autocompletion
compinit
## Syntax Highlighting
source "$HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
# Make errors red
ZSH_HIGHLIGHT_STYLES[unknown-token]='fg=red'
# Turn just about everything else off
ZSH_HIGHLIGHT_STYLES[reserved-word]='none'
ZSH_HIGHLIGHT_STYLES[reserved-word]='none'
ZSH_HIGHLIGHT_STYLES[alias]='none'
ZSH_HIGHLIGHT_STYLES[builtin]='none'
ZSH_HIGHLIGHT_STYLES[function]='none'
ZSH_HIGHLIGHT_STYLES[command]='none'
ZSH_HIGHLIGHT_STYLES[precommand]='none'
ZSH_HIGHLIGHT_STYLES[commandseparator]='none'
ZSH_HIGHLIGHT_STYLES[hashed-command]='none'
ZSH_HIGHLIGHT_STYLES[path]='none'
ZSH_HIGHLIGHT_STYLES[path_prefix]='none'
ZSH_HIGHLIGHT_STYLES[path_approx]='none'
ZSH_HIGHLIGHT_STYLES[globbing]='none'
ZSH_HIGHLIGHT_STYLES[history-expansion]='none'
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='none'
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='none'
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]='none'
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]='none'
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='none'
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]='none'
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]='none'
ZSH_HIGHLIGHT_STYLES[assign]='none'
ZSH_HIGHLIGHT_STYLES[default]='none'
# Get the first part of the hostname
#
# Sometimes they have dots in them, I'm not partial to that.
function nice-hostname {
echo $(command hostname | cut -d . -f 1)
}
# Don't beep at me when I do something wrong.
#
# I found it was beeping when I wasn't doing something wrong, and that
# really gets on my nerves.
setopt no_beep
unset zle_bracketed_paste
## Changing Directories
# If a command cannot be executed, try cd.
#
# This is an old Fish option that I sometimes made use of.
setopt auto_cd
# Use pushd instead of cd
#
# Pushd is a thing that maintains a history of directories in a stack.
# It turns out that this is incredibly useful.
setopt auto_pushd
# Resolve links to their actual directory.
#
# Not doing this causes several unpleasant conflicts. Fish made the
# right call by not doing this. See:
#
# http://fishshell.com/docs/current/faq.html#faq-cwd-symlink
#
# > ...it is impossible to consistently keep symlinked directories
# > unresolved. It is indeed possible to do this partially, and many
# > other shells do so. But it was felt there are enough serious corner
# > cases that this is a bad idea. Most such issues have to do with how
# > '..' is handled...
setopt chase_links
# Do not print the directory stack on each pushd (cd)
setopt pushd_silent
# Pushd with no arguments is like cd with no arguments
setopt pushd_to_home
## History
# Save history between sessions.
#
# Zsh doesn't do this by default, and I don't know why.
HISTSIZE=10000
SAVEHIST=10000
HISTFILE="$HOME/.zsh_history"
# Don't beep at me when I do something wrong
setopt no_hist_beep
# Tell Z Shell to append to the history file.
#
# The other option is to write to it each session.
setopt append_history
# Store more information in the history file.
#
# This option will store the timestamp corresponding to when the
# command started, as well as its duration. I'm turning this on
# because I don't see why I wouldn't want more information.
setopt extended_history
# Apparently, there is a bug in the way Z Shell handles words.
#
# This option enforces correct behaviour, but can be slower. We'll try
# to do things correctly and see if it's slow.
setopt hist_lex_words
# Liquid Prompt!
source "$HOME/.zsh/liquidprompt/liquidprompt"
# Create MySQL Docker container
function provision_mysql {
mkdir -p "$HOME/Data/5.6/data" && docker run -d\
--name="mysql-5.6" \
-e "MYSQL_ROOT_PASSWORD=root" \
-p 33306:3306 \
-v "$HOME/Data/5.6/data:/tmp/data" \
-v "/var/lib/mysql" \
"mysql:5.6"
}
# Access MySQL Docker container
alias mysql='docker exec -it "mysql-5.6" mysql -uroot -proot'
# Install Magento 2
function install_magento {
local host="$1"
local db_name="$2"
n98-magerun2 setup:install \
--admin-firstname="Max" \
--admin-lastname="Bucknell" \
--admin-email="me@maxbucknell.com" \
--admin-user="max.bucknell" \
--admin-password="password123" \
--base-url="http://$host:15013/index.php/" \
--backend-frontname="admin" \
--db-host="127.0.0.1:33306" \
--db-name="$db_name" \
--db-user="root" \
--db-password="root" \
--language="en_US" \
--currency="EUR" \
--timezone="UTC" \
--use-rewrites="1" \
--use-secure="0" \
--use-secure-admin="0" \
--admin-use-security-key="0" \
--session-save="files"
n98-magerun2 config:store:set "dev/static/sign" "0"
n98-magerun2 config:store:set "web/unsecure/base_static_url" "http://$host:15013/static/"
n98-magerun2 c:f
}
# Find root of Magetno 2 installation
alias find_magento_root='findroot "app/etc/config.php"'
# Start M2 server
function serve_m2 {
local root="$(find_magento_root)"
pushd "$root/pub"
php -S "0.0.0.0:15013" "../phpserver/router.php" "../pub"
popd
}
alias ww='workflow'
# Initialize workflow with Github
function workflow_github {
local root="$(findroot "app/code/Magento")"
pushd "$root"
cp -r "$HOME/dotfiles/share/workflow-github/" "."
cat <<'EOF'
Initialized workflow Docker and Docker Compose files in the Magento root.
Configure your volumes to sync what you are working on, edit .docker/local.env
and run:
$ workflow up && workflow mfi
To install Magento. Happy hacking!
EOF
popd
}