Skip to content

Commit

Permalink
Merge branch 'master' into bats-precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
seefood authored Nov 7, 2024
2 parents 984c0c6 + 6949272 commit c5be0e7
Show file tree
Hide file tree
Showing 25 changed files with 363 additions and 56 deletions.
22 changes: 15 additions & 7 deletions aliases/available/git.aliases.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ about-alias 'common git abbreviations'

alias g='git'
alias get='git'
alias got='git '

# add
alias ga='git add'
Expand Down Expand Up @@ -32,6 +33,9 @@ alias gca='git commit -v -a'
alias gcaa='git commit -a --amend -C HEAD' # Add uncommitted and unstaged changes to the last commit
alias gcam='git commit -v -am'
alias gcamd='git commit --amend'
alias gc!='git commit -v --amend'
alias gca!='git commit -v -a --amend'
alias gcn!='git commit -v --amend --no-edit'
alias gcm='git commit -v -m'
alias gci='git commit --interactive'
alias gcsam='git commit -S -am'
Expand Down Expand Up @@ -79,6 +83,8 @@ alias ggup='git log --branches --not --remotes --no-walk --decorate --oneline' #
alias gll='git log --graph --pretty=oneline --abbrev-commit'
alias gnew='git log HEAD@{1}..HEAD@{0}' # Show commits since last pull, see http://blogs.atlassian.com/2014/10/advanced-git-aliases/
alias gwc='git whatchanged'
alias ghist='git log --pretty=format:'\''%h %ad | %s%d [%an]'\'' --graph --date=short' # Use it to be fast and without color.
alias gprogress='git log --pretty=format:'\''%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d'\'' --decorate --date=short' #Usually use "git progress" in the file .gitconfig. The new alias from Git friends will be truly welcome.

# ls-files
alias gu='git ls-files . --exclude-standard --others' # Show untracked files
Expand Down Expand Up @@ -110,7 +116,8 @@ alias gpatch='git format-patch -1'
# push
alias gp='git push'
alias gpd='git push --delete'
alias gpf='git push --force'
alias gpf='git push --force-with-lease'
alias gpff='git push --force'
alias gpo='git push origin HEAD'
alias gpom='git push origin $(get_default_branch)'
alias gpu='git push --set-upstream'
Expand All @@ -120,6 +127,7 @@ alias gpuoc='git push --set-upstream origin $(git symbolic-ref --short HEAD)'

# pull
alias gl='git pull'
alias glp='git pull --prune'
alias glum='git pull upstream $(get_default_branch)'
alias gpl='git pull'
alias gpp='git pull && git push'
Expand All @@ -132,6 +140,7 @@ alias grv='git remote -v'

# rm
alias grm='git rm'
alias grmc='git rm --cached' # Removes the file only from the Git repository, but not from the filesystem. This is useful to undo some of the changes you made to a file before you commit it.

# rebase
alias grb='git rebase'
Expand All @@ -144,7 +153,9 @@ alias grma='GIT_SEQUENCE_EDITOR=: git rebase $(get_default_branch) -i --autosqu
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

# reset
alias gus='git reset HEAD'
alias gus='git reset HEAD' # read as: 'git unstage'
alias grh='git reset' # equivalent to: git reset HEAD
alias grh!='git reset --hard'
alias gpristine='git reset --hard && git clean -dfx'

# status
Expand Down Expand Up @@ -211,9 +222,6 @@ function gdv() {
}

function get_default_branch() {
if git branch | grep -q '^. main\s*$'; then
echo main
else
echo master
fi
branch=$(git symbolic-ref refs/remotes/origin/HEAD)
${branch#refs/remotes/origin/}
}
13 changes: 12 additions & 1 deletion aliases/available/maven.aliases.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@ about-alias 'maven abbreviations'

alias mci='mvn clean install'
alias mi='mvn install'
alias mcp='mvn clean package'
alias mc='mvn clean'
alias mct='mvn clean test'
alias mcc='mvn clean compile'
alias mccnt='mvn clean compile -DskipTests=true'
alias mp='mvn package'
alias mcp='mvn clean package'
alias mcpnt='mvn clean package -DskipTests=true'
alias mrprep='mvn release:prepare'
alias mrperf='mvn release:perform'
alias mrrb='mvn release:rollback'
alias mdep='mvn dependency:tree'
alias mpom='mvn help:effective-pom'
alias mcisk='mci -Dmaven.test.skip=true'
alias mcpsk='mcp -Dmaven.test.skip=true'

# Maven service plugin aliases
alias mspring='mvn spring-boot:run'
alias mjetty='mvn jetty:run'
alias mquark='mvn quarkus:dev'
alias mmicro='mvn mn:run'
21 changes: 9 additions & 12 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
aliases/
docs/
hooks/
lib/
scripts/
test/

Expand All @@ -32,6 +33,7 @@ lint_clean_files.sh

# completions
#
completion/available/aliases.completion.bash
completion/available/apm.completion.bash
completion/available/awless.completion.bash
completion/available/awscli.completion.bash
Expand All @@ -47,6 +49,7 @@ completion/available/dmidecode.completion.bash
completion/available/docker-machine.completion.bash
completion/available/docker.completion.bash
completion/available/dotnet.completion.bash
completion/available/export.completion.bash
completion/available/flutter.completion.bash
completion/available/gcloud.completion.bash
completion/available/gem.completion.bash
Expand Down Expand Up @@ -79,18 +82,6 @@ completion/available/vuejs.completion.bash
completion/available/wpscan.completion.bash
completion/available/yarn.completion.bash

# libraries
lib/appearance.bash
lib/colors.bash
lib/command_duration.bash
lib/helpers.bash
lib/history.bash
lib/log.bash
lib/preexec.bash
lib/preview.bash
lib/search.bash
lib/utilities.bash

# plugins
#
plugins/available/alias-completion.plugin.bash
Expand Down Expand Up @@ -135,6 +126,7 @@ plugins/available/rbenv.plugin.bash
plugins/available/ruby.plugin.bash
plugins/available/textmate.plugin.bash
plugins/available/todo.plugin.bash
plugins/available/url.plugin.bash
plugins/available/xterm.plugin.bash
plugins/available/zoxide.plugin.bash

Expand All @@ -160,9 +152,13 @@ themes/bobby-python
themes/brainy
themes/brunton
themes/candy
themes/clean
themes/easy
themes/elixr
themes/essential
themes/githelpers.theme.bash
themes/inretio
themes/lambda
themes/modern
themes/norbu
themes/oh-my-posh
Expand All @@ -172,6 +168,7 @@ themes/powerline
themes/pure
themes/purity


# vendor init files
#
vendor/.gitattributes
8 changes: 4 additions & 4 deletions completion/available/aliases.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function _bash-it-component-completion-callback-on-init-aliases() {
completions=("${completions[@]##complete -* * -}") # strip all but last option plus trigger(s)
completions=("${completions[@]#complete -}") # strip anything missed
completions=("${completions[@]#? * }") # strip last option and arg, leaving only trigger(s)
completions=("${completions[@]#? }") # strip anything missed
completions=("${completions[@]#? }") # strip anything missed
#TODO: this will fail on some completions...

# create temporary file for wrapper functions and completions
Expand All @@ -40,10 +40,10 @@ function _bash-it-component-completion-callback-on-init-aliases() {
line="${line#alias -- }"
line="${line#alias }"
alias_name="${line%%=*}"
alias_defn="${line#*=\'}" # alias definition
alias_defn="${line#*=\'}" # alias definition
alias_defn="${alias_defn%\'}"
alias_cmd="${alias_defn%%[[:space:]]*}" # first word of alias
if [[ ${alias_defn} == ${alias_cmd} ]]; then
if [[ ${alias_defn} == "${alias_cmd}" ]]; then
alias_args=''
else
alias_args="${alias_defn#*[[:space:]]}" # everything after first word
Expand Down Expand Up @@ -89,7 +89,7 @@ function _bash-it-component-completion-callback-on-init-aliases() {
prec_word=\${prec_word#* }
fi
(( COMP_CWORD += ${#alias_arg_words[@]} ))
COMP_WORDS=(\"$alias_cmd\" \"${alias_arg_words[@]}\" \"\${COMP_WORDS[@]:1}\")
COMP_WORDS=(\"$alias_cmd\" \"${alias_arg_words[*]}\" \"\${COMP_WORDS[@]:1}\")
(( COMP_POINT -= \${#COMP_LINE} ))
COMP_LINE=\${COMP_LINE/$alias_name/$alias_cmd $alias_args}
(( COMP_POINT += \${#COMP_LINE} ))
Expand Down
4 changes: 3 additions & 1 deletion completion/available/export.completion.bash
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
complete -o nospace -S = -W '$(printenv | awk -F= "{print \$1}")' export
# shellcheck shell=bash

complete -o nospace -S = -W "$(printenv | awk -F= "{print \$1}")" export
15 changes: 15 additions & 0 deletions docs/themes-list/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,21 @@ Envy

----

Inretio
^^^^^^^


.. image:: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-black.png
:target: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-black.png
:alt: Inretio theme in dark color scheme


.. image:: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-white.png
:target: https://raw.githubusercontent.com/inretio/bash-it/gh-pages/docs/images/inretio-white.png
:alt: Inretio theme in light color scheme

----

Iterate
^^^^^^^

Expand Down
32 changes: 32 additions & 0 deletions docs/themes-list/inretio.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.. _inretio:

Inretio Theme
=============

Simple theme showing date and time, username and hostname, current folder, Git details and as a bonus - virtual environment along with Python version available in it.

Inspired by existing themes:
- metal
- bobby

Examples
--------

In Git-tracked folder:

.. code-block:: bash
┌──[2024-03-20 12:05:07] 🐧 gytis 💻 gytis-legion 📂 bash-it on 🌵 theme-inretio ⌀1 ✗
> ls
aliases clean_files.txt custom hooks lib lint_clean_files.sh profiles template test_lib uninstall.sh
bash_it.sh completion docs install.sh LICENSE plugins scripts test themes vendor
In Python virtual environment:

.. code-block:: bash
┌──[2024-03-20 12:07:32] 🐧 gytis 💻 gytis-legion 🐍 3.12.2 on [general] 📂 general
> ls
bin include lib lib64 pyvenv.cfg share
2 changes: 1 addition & 1 deletion docs/themes-list/powerline-base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
* ``python_venv`` - Python virtual environment information (\ ``virtualenv``\ , ``venv``
and ``conda`` supported)
* ``ruby`` - Current ruby version if using ``rvm``
* ``node`` - Current node version (only ``nvm`` is supported)
* ``node`` - Current node version (``nvm`` is the default strategy; set ``NODE_VERSION_STRATEGY`` to ``node`` to use ``node --version``)
* ``scm`` - Version control information, ``git``
* ``terraform`` - Current terraform workspace
* ``user_info`` - Current user
Expand Down
2 changes: 1 addition & 1 deletion lib/command_duration.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function _dynamic_clock_icon {
local clock_hand
# clock hand value is between 90 and 9b in hexadecimal.
# so between 144 and 155 in base 10.
printf -v clock_hand '%x' $(((${1:-${SECONDS}} % 12) + 144))
printf -v clock_hand '%x' $((((${1:-${SECONDS}} - 1) % 12) + 144))
printf -v 'COMMAND_DURATION_ICON' '%b' "\xf0\x9f\x95\x$clock_hand"
}

Expand Down
2 changes: 1 addition & 1 deletion lint_clean_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mapfile -t FILES < <(
cat clean_files.txt \
| grep -E -v '^\s*$' \
| grep -E -v '^\s*#' \
| xargs -n1 -I{} find "{}" -type f
| xargs -I{} find "{}" -type f
)

# We clear the BASH_IT variable to help the shellcheck checker
Expand Down
10 changes: 8 additions & 2 deletions plugins/available/gif.plugin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function v2gif() {
fi

# Parse the options
args=$("$getopt" -l "alert:" -l "lossy:" -l "width:" -l del,delete -l high -l tag -l "fps:" -l webm -o "a:l:w:f:dhmt" -- "$@") || {
args=$("$getopt" -l "alert:" -l "lossy:" -l "width:" -l del,delete -l high -l help -l tag -l "fps:" -l webm -o "a:l:w:f:dhmt" -- "$@") || {
echo 'Terminating...' >&2
return 2
}
Expand All @@ -82,6 +82,7 @@ function v2gif() {
local fps=""
local make_webm=""
local alert=5000
local printhelp=""
while [[ $# -ge 1 ]]; do
case "$1" in
--)
Expand All @@ -94,6 +95,11 @@ function v2gif() {
opt_del_after="true"
shift
;;
--help)
# Print Help
printhelp="true"
shift
;;
-h | --high)
#High Quality, use gifski
gifski="$(type -p gifski)"
Expand Down Expand Up @@ -141,7 +147,7 @@ function v2gif() {
esac
done

if [[ -z "$*" ]]; then
if [[ -z "$*" || "$printhelp" ]]; then
echo "$(tput setaf 1)No input files given. Example: v2gif file [file...] [-w <max width (pixels)>] [-l <lossy level>] $(tput sgr 0)"
echo "-d/--del/--delete Delete original vid if done suceessfully (and file not over the size limit)"
echo "-h/--high High Quality - use Gifski instead of gifsicle"
Expand Down
12 changes: 10 additions & 2 deletions plugins/available/nvm.plugin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ cite about-plugin
about-plugin 'node version manager configuration'

export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"

# first check if NVM is managed by brew
NVM_BREW_PREFIX=""
if _bash_it_homebrew_check
then
NVM_BREW_PREFIX=$(brew --prefix nvm 2>/dev/null)
fi

# This loads nvm
if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" ]]
if [[ -n "$NVM_BREW_PREFIX" && -s "${NVM_BREW_PREFIX}/nvm.sh" ]]
then
source "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh"
source "${NVM_BREW_PREFIX}/nvm.sh"
else
[[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
fi
Expand Down
45 changes: 45 additions & 0 deletions plugins/available/url.plugin.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'Basic url handling and manipulation functions'

function slugify() {
about 'takes the text and transform to slug url, also supports formats like (html,link,rst,md)'
group 'url'
param "1: Text to transform (optional)"
param "2: Output format (html,rst,link,md). Omit or pass any text to return only output"

local TXT=$1
local OUTPUT=$2
local SLUG

if [[ -z $TXT ]]; then
read -rp "Enter the valid string: " TXT
fi

# Pass 1 - Clean the url
# Credits: https://stackoverflow.com/a/20007549/10362396
SLUG=$(echo -n "$TXT" | tr -cd ' [:alnum:]._-' | tr -s ' ')

# Pass 2 - Transformation
SLUG=$(echo -n "$SLUG" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')

case "$OUTPUT" in
html | htm)
echo "<a href=\"#$SLUG\">$TXT</a>"
;;
href | link)
echo "#$SLUG"
;;
md)
echo "[$TXT](#$SLUG)"
;;
rst)
echo "\`$TXT <#$SLUG>\`_"
;;

*)
echo "$SLUG"
;;
esac

}
Loading

0 comments on commit c5be0e7

Please sign in to comment.