-
Notifications
You must be signed in to change notification settings - Fork 1
/
.zshrc.shared
75 lines (60 loc) · 2.24 KB
/
.zshrc.shared
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env zsh
# Skip all this for non-interactive shells
[[ -z "$PS1" ]] && return
function zcompare() {
if [[ -s ${1} && (! -s ${1}.zwc || ${1} -nt ${1}.zwc) ]]; then
zcompile ${1}
fi
}
function source_file() {
zcompare "$1"
builtin source "$1"
}
function source_files() {
local f
for f; do
test -x "$f" && source_file "$f"
done
}
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
plugins=()
# extra files in $HOME/.shellrc/zshrc.d/configs/pre, $HOME/.shellrc/zshrc.d/configs, and $HOME/.shellrc/zshrc.d/configs/post
# these are loaded first, second, and third, respectively.
_load_settings() {
_dir="$1"
if [[ -d "$_dir" ]]; then
if [[ -d "$_dir/pre" ]]; then
source_files $(find "$_dir"/pre -mindepth 1 -name '*.*sh' -and -not -name '*##*' -and -not -name '*~$*' -and \( -type f -or -type l \) | sort -n 2>/dev/null)
fi
source_files $(find "$_dir" -mindepth 1 -and -not -path '*/pre/**' -and -not -path '*/post/**' -and -not -name '*##*' -and -not -name '*~$*' -and \( -type f -or -type l \))
if [[ -f "$ZSH/oh-my-zsh.sh" && -z "$INTELLIJ_ENVIRONMENT_READER" ]]; then
source_file $ZSH/oh-my-zsh.sh
fi
if [ -d "$_dir/post" ]; then
source_files $(find "$_dir"/post -mindepth 1 -name '*.*sh' -and -not -name '*##*' -and -not -name '*~$*' -and \( -type f -or -type l \) | sort -n 2>/dev/null)
fi
fi
}
_load_settings "$HOME/.shellrc/zshrc.d/configs"
# Load all files from .shell/rc.d directory
if [[ -d $HOME/.shellrc/rc.d ]]; then
source_files $(find $HOME/.shellrc/rc.d -mindepth 1 -name '*.sh' -and -not -name '*##*' -and -not -name '*~$*' -and \( -type f -or -type l \) | sort -n 2>/dev/null | uniq)
fi
# aliases
source_file ~/.aliases.sh
unfunction source_files
# autoload custom executable functions
_func_dir="${HOME}/.shellrc/zshrc.d/functions"
_function_files=($(find ${_func_dir} -mindepth 1 -maxdepth 1 -not -name '*.zwc' -and -not -name '*##*' -and -not -name '*~$*' -and \( -type f -or -type l \)))
if [[ ${#_function_files[@]} -gt 0 ]]; then
fpath+=("${_func_dir}")
autoload -Uz $_function_files[@]
fi
sessions=$(tmux ls 2>&1)
if [[ $? -eq 0 ]]; then
if [[ $(echo $sessions | wc -l) -gt 1 ]]; then
echo "Existing tmux sessions:"
echo "$sessions"
fi
fi