mirror of
https://github.com/nikdoof/dotfiles.git
synced 2025-12-13 09:42:27 +00:00
Add zsh config
This commit is contained in:
12
zsh/.config/zsh/aliases.zsh
Normal file
12
zsh/.config/zsh/aliases.zsh
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# OSX aliases
|
||||||
|
if [[ $(uname) == "Darwin" ]]; then
|
||||||
|
alias ls="ls -FG"
|
||||||
|
alias code="code-insiders"
|
||||||
|
alias flushdns="sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder"
|
||||||
|
else
|
||||||
|
alias ls="ls -F --color=auto"
|
||||||
|
fi
|
||||||
|
|
||||||
|
alias t='(tmux has-session 2>/dev/null && tmux attach) || (tmux new-session)'
|
||||||
|
alias tma="tmux attach"
|
||||||
|
alias last="last | head"
|
||||||
45
zsh/.config/zsh/exports.zsh
Normal file
45
zsh/.config/zsh/exports.zsh
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# User specific environment
|
||||||
|
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
|
||||||
|
export PATH
|
||||||
|
|
||||||
|
# History
|
||||||
|
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
|
||||||
|
HISTSIZE=2000
|
||||||
|
SAVEHIST=1000
|
||||||
|
|
||||||
|
# Prompt
|
||||||
|
export PS1="%F{black}[%F{white}%n@%m%F{black}] (%F{white}%1~%F{black}) %F{white}%# "
|
||||||
|
|
||||||
|
# User specific environment and startup programs
|
||||||
|
export TZ=GB
|
||||||
|
export LANG=en_GB.UTF-8
|
||||||
|
|
||||||
|
# Make a sensible editor choice
|
||||||
|
if [ -x /usr/bin/nano ]; then
|
||||||
|
export EDITOR=nano
|
||||||
|
export VISUAL=nano
|
||||||
|
else
|
||||||
|
export EDITOR=vi
|
||||||
|
export VISUAL=vi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Go stuff
|
||||||
|
if [ -d /usr/local/go ]; then
|
||||||
|
export GOROOT=/usr/local/go/
|
||||||
|
export GOPATH=$HOME/go/
|
||||||
|
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
|
||||||
|
|
||||||
|
# https://github.com/oz/tz
|
||||||
|
if [ -f $HOME/go/bin/tz ]; then
|
||||||
|
export TZ_LIST="America/New_York,America/Los_Angeles,Europe/Paris"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# OSX Specific envs
|
||||||
|
if [[ $(uname) == "Darwin" ]]; then
|
||||||
|
# M1 specific hacks
|
||||||
|
if [[ $(uname -p) == "arm" ]]; then
|
||||||
|
# Stop golang progs having fun with Rosetta 2 (https://yaleman.org/post/2021/2021-01-01-apple-m1-terraform-and-golang/)
|
||||||
|
export GODEBUG=asyncpreemptoff=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
59
zsh/.config/zsh/functions.zsh
Normal file
59
zsh/.config/zsh/functions.zsh
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# Git pulls latest dotfiles
|
||||||
|
function update-dotfiles() {
|
||||||
|
prevdir=$PWD
|
||||||
|
if [ -d "${HOME}/.dotfiles" ]; then
|
||||||
|
cd $HOME/.dotfiles
|
||||||
|
git pull --rebase --autostash
|
||||||
|
fi
|
||||||
|
if [ -d "${HOME}/.dotfiles-private" ]; then
|
||||||
|
cd $HOME/.dotfiles-private
|
||||||
|
git pull --rebase --autostash
|
||||||
|
fi
|
||||||
|
cd $prevdir
|
||||||
|
}
|
||||||
|
|
||||||
|
function add-sshkey() {
|
||||||
|
TIMEOUT="2h"
|
||||||
|
NAME=$1
|
||||||
|
|
||||||
|
if [ -z "$NAME" ]; then
|
||||||
|
echo "Current Keys"
|
||||||
|
ssh-add -L | cut -d" " -f 3-
|
||||||
|
else
|
||||||
|
if [ -f "${HOME}/.ssh/id_ed25519_${NAME}" ]; then
|
||||||
|
ssh-add -t $TIMEOUT "${HOME}/.ssh/id_ed25519_${NAME}"
|
||||||
|
else
|
||||||
|
echo "No key named ${NAME} found..."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Switch to a simple prompt for demos (thanks Mark H for the idea)
|
||||||
|
function demoprompt() {
|
||||||
|
if [ ! -z ${OLDPS1+x} ]; then
|
||||||
|
PS1=$OLDPS1
|
||||||
|
unset OLDPS1
|
||||||
|
else
|
||||||
|
OLDPS1=$PS1
|
||||||
|
PS1=" %# "
|
||||||
|
clear
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function commit-pkm() {
|
||||||
|
if [ -d $HOME/Documents/pkm ]; then
|
||||||
|
prevdir=$PWD
|
||||||
|
cd ~/Documents/pkm
|
||||||
|
if [[ `git status --porcelain` ]]; then
|
||||||
|
echo "Changes detected, commiting..."
|
||||||
|
git add -A && git commit -a -m 'Manual savepoint'
|
||||||
|
else
|
||||||
|
echo "No changes detected"
|
||||||
|
fi
|
||||||
|
git fetch
|
||||||
|
if [ $(git rev-parse main) != $(git rev-parse refs/remotes/origin/main) ]; then
|
||||||
|
git push origin
|
||||||
|
fi
|
||||||
|
cd $PREVDIR
|
||||||
|
fi
|
||||||
|
}
|
||||||
19
zsh/.zshrc
Normal file
19
zsh/.zshrc
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Source exports, if it exists
|
||||||
|
if [ -f $HOME/.config/zsh/exports.zsh ]; then
|
||||||
|
source $HOME/.config/zsh/exports.zsh
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source functions, if it exists
|
||||||
|
if [ -f $HOME/.config/zsh/functions.zsh ]; then
|
||||||
|
source $HOME/.config/zsh/functions.zsh
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source aliases, if it exists
|
||||||
|
if [ -f $HOME/.config/zsh/aliases.zsh ]; then
|
||||||
|
source $HOME/.config/zsh/aliases.zsh
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Source completions, if it exists
|
||||||
|
if [ -f $HOME/.config/zsh/completions.zsh ]; then
|
||||||
|
source $HOME/.config/zsh/completions.zsh
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user