Skip to content

Commit

Permalink
Merge pull request #2266 from seefood/ira/lint-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
seefood authored Nov 7, 2024
2 parents 775044b + 9df0c64 commit 5fd2afe
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 97 deletions.
6 changes: 3 additions & 3 deletions aliases/available/git.aliases.bash
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ 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 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
Expand Down Expand Up @@ -153,8 +153,8 @@ 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' # read as: 'git unstage'
alias grh='git reset' # equivalent to: 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'

Expand Down
1 change: 1 addition & 0 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ plugins/available/base.plugin.bash
plugins/available/basher.plugin.bash
plugins/available/battery.plugin.bash
plugins/available/blesh.plugin.bash
plugins/available/browser.plugin.bash
plugins/available/cmd-returned-notify.plugin.bash
plugins/available/colors.plugin.bash
plugins/available/direnv.plugin.bash
Expand Down
1 change: 0 additions & 1 deletion docs/themes-list/inretio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ In Python virtual environment:
┌──[2024-03-20 12:07:32] 🐧 gytis 💻 gytis-legion 🐍 3.12.2 on [general] 📂 general
> ls
bin include lib lib64 pyvenv.cfg share
81 changes: 42 additions & 39 deletions plugins/available/browser.plugin.bash
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
# shellcheck shell=bash
# based on https://gist.github.com/318247

cite about-plugin
about-plugin 'render commandline output in your browser'

# shellcheck disable=SC2120
function browser() {
about 'pipe html to a browser'
example '$ echo "<h1>hi mom!</h1>" | browser'
example '$ ron -5 man/rip.5.ron | browser'
group 'browser'
about 'pipe html to a browser'
example '$ echo "<h1>hi mom!</h1>" | browser'
example '$ ron -5 man/rip.5.ron | browser'
group 'browser'

if [ -t 0 ]; then
if [ -n "$1" ]; then
open $1
else
reference browser
fi
if [ -t 0 ]; then
if [ -n "$1" ]; then
open "$1"
else
reference browser
fi

else
f="/tmp/browser.$RANDOM.html"
cat /dev/stdin > $f
open $f
fi
else
f="/tmp/browser.$RANDOM.html"
cat /dev/stdin > $f
open $f
fi
}


function wmate() {
about 'pipe hot spicy interwebs into textmate and cleanup!'
example '$ wmate google.com'
group 'browser'

if [ -t 0 ]; then
if [ -n "$1" ]; then
wget -qO- $1 | /usr/bin/mate
about 'pipe hot spicy interwebs into textmate and cleanup!'
example '$ wmate google.com'
group 'browser'

TIDY=`/usr/bin/osascript << EOT
if [ -t 0 ]; then
if [ -n "$1" ]; then
wget -qO- "$1" | /usr/bin/mate
TIDY=$(
/usr/bin/osascript << EOT
tell application "TextMate"
activate
end tell
Expand All @@ -53,24 +54,26 @@ tell application "System Events"
end tell
end tell
end tell
EOT`
EOT
)
export TIDY

else
reference wmate
fi
fi
else
reference wmate
fi
fi
}

function raw() {
about 'write wget into a temp file and pump it into your browser'
example '$ raw google.com'
group 'browser'
about 'write wget into a temp file and pump it into your browser'
example '$ raw google.com'
group 'browser'

if [ -t 0 ]; then
if [ -n "$1" ]; then
wget -qO- $1 | browser
else
reference raw
fi
fi
if [ -t 0 ]; then
if [ -n "$1" ]; then
wget -qO- "$1" | browser
else
reference raw
fi
fi
}
1 change: 1 addition & 0 deletions test/plugins/battery.plugin.bats
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ function setup_ioreg {
percent="$1"

function ioreg {
# shellcheck disable=SC2317
printf "\"MaxCapacity\" = 100\n\"CurrentCapacity\" = %s" "${percent}"
}
}
Expand Down
10 changes: 6 additions & 4 deletions test/plugins/cmd-returned-notify.plugin.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ function local_setup_file() {
}

@test "plugins cmd-returned-notify: notify after elapsed time" {
export NOTIFY_IF_COMMAND_RETURNS_AFTER=0
export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)"
NOTIFY_IF_COMMAND_RETURNS_AFTER=0
COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)"
export COMMAND_DURATION_START_SECONDS NOTIFY_IF_COMMAND_RETURNS_AFTER
sleep 1
run precmd_return_notification
assert_success
assert_output $'\a'
}

@test "plugins cmd-returned-notify: do not notify before elapsed time" {
export NOTIFY_IF_COMMAND_RETURNS_AFTER=10
export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)"
NOTIFY_IF_COMMAND_RETURNS_AFTER=10
COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)"
export COMMAND_DURATION_START_SECONDS NOTIFY_IF_COMMAND_RETURNS_AFTER
sleep 1
run precmd_return_notification
assert_success
Expand Down
4 changes: 2 additions & 2 deletions themes/base.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@ function node_version_prompt() {
_log_debug "node: using version strategy '$NODE_VERSION_STRATEGY'"

if [ "$NODE_VERSION_STRATEGY" == "nvm" ]; then
nvm_version_prompt
nvm_version_prompt
elif [ "$NODE_VERSION_STRATEGY" == "node" ]; then
node_native_version_prompt
node_native_version_prompt
fi
}

Expand Down
52 changes: 26 additions & 26 deletions themes/inretio/inretio.theme.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ VIRTUALENV_THEME_PROMPT_SUFFIX=""
# SCM prompts
SCM_NONE_CHAR=""
SCM_GIT_CHAR="[±] "
SCM_GIT_BEHIND_CHAR="${red}${normal}"
SCM_GIT_AHEAD_CHAR="${bold_green}${normal}"
SCM_GIT_BEHIND_CHAR="${red?}${normal?}"
SCM_GIT_AHEAD_CHAR="${bold_green?}${normal?}"
SCM_GIT_UNTRACKED_CHAR=""
SCM_GIT_UNSTAGED_CHAR="${bold_yellow}${normal}"
SCM_GIT_STAGED_CHAR="${bold_green}+${normal}"
SCM_GIT_UNSTAGED_CHAR="${bold_yellow?}${normal?}"
SCM_GIT_STAGED_CHAR="${bold_green?}+${normal?}"

SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""

# Git status prompts
GIT_THEME_PROMPT_DIRTY=" ${red}${normal}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
GIT_THEME_PROMPT_DIRTY=" ${red?}${normal?}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green?}${normal?}"
GIT_THEME_PROMPT_PREFIX=""
GIT_THEME_PROMPT_SUFFIX=""

Expand All @@ -48,32 +48,32 @@ icon_end="└> "

# Display virtual environment info
function _virtualenv_prompt {
VIRTUALENV_DETAILS=""
VIRTUALENV_CHAR=""

# $VIRTUAL_ENV is set and is non-zero length
if [[ -n "$VIRTUAL_ENV" ]]; then
# Check if Python 3 exists
if command -v python3 >/dev/null 2>&1; then
VIRTUALENV_DETAILS="$($VIRTUAL_ENV/bin/python --version | sed 's,Python ,,') on [$(basename $VIRTUAL_ENV)]"
VIRTUALENV_CHAR=" 🐍"
else
VIRTUALENV_DETAILS="[$(basename $VIRTUAL_ENV)]"
VIRTUALENV_CHAR=""
fi
fi

echo "$VIRTUALENV_CHAR $VIRTUALENV_DETAILS"
VIRTUALENV_DETAILS=""
VIRTUALENV_CHAR=""

# $VIRTUAL_ENV is set and is non-zero length
if [[ -n "$VIRTUAL_ENV" ]]; then
# Check if Python 3 exists
if command -v python3 > /dev/null 2>&1; then
VIRTUALENV_DETAILS="$("$VIRTUAL_ENV/bin/python" --version | sed 's,Python ,,') on [$(basename "$VIRTUAL_ENV")]"
VIRTUALENV_CHAR=" 🐍"
else
VIRTUALENV_DETAILS="[$(basename "$VIRTUAL_ENV")]"
VIRTUALENV_CHAR=""
fi
fi

echo "$VIRTUALENV_CHAR $VIRTUALENV_DETAILS"
}

# Rename tab
function tabname {
printf "\e]1;$1\a"
printf "\e]1;%s\a" "$1"
}

# Rename window
function winname {
printf "\e]2;$1\a"
printf "\e]2;%s\a" "$1"
}

_theme_clock() {
Expand All @@ -92,8 +92,8 @@ THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%Y-%m-%d %H:%M:%S"}

# Displays the current prompt
function prompt_command() {
PS1="\n${icon_start}$(_theme_clock)${icon_user}${bold_green}\u${normal}${icon_host}${bold_cyan}\h${normal}${green}$(_virtualenv_prompt)${normal}${icon_directory}${bold_purple}\W${normal}\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on ${icon_branch} $(scm_prompt_info) \")${white}${normal}\n${icon_end}"
PS2="${icon_end}"
PS1="\n${icon_start}$(_theme_clock)${icon_user}${bold_green?}\u${normal}${icon_host}${bold_cyan?}\h${normal}${green?}$(_virtualenv_prompt)${normal}${icon_directory}${bold_purple?}\W${normal}\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on ${icon_branch} $(scm_prompt_info) \")${white?}${normal}\n${icon_end}"
PS2="${icon_end}"
}

# Runs prompt (this bypasses bash_it $PROMPT setting)
Expand Down
46 changes: 24 additions & 22 deletions themes/lambda/lambda.theme.bash
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
#!/bin/bash
# shellcheck shell=bash
# shellcheck disable=SC1090,SC2034

function set_prompt {
local user_color="\[\033[1;31m\]" # bold red for username
local at_color="\[\033[1;37m\]" # bold white for @ symbol
local host_color="\[\033[1;31m\]" # bold red for hostname
local in_color="\[\033[1;37m\]" # bold white for "in"
local dir_color="\[\033[1;35m\]" # bold purple for current working directory
local git_color="\[\033[1;36m\]" # bold cyan for Git information
local time_color="\[\033[1;32m\]" # bold green for time taken
local reset_color="\[\033[0m\]" # reset color
local prompt_symbol_color="\[\033[1;31m\]" # bold red for the prompt symbol
local user_color="\[\033[1;31m\]" # bold red for username
local at_color="\[\033[1;37m\]" # bold white for @ symbol
local host_color="\[\033[1;31m\]" # bold red for hostname
local in_color="\[\033[1;37m\]" # bold white for "in"
local dir_color="\[\033[1;35m\]" # bold purple for current working directory
local git_color="\[\033[1;36m\]" # bold cyan for Git information
local time_color="\[\033[1;32m\]" # bold green for time taken
local reset_color="\[\033[0m\]" # reset color
local prompt_symbol_color="\[\033[1;31m\]" # bold red for the prompt symbol

local end_time=$(date +%s%3N) # current time in milliseconds
local time_taken=$(( (end_time - start_time) )) # time in milliseconds
local end_time time_taken
end_time=$(date +%s%3N) # current time in milliseconds
# shellcheck disable=SC2154
time_taken=$((end_time - start_time)) # time in milliseconds

PS1="${user_color}╭─\\u" # username
PS1+="${at_color}@${host_color}\\h" # @ symbol and hostname
PS1+="${in_color} in" # "in" between hostname and current directory
PS1+="${dir_color} \\w" # current working directory
PS1="${user_color}╭─\\u" # username
PS1+="${at_color}@${host_color}\\h" # @ symbol and hostname
PS1+="${in_color} in" # "in" between hostname and current directory
PS1+="${dir_color} \\w" # current working directory

# Git information (status symbol)
PS1+=" ${git_color}$(__git_ps1 "[%s]")${reset_color}"
# Git information (status symbol)
PS1+=" ${git_color}$(__git_ps1 "[%s]")${reset_color}"

if [ $time_taken -gt 0 ]; then
PS1+=" ${time_color}took ${time_taken}ms" # time taken in milliseconds
fi
if [ $time_taken -gt 0 ]; then
PS1+=" ${time_color}took ${time_taken}ms" # time taken in milliseconds
fi

PS1+="\n${prompt_symbol_color}╰─λ${reset_color} " # red color for the prompt symbol, reset color after
PS1+="\n${prompt_symbol_color}╰─λ${reset_color} " # red color for the prompt symbol, reset color after
}

PROMPT_COMMAND='start_time=$(date +%s%3N); set_prompt'

0 comments on commit 5fd2afe

Please sign in to comment.