-
Notifications
You must be signed in to change notification settings - Fork 0
/
_profile
71 lines (57 loc) · 1.38 KB
/
_profile
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
if [ -n "$ZSH_VERSION" ]; then
local my_dir="$(dirname "${(%):-%N}")"
elif [ -n "$BASH_VERSION" ]; then
my_dir="$(dirname "${BASH_SOURCE[0]}")"
fi
export PATH="$my_dir/bin:$PATH"
settitle() {
ESC=$(printf "\e")
OSC_START="${ESC}Ptmux;${ESC}"
OSC_END="${ESC}\\"
title_sequence="$ESC]2;${1}$ESC\\"
printf "$OSC_START$title_sequence$OSC_END"
printf "$title_sequence"
}
tmux_session_name() {
tty=$(tty)
for s in $(tmux list-sessions -F '#{session_name}' 2>/dev/null); do
tmux list-panes -F '#{pane_tty} #{session_name}' -t "$s"
done | grep "$tty" | awk '{print $2}'
}
function git_base_dir() {
local git_dir="$1"
(
if [[ -n $git_dir ]]; then
cd $git_dir
fi
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) != 'true' ]]; then
echo "Not in a git repository"
return 1
fi
local root_path=$(git rev-parse --show-toplevel)
echo $root_path
)
}
function cdg() {
local relative_path="$1"
local root_path=$(git_base_dir)
if [ -n "$relative_path" ]; then
cd "$root_path/$relative_path"
else
cd "$root_path"
fi
}
stty -ixon
export EDITOR='vim'
if [ -f /usr/local/bin/vim.appimage ]; then
alias vim=/usr/local/bin/vim.appimage
fi
# fzf options
source "${my_dir}/bash/_fzf_config"
if [ -n "$ZSH_VERSION" ]
then
source "${my_dir}/zsh/_zsh_profile"
elif [ -n "$BASH_VERSION" ]
then
source "${my_dir}/bash/_bash_profile"
fi