Skip to content

Instantly share code, notes, and snippets.

@nfet
Last active June 3, 2020 16:12
Show Gist options
  • Save nfet/bf947bf77fba5cc3d474b6a7e38c28b3 to your computer and use it in GitHub Desktop.
Save nfet/bf947bf77fba5cc3d474b6a7e38c28b3 to your computer and use it in GitHub Desktop.
ZShell Stuff
# git
autoload -Uz vcs_info
precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
RPROMPT=\$vcs_info_msg_0_
zstyle ':vcs_info:git:*' formats '%F{240}(%b)%r%f'
zstyle ':vcs_info:*' enable git
source zshrc.sh
# defines all the functions that os/zshrc.sh can use
#_verbose=true
_this_script="${(%):-%N}"
function _echo_script_name() {
if [[ "${_verbose}" == "true" ]]; then
echo sourcing $1
fi
}
function _echo_script() {
if [[ "${_verbose}" == "true" ]]; then
echo sourcing $1
fi
}
_echo_script_name "${_this_script}"
function include () {
[[ -f "$1" ]] && source "$1"
}
function _get_path() {
echo "$( cd "$1" && pwd )"
}
function _load_scripts() {
local dir=$1
local i
if [ -d "${dir}" ]; then
for i in ${dir}/*.sh; do
if [ -r $i ]; then
_echo_script $i && source $i
fi
done
fi
}
function _init() {
local SOURCE=$1
local script="$(basename $SOURCE)"
local cwd="$( cd "$( dirname "$SOURCE" )" && pwd )"
local source="${cwd}/${script}"
# echo cwd: $cwd
echo sourcing ${source}
local pre_dir="$(_get_path "${cwd}/../_pre")"
local post_dir="$(_get_path "${cwd}/../_post")"
local common_dir="$(_get_path "${cwd}/../common")"
local scripts_dir="$(_get_path "${cwd}/scripts")"
_load_scripts ${pre_dir}
_load_scripts ${common_dir}
_load_scripts ${scripts_dir}
_load_scripts ${post_dir}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment