-
Notifications
You must be signed in to change notification settings - Fork 1
/
dot_bashrc
134 lines (110 loc) · 3.62 KB
/
dot_bashrc
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env bash
# bash
HISTCONTROL=ignoreboth # Ignore duplicate commands, or ones prefixed with a space
HISTSIZE=65535 # Keep lots of history. Default, 500
# XDG bin directory
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
# ripgrep
if [ -f "$HOME/.ripgreprc" ]; then
export RIPGREP_CONFIG_PATH="$HOME/.ripgreprc"
fi
# homebrew for linux
if [ -d /home/linuxbrew/ ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
# volta
if type volta >/dev/null 2>&1; then
VOLTA_HOME="$HOME/.volta"
PATH="$VOLTA_HOME/bin:$PATH"
export VOLTA_HOME
fi
# Linux Utilities
if type vim >/dev/null 2>&1; then EDITOR=vim; fi
if type nvim >/dev/null 2>&1; then EDITOR=nvim; fi
export EDITOR
# homebrew autocomplete
if type brew >/dev/null 2>&1; then
for completion_file in "$(brew --prefix)"/etc/bash_completion.d/*; do
# shellcheck source=/dev/null
source "$completion_file"
done
# node-version-manager
if [ -d "$(brew --prefix nvm)" ]; then
export NVM_DIR="$HOME/.nvm"
nvmsh="$(brew --prefix)/opt/nvm/nvm.sh"
if [ -s "$nvmsh" ]; then
# shellcheck source=/dev/null
source "$nvmsh"
fi
unset nvmsh
bashCompletion="$(brew --prefix)/opt/nvm/etc/bash_completion"
if [ -s "$bashCompletion" ]; then
# shellcheck source=/dev/null
source "$bashCompletion"
fi
unset bashCompletion
fi
fi
if type zoxide >/dev/null 2>&1; then eval "$(zoxide init bash)"; fi
fzfShellDir="/usr/share/doc/fzf/examples" # Default on Ubuntu 20.04
if type brew >/dev/null 2>&1; then
fzfShellDir="$(brew --prefix)/opt/fzf/shell"
if [[ ! "$PATH" == *"$(brew --prefix)"/opt/fzf/bin* ]]; then
# Append fzf/bin to the PATH since homebrew does not.
PATH="$PATH:$(brew --prefix)/opt/fzf/bin"
export PATH
fi
fi
if [ -d "$fzfShellDir" ]; then
if [[ $- == *i* ]]; then
# shellcheck source=/dev/null
source "$fzfShellDir/completion.bash" 2> /dev/null
fi
# shellcheck source=/dev/null
source "$fzfShellDir/key-bindings.bash"
fi
unset fzfShellDir
# .bashrc.local, to override any settings from this .bashrc file.
if [ -f "$HOME/.bashrc.local" ]; then
# shellcheck source=/dev/null
source "$HOME/.bashrc.local"
fi
if type oh-my-posh >/dev/null 2>&1; then
promptVariation='.minimal'
if [[ -n "${WT_SESSION}" ]]
then
promptVariation=''
fi
if [[ -n "${TERM_PROGRAM}" ]]
then
if [[ 'VSCode' == "${TERM_PROGRAM}" ]]
then
promptVariation=''
fi
fi
eval "$(oh-my-posh --init --shell bash --config ~/.dotfiles-prompt"$promptVariation".omp.json)"
fi
if type dotnet >/dev/null 2>&1; then
# bash parameter completion for the dotnet CLI
function _dotnet_bash_complete()
{
local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n'
local candidates
read -d '' -ra candidates < <(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)
read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]:-}" -- "$cur")
}
complete -f -F _dotnet_bash_complete dotnet
fi
getSourceLocations () {
find -L "$HOME/Source" -mindepth 1 -maxdepth 3 -type d | grep -v '\.git'
}
editSourceLocation () { $EDITOR "$(getSourceLocations | fzf)" || return; }
getSourceLocation () { "$(getSourceLocations | fzf)" || return; }
setSourceLocation () { cd "$(getSourceLocations | fzf)" || return; }
pushSourceLocation () { pushd "$(getSourceLocations | fzf)" || return; }
alias esl=editSourceLocation
alias gsl=getSourceLocation
alias ssl=setSourceLocation
alias psl=pushSourceLocation