-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbash_interactive
131 lines (104 loc) · 3.2 KB
/
bash_interactive
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
#!/bin/bash
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return ;;
esac
case `uname` in
Darwin*)
export CLICOLOR=1 ;;
esac
if [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
fi
# No duplicates!
export HISTSIZE=4096
export HISTCONTROL=erasedups
export HISTIGNORE=ls:cd
export VISUAL=vim
export EDITOR=$VISUAL
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
export PYTHONDONTWRITEBYTECODE=1
export FZF_DEFAULT_COMMAND="rg --files"
export FZF_CTRL_T_COMMAND="rg --files"
# append to the history file, don't overwrite it
shopt -s histappend
# check the window size after each command and, if necessary, update the values
# of LINES and COLUMNS.
shopt -s checkwinsize
function reloadssh() {
eval "$(tmux show-env -s |grep '^SSH_')"
}
if [ -x /usr/bin/tput ] && tput setaf 1 >& /dev/null; then
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
else
export PS1='\u@\h:\W\$ '
fi
[ -f ~/.fzf.bash ] && . ~/.fzf.bash
[ -f ~/.cargo/env ] && . ~/.cargo/env
[ -f /usr/local/share/google-cloud-sdk/path.bash.inc ] && . /usr/local/share/google-cloud-sdk/path.bash.inc
# subshells interfere with vim-tmux-navigator:
#
# https://github.com/christoomey/vim-tmux-navigator/issues/195
#
# Since supporting arbitrary subshell nested is broken, provide an alias to
# avoid creating a subshell for virtual environments instead
if which poetry > /dev/null; then
alias poetry_activate='source $(poetry env info --path)/bin/activate'
fi
# On some machines (Ubuntu 18.04), non-login interactive shells do not load
# bash completions. Load them if not.
if [ -z "${BASH_COMPLETION_VERSINFO-}" ]; then
if ! shopt -oq posix; then
for candidate in /usr/share/bash-completion/bash_completion /usr/local/etc/bash_completion /etc/bash_completion; do
if [ -f "$candidate" ]; then
. "$candidate"
break
fi
done
fi
fi
###-begin-gt-completions-###
#
# yargs command completion script
#
# Installation: gt completion >> ~/.bashrc
# or gt completion >> ~/.bash_profile on OSX.
#
_gt_yargs_completions()
{
local cur_word args type_list
cur_word="${COMP_WORDS[COMP_CWORD]}"
args=("${COMP_WORDS[@]}")
# ask yargs to generate completions.
type_list=$(gt --get-yargs-completions "${args[@]}")
COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )
# if no match was found, fall back to filename completion
if [ ${#COMPREPLY[@]} -eq 0 ]; then
COMPREPLY=()
fi
return 0
}
complete -o bashdefault -o default -F _gt_yargs_completions gt
###-end-gt-completions-###
_check_completion() {
local IFS=$'\n'
local response
response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _CHECK_COMPLETE=bash_complete $1)
for completion in $response; do
IFS=',' read type value <<< "$completion"
if [[ $type == 'dir' ]]; then
COMPREPLY=()
compopt -o dirnames
elif [[ $type == 'file' ]]; then
COMPREPLY=()
compopt -o default
elif [[ $type == 'plain' ]]; then
COMPREPLY+=($value)
fi
done
return 0
}
complete -o nosort -F _check_completion check