Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40d154cb16 | ||
|
|
825fc88a8f | ||
|
|
c7d67aedb9 | ||
|
|
3838f12498 | ||
|
|
5e65235d0e | ||
|
|
8a36f21ca1 |
@@ -2,7 +2,7 @@
|
|||||||
cite "about-completion"
|
cite "about-completion"
|
||||||
about-completion "GitHub CLI completion"
|
about-completion "GitHub CLI completion"
|
||||||
|
|
||||||
if _command_exists gh; then
|
if _binary_exists gh; then
|
||||||
if _command_exists brew; then
|
if _command_exists brew; then
|
||||||
_log_warning "You don't need github-cli completion enabled if you have system completion enabled"
|
_log_warning "You don't need github-cli completion enabled if you have system completion enabled"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -26,6 +26,17 @@ function _command_exists ()
|
|||||||
type "$1" &> /dev/null || (_log_warning "$msg" && return 1) ;
|
type "$1" &> /dev/null || (_log_warning "$msg" && return 1) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _binary_exists ()
|
||||||
|
{
|
||||||
|
_about 'checks for existence of a binary'
|
||||||
|
_param '1: binary to check'
|
||||||
|
_param '2: (optional) log message to include when binary not found'
|
||||||
|
_example '$ _binary_exists ls && echo exists'
|
||||||
|
_group 'lib'
|
||||||
|
local msg="${2:-Binary '$1' does not exist!}"
|
||||||
|
type -P "$1" &> /dev/null || (_log_warning "$msg" && return 1) ;
|
||||||
|
}
|
||||||
|
|
||||||
function _make_reload_alias() {
|
function _make_reload_alias() {
|
||||||
echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}"
|
echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}"
|
||||||
}
|
}
|
||||||
@@ -80,7 +91,7 @@ bash-it ()
|
|||||||
_bash-it-search $component "$@"
|
_bash-it-search $component "$@"
|
||||||
return;;
|
return;;
|
||||||
update)
|
update)
|
||||||
func=_bash-it_update-$component;;
|
func=_bash-it-update-$component;;
|
||||||
migrate)
|
migrate)
|
||||||
func=_bash-it-migrate;;
|
func=_bash-it-migrate;;
|
||||||
version)
|
version)
|
||||||
@@ -158,18 +169,18 @@ _bash-it-plugins ()
|
|||||||
_bash-it-describe "plugins" "a" "plugin" "Plugin"
|
_bash-it-describe "plugins" "a" "plugin" "Plugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it_update-dev() {
|
_bash-it-update-dev() {
|
||||||
_about 'updates Bash-it to the latest master'
|
_about 'updates Bash-it to the latest master'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it_update- dev "$@"
|
_bash-it-update- dev "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it_update-stable() {
|
_bash-it-update-stable() {
|
||||||
_about 'updates Bash-it to the latest tag'
|
_about 'updates Bash-it to the latest tag'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_bash-it_update- stable "$@"
|
_bash-it-update- stable "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it_pull_and_update_inner() {
|
_bash-it_pull_and_update_inner() {
|
||||||
@@ -187,7 +198,7 @@ _bash-it_pull_and_update_inner() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it_update-() {
|
_bash-it-update-() {
|
||||||
_about 'updates Bash-it'
|
_about 'updates Bash-it'
|
||||||
_param '1: What kind of update to do (stable|dev)'
|
_param '1: What kind of update to do (stable|dev)'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|||||||
@@ -39,6 +39,26 @@ function local_setup {
|
|||||||
assert_failure
|
assert_failure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "helpers: _binary_exists function exists" {
|
||||||
|
run type -a _binary_exists &> /dev/null
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "helpers: _binary_exists function positive test ls" {
|
||||||
|
run _binary_exists ls
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "helpers: _binary_exists function negative test function" {
|
||||||
|
run _binary_exists _binary_exists
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "helpers: _binary_exists function negative test" {
|
||||||
|
run _binary_exists __addfkds_dfdsjdf
|
||||||
|
assert_failure
|
||||||
|
}
|
||||||
|
|
||||||
@test "helpers: bash-it help aliases ag" {
|
@test "helpers: bash-it help aliases ag" {
|
||||||
run bash-it help aliases "ag"
|
run bash-it help aliases "ag"
|
||||||
assert_line -n 0 "ag='ag --smart-case --pager=\"less -MIRFX'"
|
assert_line -n 0 "ag='ag --smart-case --pager=\"less -MIRFX'"
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ BARBUK_GIT_BRANCH_ICON=''
|
|||||||
BARBUK_HG_CHAR='☿ '
|
BARBUK_HG_CHAR='☿ '
|
||||||
BARBUK_SVN_CHAR='⑆ '
|
BARBUK_SVN_CHAR='⑆ '
|
||||||
BARBUK_EXIT_CODE_ICON=' '
|
BARBUK_EXIT_CODE_ICON=' '
|
||||||
|
BARBUK_PYTHON_VENV_CHAR=' '
|
||||||
```
|
```
|
||||||
|
|
||||||
### Customize glyphs
|
### Customize glyphs
|
||||||
@@ -97,3 +98,9 @@ chmod 400 /etc/sudoers.d/keepenv
|
|||||||
```bash
|
```bash
|
||||||
user@hostname in ~/bash-it on master ✓ ❯
|
user@hostname in ~/bash-it on master ✓ ❯
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Python venv
|
||||||
|
|
||||||
|
```bash
|
||||||
|
flask ~/test on master ✓ ❯
|
||||||
|
```
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ SCM_GIT_CHAR_ICON_BRANCH=${BARBUK_GIT_BRANCH_ICON:=''}
|
|||||||
SCM_HG_CHAR=${BARBUK_HG_CHAR:='☿ '}
|
SCM_HG_CHAR=${BARBUK_HG_CHAR:='☿ '}
|
||||||
SCM_SVN_CHAR=${BARBUK_SVN_CHAR:='⑆ '}
|
SCM_SVN_CHAR=${BARBUK_SVN_CHAR:='⑆ '}
|
||||||
EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '}
|
EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '}
|
||||||
|
PYTHON_VENV_CHAR=${BARBUK_PYTHON_VENV_CHAR:=' '}
|
||||||
|
|
||||||
# Ssh user and hostname display
|
# Ssh user and hostname display
|
||||||
SSH_INFO=${BARBUK_SSH_INFO:=true}
|
SSH_INFO=${BARBUK_SSH_INFO:=true}
|
||||||
@@ -90,12 +91,12 @@ function _prompt {
|
|||||||
|
|
||||||
# Detect python venv
|
# Detect python venv
|
||||||
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
|
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
|
||||||
python_venv="${CONDA_DEFAULT_ENV}"
|
python_venv="$PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV} "
|
||||||
elif [[ -n "${VIRTUAL_ENV}" ]]; then
|
elif [[ -n "${VIRTUAL_ENV}" ]]; then
|
||||||
python_venv=$(basename "${VIRTUAL_ENV}")
|
python_venv="$PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}") "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PS1="\\n${ssh_info} ${python_venv} ${purple}$(scm_char)${dir_color}\\w${normal}$(scm_prompt_info)${exit_code}"
|
PS1="\\n${ssh_info} ${purple}$(scm_char)${python_venv}${dir_color}\\w${normal}$(scm_prompt_info)${exit_code}"
|
||||||
|
|
||||||
[[ ${#PS1} -gt $((COLUMNS*3)) ]] && wrap_char="\\n"
|
[[ ${#PS1} -gt $((COLUMNS*3)) ]] && wrap_char="\\n"
|
||||||
PS1="${PS1}${wrap_char}❯${normal} "
|
PS1="${PS1}${wrap_char}❯${normal} "
|
||||||
|
|||||||
Reference in New Issue
Block a user