mirror of
https://github.com/nikdoof/dotfiles.git
synced 2025-12-14 02:02:29 +00:00
Switch to a common shell settings between bash and zsh
This commit is contained in:
12
shell-common/.config/shell-common/aliases.sh
Normal file
12
shell-common/.config/shell-common/aliases.sh
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"
|
||||
40
shell-common/.config/shell-common/exports.sh
Normal file
40
shell-common/.config/shell-common/exports.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
# User specific environment
|
||||
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
|
||||
export PATH
|
||||
|
||||
# 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
|
||||
|
||||
# Homebrew
|
||||
[ -d /opt/homebrew ] && eval $(/opt/homebrew/bin/brew shellenv)
|
||||
fi
|
||||
59
shell-common/.config/shell-common/functions.sh
Normal file
59
shell-common/.config/shell-common/functions.sh
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
|
||||
}
|
||||
Reference in New Issue
Block a user