Skip to content

Commit

Permalink
Update prompt and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robotdana committed Nov 26, 2023
1 parent 4de695c commit 1774e69
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 47 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ on: [push, pull_request]

jobs:
bats:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- run: test/ci.sh
spellr:
Expand All @@ -20,6 +19,5 @@ jobs:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- run: bundle exec spellr
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.1
3.2.2
1 change: 1 addition & 0 deletions .spellr_wordlists/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ libffi
localhost
lsof
lvh
macos
mailmap
makefile
marketfacer
Expand Down
8 changes: 5 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
GEM
remote: https://rubygems.org/
specs:
fast_ignore (0.15.2)
parallel (1.21.0)
spellr (0.9.1)
fast_ignore (0.17.4)
jaro_winkler (1.5.6)
parallel (1.23.0)
spellr (0.11.0)
fast_ignore (>= 0.11.0)
jaro_winkler
parallel (~> 1.0)

PLATFORMS
Expand Down
2 changes: 1 addition & 1 deletion bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ if [ -f /usr/local/bin/direnv ]; then
fi

export PS2="\[$C_PINK\]» \[$C_RESET\]"
export PS1="\[\$(last_command_style)\]\[$C_PINK\]\w\[$C_LIGHT_PINK\]\$(version_prompt)\[\$(git_status_color)\]\$(git_prompt_current_ref :)$PS2"
export PS1="\$(last_command_style)$C_PINK\w\$(prompt_version)\$(prompt_git)$PS2"
2 changes: 1 addition & 1 deletion bashrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source ~/.dotfiles/functions/bash_support.sh
source ~/.dotfiles/functions/git_support.sh
export PS2="\[$C_PINK\]» \[$C_RESET\]"
export PS1="\[\$(last_command_style)\]\[$C_PINK\]\w\[$C_LIGHT_PINK\]\$(ruby_version_prompt)\[\$(git_status_color)\]\$(git_prompt_current_ref :)$PS2"
export PS1="\$(last_command_style)$C_PINK\w\$(prompt_version)\$(prompt_git)$PS2"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Expand Down
22 changes: 12 additions & 10 deletions functions/bash_support.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,27 @@ function check_untested_bash_profile {
fi
}

function version_prompt {
ruby_version=$(ruby_version_prompt)
node_version=$(node_version_prompt)
function prompt_version {
ruby_version="$(prompt_ruby_version | cut -d. -f1,2)"
node_version="$(prompt_node_version | cut -d. -f1,2)"
if [[ ! -z "$ruby_version" ]] && [[ ! -z "$node_version" ]]; then
echo "{$ruby_version,$node_version}"
elif [[ ! -z "$ruby_version" ]] || [[ ! -z "$node_version" ]]; then
echo "{$ruby_version$node_version}"
echo -ne "$C_LIGHT_PINK{r$ruby_version,n$node_version}"
elif [[ ! -z "$ruby_version" ]]; then
echo -ne "$C_LIGHT_PINK{r$ruby_version}"
elif [[ ! -z "$ruby_version" ]]; then
echo -ne "$C_LIGHT_PINK{n$node_version}"
fi
}

function ruby_version_prompt {
function prompt_ruby_version {
if [ -f Gemfile ]; then
echo "r$(ruby --version | cut -d' ' -f 2 | cut -dp -f1 | cut -d. -f1,2 )"
ruby --version | cut -d' ' -f 2 | cut -dp -f1
fi
}

function node_version_prompt {
function prompt_node_version {
if [ -f package.json ]; then
echo "n$(nvm current | colrm 1 1 | cut -d. -f1,2 )"
nvm current | colrm 1 1 | cut -d. -f1,2
fi
}

Expand Down
50 changes: 26 additions & 24 deletions functions/git_support.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,24 +289,38 @@ function git_current_branch() {
}

function git_branch_name() {
ref=$(git rev-parse --symbolic-full-name --abbrev-ref "$1")
ref=$(git rev-parse --symbolic-full-name --abbrev-ref "$1" 2>/dev/null)
[[ -z "$ref" ]] && echo "$1" || echo "$ref"
}

# TODO: test
function git_prompt_current_ref() {
local ref
ref=$(git_current_branch)
if [[ $ref == 'HEAD' ]]; then
ref=$(git branch --format='%(refname:short)' --sort=-committerdate --contains HEAD 2>/dev/null | head -n 1)
local subref="$(git rev-parse --short HEAD 2>/dev/null)"

if [[ ! -z $subref ]]; then
ref="$ref[$subref]"
function prompt_git() {
if git rev-parse --is-inside-work-tree >/dev/null 2>/dev/null; then
local ref
local color

if git_status_clean; then
if git_head_pushed; then
color="$C_AQUA"
else
color="$C_GREEN"
fi
else
color="$C_YELLOW"
fi

ref=$(git_current_branch 2>/dev/null)
if [[ $ref == 'HEAD' ]]; then
ref=$(git branch --format='%(refname:short)' --sort=-committerdate --contains HEAD 2>/dev/null | head -n 1)
local subref="$(git rev-parse --short HEAD 2>/dev/null)"

if [[ ! -z $subref ]]; then
ref="$ref[$subref]"
fi
fi
fi

[[ ! -z $ref ]] && echo "$1$ref"
echo -ne "$color:$ref"
fi
}

function git_current_repo() {
Expand Down Expand Up @@ -569,18 +583,6 @@ function git_head_pushed() {
fi
}

function git_status_color() {
if git_status_clean; then
if git_head_pushed; then
echo -en "$C_AQUA"
else
echo -en "$C_GREEN"
fi
else
echo -en "$C_YELLOW"
fi
}

function git_changed_files_after_merge() {
git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD
}
Expand Down
2 changes: 1 addition & 1 deletion test/bats
Submodule bats updated 260 files
2 changes: 1 addition & 1 deletion test/test_helper/bats-file
Submodule bats-file updated 45 files
+38 −0 .github/workflows/tests.yml
+3 −0 .gitignore
+0 −11 .travis.yml
+23 −0 CHANGELOG.md
+119 −60 README.md
+36 −0 Vagrantfile
+277 −280 src/file.bash
+13 −11 src/temp.bash
+13 −13 test/50-assert-10-assert_exists.bats
+11 −11 test/50-assert-11-assert_not_exists.bats
+11 −11 test/51-assert-10-assert_file_exists.bats
+11 −11 test/51-assert-11-assert_file_not_exists.bats
+1 −1 test/52-assert-10-assert_file_executable.bats
+0 −0 test/52-assert-11-assert_file_not_executable.bats
+11 −11 test/53-assert-10-assert_link_exists.bats
+10 −10 test/53-assert-11-assert_link_not_exists.bats
+12 −12 test/54-assert-10-assert_character_exists.bats
+11 −11 test/54-assert-11-assert_character_not_exists.bats
+12 −12 test/55-assert-10-assert_block_exists.bats
+11 −11 test/55-assert-11-assert_block_not_exists.bats
+10 −10 test/56-assert-10-assert_fifo_exists.bats
+10 −10 test/56-assert-11-assert_fifo_not_exists.bats
+10 −10 test/57-assert-10-assert_socket_exists.bats
+10 −10 test/57-assert-11-assert_socket_not_exists.bats
+2 −1 test/58-assert-10-assert_equal_files.bats
+2 −1 test/58-assert-11-assert_not_equal_files.bats
+9 −4 test/59-assert-10-assert_file_owner.bats
+13 −7 test/59-assert-11-assert_not_file_owner.bats
+1 −2 test/60-assert-10-assert_file_permission.bats
+2 −3 test/60-assert-11-assert_file_no_permissions.bats
+11 −9 test/61-assert-10-size_zero.bats
+11 −10 test/61-assert-11-size_not_zero.bats
+20 −10 test/65-assert-10-assert_symlink_to.bats
+13 −0 test/67-assert-10-assert_file_contains.bats
+53 −0 test/67-assert-10-assert_file_not_contains.bats
+19 −7 test/70-temp-10-temp_make.bats
+44 −7 test/70-temp-11-temp_del.bats
+4 −0 test/fixtures/temp/temp_del-main.bats
+12 −0 test/fixtures/temp/temp_del-setup_file.bats
+12 −0 test/fixtures/temp/temp_del-teardown_file.bats
+4 −0 test/fixtures/temp/temp_make-main.bats
+15 −0 test/fixtures/temp/temp_make-setup_file.bats
+12 −0 test/fixtures/temp/temp_make-teardown_file.bats
+1 −1 test/fixtures/temp/test_helper.bash
+13 −1 test/test_helper.bash

0 comments on commit 1774e69

Please sign in to comment.