Skip to content

Commit eaf7ff4

Browse files
committed
Merge branch 'master' into ira/fix-knife-load
* master: (113 commits) skip go tests when go is not available plugins: Add ble.sh plugin clean up pyenv plugin Lint: prepare `lib/utilities` for `shellcheck` (Bash-it#1933) plugin/base: improvements (Bash-it#1930) plugins/percol: `bind` completion/git: `shfmt` && `shellcheck` completion/git: expand search range plugin/percol: `shellcheck` & `shfmt` plugins/percol: use `_command_exists` completion/pip: simplify code flow plugin/less-pretty-cat: remove `|| cat` completion/wpscan: simplify code flow (whitespace) plugins/less-pretty-cat: simplify code flow plugins/less-pretty-cat: use `_command_exists` lib/helpers: cite `_bash-it-find-in-ancestor()` gradle: adopt `_bash_it_find_in_ancestor()` lib/helpers: new function `_bash-it-find-in-ancestor()` completion/laravel: simplify code flow plugin/ruby: add missing parameter error message ...
2 parents 79abc59 + cf08fca commit eaf7ff4

File tree

134 files changed

+1167
-994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+1167
-994
lines changed

.editorconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ insert_final_newline = true
1313
trim_trailing_whitespace = false
1414

1515
[.git*]
16+
indent_size = tab
1617
indent_style = tab
1718

1819
[{**.*sh,test/run}]
20+
indent_size = tab
1921
indent_style = tab
20-
indent_size = 4
2122

2223
shell_variant = bash
2324
binary_next_line = true # like -bn
2425
switch_case_indent = true # like -ci
2526
space_redirects = true # like -sr
26-
keep_padding = false # like -kp
27+
keep_padding = false # like -kp
2728
end_of_line = lf
2829
charset = utf-8
2930
trim_trailing_whitespace = true

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
bats-test:
1212
strategy:
1313
matrix:
14-
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, macos-10.15]
14+
os: [ubuntu-20.04, ubuntu-18.04, macos-10.15, macos-11.0]
1515

1616
runs-on: ${{ matrix.os }}
1717

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ repos:
1515
- id: mixed-line-ending
1616
- id: check-added-large-files
1717
- repo: https://github.com/jumanjihouse/pre-commit-hooks
18-
rev: 2.1.4
18+
rev: 2.1.5
1919
hooks:
2020
- id: git-check # Configure in .gitattributes
2121
- id: shellcheck

.shellcheckrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

aliases/available/apt.aliases.bash

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
# shellcheck shell=bash
22
#
33
# -binaryanomaly
44

@@ -8,7 +8,8 @@ about-alias 'Apt and dpkg aliases for Ubuntu and Debian distros.'
88
# set apt aliases
99
function _set_pkg_aliases()
1010
{
11-
if [ -x $(which apt) ]; then
11+
if _command_exists apt
12+
then
1213
alias apts='apt-cache search'
1314
alias aptshow='apt-cache show'
1415
alias aptinst='sudo apt-get install -V'

aliases/available/curl.aliases.bash

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ about-alias 'Curl aliases for convenience.'
66
# set apt aliases
77
function _set_pkg_aliases()
88
{
9-
if [ -x $(which curl) ]; then
9+
if _command_exists curl
10+
then
1011
# follow redirects
1112
alias cl='curl -L'
1213
# follow redirects, download as original name

aliases/available/general.aliases.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ then
3030
alias grep='grep --color=auto'
3131
fi
3232

33-
if which gshuf &> /dev/null
33+
if _command_exists gshuf
3434
then
3535
alias shuf=gshuf
3636
fi
@@ -65,7 +65,7 @@ alias -- -='cd -' # Go back
6565
alias h='history'
6666

6767
# Tree
68-
if [ ! -x "$(which tree 2>/dev/null)" ]
68+
if ! _command_exists tree
6969
then
7070
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
7171
fi

aliases/available/git.aliases.bash

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ alias gcb='git checkout -b'
3737
alias gco='git checkout'
3838
alias gcob='git checkout -b'
3939
alias gcobu='git checkout -b ${USER}/'
40-
alias gcom='git checkout master'
41-
alias gcpd='git checkout master; git pull; git branch -D'
40+
alias gcom='git checkout $(get_default_branch)'
41+
alias gcpd='git checkout $(get_default_branch); git pull; git branch -D'
4242
alias gct='git checkout --track'
4343

4444
# clone
@@ -64,13 +64,14 @@ alias gf='git fetch --all --prune'
6464
alias gft='git fetch --all --prune --tags'
6565
alias gftv='git fetch --all --prune --tags --verbose'
6666
alias gfv='git fetch --all --prune --verbose'
67-
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master'
67+
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/$(get_default_branch)'
6868
alias gup='git fetch && git rebase'
6969

7070
# log
7171
alias gg='git log --graph --pretty=format:'\''%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset'\'' --abbrev-commit --date=relative'
7272
alias ggf='git log --graph --date=short --pretty=format:'\''%C(auto)%h %Cgreen%an%Creset %Cblue%cd%Creset %C(auto)%d %s'\'''
7373
alias ggs='gg --stat'
74+
alias ggup='git log --branches --not --remotes --no-walk --decorate --oneline' # FROM https://stackoverflow.com/questions/39220870/in-git-list-names-of-branches-with-unpushed-commits
7475
alias gll='git log --graph --pretty=oneline --abbrev-commit'
7576
alias gnew='git log HEAD@{1}..HEAD@{0}' # Show commits since last pull, see http://blogs.atlassian.com/2014/10/advanced-git-aliases/
7677
alias gwc='git whatchanged'
@@ -104,15 +105,15 @@ alias gp='git push'
104105
alias gpd='git push --delete'
105106
alias gpf='git push --force'
106107
alias gpo='git push origin HEAD'
107-
alias gpom='git push origin master'
108+
alias gpom='git push origin $(get_default_branch)'
108109
alias gpu='git push --set-upstream'
109110
alias gpunch='git push --force-with-lease'
110111
alias gpuo='git push --set-upstream origin'
111112
alias gpuoc='git push --set-upstream origin $(git symbolic-ref --short HEAD)'
112113

113114
# pull
114115
alias gl='git pull'
115-
alias glum='git pull upstream master'
116+
alias glum='git pull upstream $(get_default_branch)'
116117
alias gpl='git pull'
117118
alias gpp='git pull && git push'
118119
alias gpr='git pull --rebase'
@@ -128,9 +129,9 @@ alias grm='git rm'
128129
# rebase
129130
alias grb='git rebase'
130131
alias grbc='git rebase --continue'
131-
alias grm='git rebase master'
132-
alias grmi='git rebase master -i'
133-
alias gprom='git fetch origin master && git rebase origin/master && git update-ref refs/heads/master origin/master' # Rebase with latest remote master
132+
alias grm='git rebase $(get_default_branch)'
133+
alias grmi='git rebase $(get_default_branch) -i'
134+
alias gprom='git fetch origin $(get_default_branch) && git rebase origin/$(get_default_branch) && git update-ref refs/heads/$(get_default_branch) origin/$(get_default_branch)' # Rebase with latest remote
134135

135136
# reset
136137
alias gus='git reset HEAD'
@@ -174,7 +175,7 @@ alias gsu='git submodule update --init --recursive'
174175
# these aliases requires git v2.23+
175176
alias gsw='git switch'
176177
alias gswc='git switch --create'
177-
alias gswm='git switch master'
178+
alias gswm='git switch $(get_default_branch)'
178179
alias gswt='git switch --track'
179180

180181
# tag
@@ -196,3 +197,11 @@ esac
196197
function gdv() {
197198
git diff --ignore-all-space "$@" | vim -R -
198199
}
200+
201+
function get_default_branch() {
202+
if git branch | grep -q main; then
203+
echo main
204+
else
205+
echo master
206+
fi
207+
}

aliases/available/vim.aliases.bash

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,14 @@
22
cite 'about-alias'
33
about-alias 'vim abbreviations'
44

5-
VIM=$(command -v vim)
6-
GVIM=$(command -v gvim)
7-
MVIM=$(command -v mvim)
5+
_command_exists vim || return
86

9-
if [[ -n $VIM ]]; then
10-
alias v='$VIM'
11-
# open the vim help in fullscreen incorporated from
12-
# https://stackoverflow.com/a/4687513
13-
alias vimh='${VIM} -c ":h | only"'
14-
fi
7+
alias v='vim'
8+
# open the vim help in fullscreen incorporated from
9+
# https://stackoverflow.com/a/4687513
10+
alias vimh='vim -c ":h | only"'
1511

1612
# open vim in new tab is taken from
1713
# http://stackoverflow.com/questions/936501/let-gvim-always-run-a-single-instancek
18-
case $OSTYPE in
19-
darwin*)
20-
[[ -n $MVIM ]] && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; }
21-
;;
22-
*)
23-
[[ -n $GVIM ]] && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; }
24-
;;
25-
esac
14+
_command_exists mvim && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; }
15+
_command_exists gvim && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; }

bash_it.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
BASH_IT_LOG_PREFIX="core: main: "
44

55
# Only set $BASH_IT if it's not already set
6-
if [ -z "$BASH_IT" ]; then
6+
if [ -z "${BASH_IT:-}" ]; then
77
# Setting $BASH to maintain backwards compatibility
88
export BASH_IT=$BASH
99
BASH="$(bash -c 'echo $BASH')"
@@ -20,12 +20,12 @@ source "${BASH_IT}"/vendor/github.com/erichs/composure/composure.sh
2020
source "${BASH_IT}/lib/log.bash"
2121

2222
# We can only log it now
23-
[ -z "$BASH_IT_OLD_BASH_SETUP" ] || _log_warning "BASH_IT variable not initialized, please upgrade your bash-it version and reinstall it!"
23+
[ -z "${BASH_IT_OLD_BASH_SETUP:-}" ] || _log_warning "BASH_IT variable not initialized, please upgrade your bash-it version and reinstall it!"
2424

2525
# For backwards compatibility, look in old BASH_THEME location
26-
if [ -z "$BASH_IT_THEME" ]; then
26+
if [ -z "${BASH_IT_THEME:-}" ]; then
2727
_log_warning "BASH_IT_THEME variable not initialized, please upgrade your bash-it version and reinstall it!"
28-
export BASH_IT_THEME="$BASH_THEME"
28+
export BASH_IT_THEME="${BASH_THEME:-}"
2929
unset BASH_THEME
3030
fi
3131

@@ -114,6 +114,7 @@ for _bash_it_config_file in $CUSTOM; do
114114
if [ -e "${_bash_it_config_file}" ]; then
115115
filename=$(basename "${_bash_it_config_file}")
116116
filename=${filename%*.bash}
117+
# shellcheck disable=SC2034
117118
BASH_IT_LOG_PREFIX="custom: $filename: "
118119
_log_debug "Loading custom file..."
119120
# shellcheck disable=SC1090
@@ -122,7 +123,7 @@ for _bash_it_config_file in $CUSTOM; do
122123
done
123124

124125
unset _bash_it_config_file
125-
if [[ $PROMPT ]]; then
126+
if [[ -n "${PROMPT:-}" ]]; then
126127
export PS1="\[""$PROMPT""\]"
127128
fi
128129

@@ -144,7 +145,7 @@ if [ -e "$HOME/.jekyllconfig" ]; then
144145
fi
145146

146147
# BASH_IT_RELOAD_LEGACY is set.
147-
if ! command -v reload &> /dev/null && [ -n "$BASH_IT_RELOAD_LEGACY" ]; then
148+
if ! _command_exists reload && [[ -n "${BASH_IT_RELOAD_LEGACY:-}" ]]; then
148149
case $OSTYPE in
149150
darwin*)
150151
alias reload='source ~/.bash_profile'

0 commit comments

Comments
 (0)