mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Added dot-env plugin
Dot-env is a cross-platform, cascading Zsh environment system for those who work on different hardware and OS environments. See: https://github.com/midwire/.env
This commit is contained in:
parent
f4944d5a95
commit
ae2db75f3e
20 changed files with 629 additions and 0 deletions
9
plugins/dot-env/global/alias/chmod.sh
Normal file
9
plugins/dot-env/global/alias/chmod.sh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Alias chmod commands
|
||||
alias 000='chmod 000'
|
||||
alias 600='chmod 600'
|
||||
alias 644='chmod 644'
|
||||
alias 755='chmod 755'
|
||||
alias mgid='chmod g+s'
|
||||
alias mx='chmod a+x'
|
||||
alias rgid='chmod g-s'
|
||||
alias rx='chmod a-x'
|
||||
12
plugins/dot-env/global/alias/git.sh
Normal file
12
plugins/dot-env/global/alias/git.sh
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Git aliases
|
||||
alias add='git add'
|
||||
alias branch='git branch'
|
||||
alias co='git checkout'
|
||||
alias commit='git commit'
|
||||
alias fetch='git fetch'
|
||||
alias gadd='git add .'
|
||||
alias gt='gittower'
|
||||
alias merge='git merge'
|
||||
alias pull='git pull'
|
||||
alias push='git push'
|
||||
alias st='git status'
|
||||
14
plugins/dot-env/global/alias/ls.sh
Normal file
14
plugins/dot-env/global/alias/ls.sh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Directory Listing aliases
|
||||
alias dir='ls -hFx'
|
||||
alias l.='ls -d .* --color=tty'
|
||||
alias l='ls -lathF'
|
||||
alias L='ls -latrhF'
|
||||
alias la='ls -Al' # show hidden files
|
||||
alias lc='ls -lcr' # sort by change time
|
||||
alias lk='ls -lSr' # sort by size
|
||||
alias ll='ls -lFh'
|
||||
alias lm='ls -al |more' # pipe through 'more'
|
||||
alias lo='ls -laSFh'
|
||||
alias lr='ls -lR' # recursive ls
|
||||
alias lt='ls -ltr' # sort by date
|
||||
alias lu='ls -lur' # sort by access time
|
||||
5
plugins/dot-env/global/alias/misc.sh
Normal file
5
plugins/dot-env/global/alias/misc.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Miscellaneous aliases
|
||||
alias c='clear'
|
||||
alias cls='clear'
|
||||
alias h='history'
|
||||
alias path='echo $PATH'
|
||||
8
plugins/dot-env/global/alias/navigation.sh
Normal file
8
plugins/dot-env/global/alias/navigation.sh
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# ChDir aliases
|
||||
alias ..='cd ..'
|
||||
alias ...='cd ../..'
|
||||
alias 1..='cd ..'
|
||||
alias 2..='cd ../..'
|
||||
alias 3..='cd ../../..'
|
||||
alias 4..='cd ../../../..'
|
||||
alias 5..='cd ../../../../..'
|
||||
20
plugins/dot-env/global/alias/rails.sh
Normal file
20
plugins/dot-env/global/alias/rails.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Rails & Development Aliases
|
||||
alias a='autotest -rails'
|
||||
alias b="bundle"
|
||||
alias be="bundle exec"
|
||||
alias bi="bundle install --path vendor"
|
||||
alias bil="bi --local"
|
||||
alias binit="bi && bundle package && echo 'vendor/ruby' >> .gitignore"
|
||||
alias bu="bundle update"
|
||||
alias p='pry'
|
||||
alias rc='rails c'
|
||||
alias rd='rails destroy'
|
||||
alias re='echo $RAILS_ENV'
|
||||
alias rg='rails g'
|
||||
alias rp='rails plugin'
|
||||
alias rs='rails s'
|
||||
alias sc='./script/console'
|
||||
alias sd='./script/destroy'
|
||||
alias sg='./script/generate'
|
||||
alias sp='./script/plugin'
|
||||
alias ss='./script/server'
|
||||
7
plugins/dot-env/global/global_alias.sh
Normal file
7
plugins/dot-env/global/global_alias.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Now source global aliases
|
||||
for i in $DOT_ENV_PATH/global/alias/*.sh ; do
|
||||
if [ -r "$i" ]; then
|
||||
. $i
|
||||
fi
|
||||
done
|
||||
unset i
|
||||
27
plugins/dot-env/global/global_env.sh
Normal file
27
plugins/dot-env/global/global_env.sh
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Some of this is taken from matt.blissett.me.uk
|
||||
# Thanks Matt!
|
||||
|
||||
# Command History
|
||||
export HISTIGNORE="&:ls:[bf]g:exit:reset:clear:cd:cd ..:cd.."
|
||||
export HISTSIZE=25000
|
||||
setopt INC_APPEND_HISTORY
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt HIST_REDUCE_BLANKS
|
||||
setopt HIST_VERIFY
|
||||
|
||||
# Say how long a command took, if it took more than 30 seconds
|
||||
export REPORTTIME=30
|
||||
|
||||
# Prompts for confirmation after 'rm *' etc
|
||||
# Helps avoid mistakes like 'rm * o' when 'rm *.o' was intended
|
||||
setopt RM_STAR_WAIT
|
||||
|
||||
# Background processes aren't killed on exit of shell
|
||||
setopt AUTO_CONTINUE
|
||||
|
||||
# Watch other user login/out
|
||||
watch=notme
|
||||
export LOGCHECK=60
|
||||
|
||||
export LSCOLORS="gxfxcxdxbxegedabagacad"
|
||||
86
plugins/dot-env/global/global_functions.sh
Normal file
86
plugins/dot-env/global/global_functions.sh
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
# Add your public SSH key to a remote host
|
||||
function add_ssh_key_to_host {
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo_warn "Usage: add_ssh_key_to_host [user@]HOSTNAME"
|
||||
return
|
||||
fi
|
||||
if [[ -r ~/.ssh/id_dsa.pub ]]; then
|
||||
cat ~/.ssh/id_dsa.pub | ssh $1 "cat >> .ssh/authorized_keys"
|
||||
elif [[ -r ~/.ssh/id_rsa.pub ]]; then
|
||||
cat ~/.ssh/id_rsa.pub | ssh $1 "cat >> .ssh/authorized_keys"
|
||||
fi
|
||||
}
|
||||
|
||||
# Propagate your entire environment system to a remote host
|
||||
function propagate_env_to_host {
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo_warn "Usage: propagate_env_to_host [user@]HOSTNAME"
|
||||
return
|
||||
fi
|
||||
|
||||
host=$1
|
||||
shift 1
|
||||
ENVFILE=$HOME/env.tar.gz
|
||||
PWD=`pwd`
|
||||
cd $HOME
|
||||
echo_info "Compressing local environment..."
|
||||
tar cfvz $ENVFILE .env/ &> /dev/null
|
||||
echo_info "Copying environment to $host..."
|
||||
scp $ENVFILE $host:
|
||||
if [[ $? != 0 ]]; then echo "Copy failed!"; return; fi
|
||||
echo_info "Installing environment on $host..."
|
||||
ssh $host "rm -rf ~/.env/ && gunzip < env.tar.gz |tar xfv -" &> /dev/null
|
||||
echo_warn "Don't forget to add this your .bashrc file:"
|
||||
echo_warn 'if [[ -n "$PS1" ]]; then'
|
||||
echo_warn ' [[ -r $HOME/.env/source.sh ]] && . $HOME/.env/source.sh'
|
||||
echo_warn 'fi'
|
||||
cd $PWD
|
||||
}
|
||||
|
||||
# Configure environment settings for your local machine.
|
||||
function configthis.env {
|
||||
DIR="$DOT_ENV_PATH/host/$HOSTNAME"
|
||||
mkdir -p "$DIR"
|
||||
touch "$DIR/env.sh"
|
||||
touch "$DIR/functions.sh"
|
||||
if [[ ! -f "$DIR/alias.sh" ]]; then
|
||||
echo "# Add your specific aliases here:\n# Example: alias home='cd \$HOME' " >> "$DIR/alias.sh"
|
||||
fi
|
||||
if [[ ! -f "$DIR/prompt.sh" ]]; then
|
||||
echo "# Define your prompt here:\n# Example: PS1=\$BLUE\u@\H\$NO_COLOR " >> "$DIR/prompt.sh"
|
||||
fi
|
||||
if [[ ! -f "$DIR/path.sh" ]]; then
|
||||
echo "# Add paths like this:\n# pathmunge \"/Developer/usr/bin\"" >> "$DIR/path.sh"
|
||||
fi
|
||||
cd "$DIR"
|
||||
echo_info "Edit these files to customize your local environment."
|
||||
ls -1AtF
|
||||
}
|
||||
|
||||
# Configure environment settings for a specified HOSTNAME
|
||||
function confighost.env {
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo_warn "Usage: confighost.env HOSTNAME"
|
||||
return
|
||||
fi
|
||||
host=$1
|
||||
shift 1
|
||||
DIR="$DOT_ENV_PATH/host/$host"
|
||||
mkdir -p "$DIR"
|
||||
touch "$DIR/env.sh"
|
||||
touch "$DIR/functions.sh"
|
||||
if [[ ! -f "$DIR/alias.sh" ]]; then
|
||||
echo "# Add your host specific aliases here:\n# Example: alias home='cd \$HOME' " >> "$DIR/alias.sh"
|
||||
fi
|
||||
if [[ ! -f "$DIR/prompt.sh" ]]; then
|
||||
echo "# Define your prompt here:\n# Example: PS1=\$BLUE\u@\H\$NO_COLOR " >> "$DIR/prompt.sh"
|
||||
fi
|
||||
if [[ ! -f "$DIR/path.sh" ]]; then
|
||||
echo "# Add paths like this:\n# pathmunge \"/Developer/usr/bin\"" >> "$DIR/path.sh"
|
||||
fi
|
||||
cd "$DIR"
|
||||
echo_info "Edit these files to customize your [$host] environment."
|
||||
echo_info "When you are finished run 'propagate_env_to_host $host'."
|
||||
ls -1AtF
|
||||
}
|
||||
|
||||
31
plugins/dot-env/global/global_path.sh
Normal file
31
plugins/dot-env/global/global_path.sh
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
paths="${DOT_ENV_PATH}/bin
|
||||
/sbin
|
||||
/bin
|
||||
/usr/X11/bin
|
||||
/usr/local/bin
|
||||
/usr/sbin
|
||||
/usr/bin"
|
||||
|
||||
EGREP=`which egrep`
|
||||
function pathmunge () {
|
||||
if ! echo $PATH | $EGREP "(^|:)$1($|:)" > /dev/null ; then
|
||||
if [ -d "$1" ]; then
|
||||
if [ "$2" = "before" ] ; then
|
||||
PATH="$1:$PATH"
|
||||
else
|
||||
PATH="$PATH:$1"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
for p in $paths; do
|
||||
pathmunge $p
|
||||
done
|
||||
|
||||
# Prepend path with $HOME/bin
|
||||
pathmunge "$HOME/bin" before
|
||||
|
||||
PATH=`echo $PATH | sed -e 's/^\://' -e 's/\:\:/:/g'`
|
||||
unset paths
|
||||
export PATH
|
||||
Loading…
Add table
Add a link
Reference in a new issue