Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
robotdana committed Dec 3, 2023
1 parent cad03d2 commit 6ad7412
Show file tree
Hide file tree
Showing 38 changed files with 241 additions and 146 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "github-cctray"]
path = github-cctray
url = [email protected]:robotdana/github-cctray.git
[submodule "monokai.terminal"]
path = monokai.terminal
url = [email protected]:robotdana/monokai.terminal.git
1 change: 0 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ xcode-select --install
git clone [email protected]:robotdana/dotfiles.git ~/.dotfiles
~/.dotfiles/scripts/install.sh
change the computer name
set Terminal.app to bash
sign in to 1pass
copy istatmenus config from 1pass
sign in to everything else
Expand Down
12 changes: 6 additions & 6 deletions bash_profile
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ track_source ~/.dotfiles/functions/colors
track_source ~/.dotfiles/functions/functionify

# have functions for things i call _all the time_
track_functionify_q echodo echoerr echo_color be
track_functionify_q echodo echodont echoerr be

# have functions for things called by prompt
track_functionify_q prompt_last_command_style
track_functionify_q prompt_base_style
track_functionify_q prompt_version
track_functionify_q prompt_git_color git_status_clean git_head_pushed
track_functionify_q prompt_git_color git_status_clean
track_functionify_q prompt_git git_branch_name

#
# some thing just work better as functions
track_functionify_q resource # as a function it won't reset history

export PS2="\[$COLOR_PINK\]» \[$COLOR_RESET\]"
export PS1="\[\$(prompt_last_command_style)$COLOR_PINK\]\w\[$COLOR_LIGHT_PINK\]\$(prompt_version)\[\$(prompt_git_color)\]\$(prompt_git)$PS2"
export PS2='\[\033[1K\r$(prompt_base_style)\]» \[\033]0m\]'
export PS1='\[\033[1K\r$(prompt_base_style)\]\w\[\033[38;5;205m\]$(prompt_version)\[$(prompt_git_color)\]$(prompt_git)\[\033[38;5;199m\]» \[\033[0m\]'

track_and_resource
8 changes: 2 additions & 6 deletions bashrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
. ~/.dotfiles/functions/color
PATH="~/.dotfiles/bin:$PATH"

export PS2="\[$COLOR_PINK\]» \[$COLOR_RESET\]"
export PS1="\[\$(last_command_style)$COLOR_PINK\]\w\$(prompt_version)\[\$(prompt_git_color)\]\$(prompt_git)$PS2"
export GPG_TTY=$(tty)
export PS2='\[\033[2K\r$(prompt_base_style)\]> \[\033]0m\]'
export PS1='\[\033[2K\r$(prompt_base_style)\]\w\[\033[38;5;205m\]$(prompt_version)\[$(prompt_git_color)\]$(prompt_git)\[\033[38;5;199m\]> \[\033[0m\]'
20 changes: 20 additions & 0 deletions bin/colors
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# modified from https://askubuntu.com/a/279014
for background in 49 40 41 42 43 44 45 46 47; do
echo -ne "\033[${background}m \033[0m"
done
echo
for style in 22 '1' '2'; do
for foreground in 39 30 31 32 33 34 35 36 37; do
for background in 49 40 41 42 43 44 45 46 47; do
echo -ne "\033[${style};${foreground};${background}m $((( style < 10 )) && echo ' ')${style};${foreground};${background} \033[0m"
done
echo
done
for background in 49 40 41 42 43 44 45 46 47; do
echo -ne "\033[${background}m \033[0m"
done
echo
done
echo ""
3 changes: 1 addition & 2 deletions bin/copy_functions
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env bash

output=~/.dotfiles/bin_new
output=~/.dotfiles/bin
rm -rf $output
mkdir -p $output

functions=( $(bash -lc 'declare -F' | cut -d' ' -f3 | sort | grep -v '^_') )
# already_bin=( $(ls -1 ~/.dotfiles/bin | sort) )

for fn in "${functions[@]}"; do
if which -s "$fn"; then
Expand Down
2 changes: 1 addition & 1 deletion bin/crt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

echo -n $COLOR_GREY"COVERAGE=1 MIN_COVERAGE=100 "$COLOR_RESET
echo -n $'\033[0;2m'COVERAGE=1 MIN_COVERAGE=100
COVERAGE=1 MIN_COVERAGE=100 rt "$@" || echodo open coverage/index.html
8 changes: 0 additions & 8 deletions bin/echo_color

This file was deleted.

2 changes: 1 addition & 1 deletion bin/echo_suggest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

echo_color AQUA run: "$@"
echo $'\033[36m'run: "$@"$'\033[0m'
false
22 changes: 1 addition & 21 deletions bin/echodo
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
#!/usr/bin/env bash

str="$COLOR_GREY"
space=''
for string in "$@"; do
str="$str$space"

if [[ -z "$string" ]]; then
str="$str''"
elif [[ "$string" =~ \'|\"|\ |\&|\{|\}|\(|\)|\[|\]|\$|\<|\>|\||\;|$'\n' ]]; then
if [[ "$string" =~ \' ]]; then
str="$str"\""${string//\"/\\\"}"\"
else
str="$str"\'"$string"\'
fi
else
str="$str$string"
fi

space=" "
done

echo -e "$str\033[0m" >&2
echodont "$@"
"$@"
23 changes: 23 additions & 0 deletions bin/echodont
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

str=$'\033[0;2m'
space=''
for string in "$@"; do
str="$str$space"

if [[ -z "$string" ]]; then
str="$str''"
elif [[ "$string" =~ \'|\"|\ |\&|\{|\}|\(|\)|\[|\]|\$|\<|\>|\||\;|$'\n' ]]; then
if [[ "$string" =~ \' ]]; then
str="$str"\""${string//\"/\\\"}"\"
else
str="$str"\'"$string"\'
fi
else
str="$str$string"
fi

space=" "
done

echo -e "$str"$'\033[0m' >&2
2 changes: 1 addition & 1 deletion bin/echoerr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

echo_color RED error: "$@" >&2
echo $'\033[31m'error: "$@"$'\033[0m' >&2
false
2 changes: 1 addition & 1 deletion bin/edot
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
if (( $# > 0 )); then
files=( $(grep -rn "${@/#/-e }" ~/.dotfiles | cut -f1,2 -d:) )
fi
echodo code ${files[@]/#/-g } -n ~/.dotfiles
echodo code -n ~/.dotfiles
6 changes: 2 additions & 4 deletions bin/gbf
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash

# `gbf <filename> [<base branch>]` git branch file
# shows commits modifying <filename> since this branch forked from <base_branch> or main branch.
# `gbf <filename>` git branch file

filename=$1;
base_branch=${2:-"$(git_main_base_branch)"};
echodo git log --oneline --follow --patch $(git_log_range "$base_branch") -- "$filename"
git_log_oneline_new --follow --patch -- "$filename"
2 changes: 1 addition & 1 deletion bin/git_bisect
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

if echodo "${@:2}"; then
echo ${COLOR_GREEN}HEAD passes$COLOR_RESET
echo HEAD passes
else
echodo git bisect reset # TODO: don't do this if you're not bisecting so there's no error
echodo git bisect start
Expand Down
7 changes: 7 additions & 0 deletions bin/git_branch_if_exist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

if [[ ! -z "$1" ]] && git rev-parse --verify -q "$1" >/dev/null 2>/dev/null; then
echo $1
else
false
fi
2 changes: 1 addition & 1 deletion bin/git_branch_name
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

git rev-parse --symbolic-full-name --abbrev-ref ${1:-HEAD} 2>/dev/null
git rev-parse --verify --symbolic-full-name --abbrev-ref=strict ${1:-HEAD} 2>/dev/null
2 changes: 1 addition & 1 deletion bin/git_head_pushed
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

[[ "$(git rev-parse @{u} 2>/dev/null)" == "$(git rev-parse HEAD 2>/dev/null)" ]]

12 changes: 8 additions & 4 deletions bin/git_log_oneline
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#!/usr/bin/env bash





echo ${COLOR_GREY}git log --oneline $(git_log_range "$1")$COLOR_RESET 1>&2;
commits_in_origin=$(echo $(git log --format="%h" $(git merge-base --fork-point $(git_main_base_branch)) 2>/dev/null));
# local commits_in_origin=$(echo -e $(git log --format="%h" $(git_log_range "$1" HEAD) 2>/dev/null))
commit_in_origin_condition='index("'$commits_in_origin'", $2) > 0';
git log --format="%b%n§%h§%s§%cr" $(git_log_range "$1") | awk -F'§' '{
git log --reverse --format="%b%n§%h§%s§%cr" | awk -F'§' '{
if ($0 ~ "^$") {
# do nothing
} else if ($1 != "" ) {
Expand All @@ -15,15 +19,15 @@ git log --format="%b%n§%h§%s§%cr" $(git_log_range "$1") | awk -F'§' '{
} else {
printf "%s", "'$COLOR_GREEN'"
}
printf "%s%s%s%s%s", $2, " '$COLOR_RESET'", $3, " \033[2m", $4
printf "%s%s%s%s%s", $2, " '$COLOR_RESET'", $3, " '$COLOR_LOWLIGHT", $4
if (body != "") {
gsub("\r", "", body)
printf "%s%s", "'$COLOR_GREY'\033[2m", body
printf "%s%s", "'$COLOR_GREY''$COLOR_LOWLIGHT'", body
}
body=""
print "\033[0m"
print "'$COLOR_RESET'"
}
}'
3 changes: 3 additions & 0 deletions bin/git_log_oneline_new
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
# git_main_remote_branch >/dev/null 2>&1 # ensure we have origin/HEAD and upstream/HEAD if we should
git --no-pager log --color --reverse --format='%h%Creset%(decorate) %s %C(dim)%cr - %cn%Creset' "$@"
2 changes: 2 additions & 0 deletions bin/git_log_oneline_new_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash

64 changes: 64 additions & 0 deletions bin/git_log_oneline_process
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env ruby --disable-all

if ARGV.delete('--off')
while gets
puts $_
end
exit 0
end

def branch_exist?(branch)
(
@branch_exist ||= Hash.new do |hash, key|
hash[key] = key && !`git_branch_if_exist #{key}`.chomp.empty?
end
)[branch]
end

def main_branch
@main_branch ||= `git_main_branch`.chomp
end

def current_branch
@current_branch ||= `git_branch_name`.chomp
end

def current_branch_main?
main_branch == current_branch
end

$forks = {
magenta: 'upstream/HEAD',
blue: (branch_exist?('origin/HEAD') ? 'origin/HEAD' : main_branch),
cyan: ('@{u}' unless current_branch_main?)
}

$forks.select! { |k, v| branch_exist?(v) }

gets
exit 0 unless $_
sha, rest = $_.split("\e", 2)
first = `git rev-parse --short #{sha}^ 2>/dev/null`.chomp
first = first.empty? ? '' : "#{first}.."
$forks.transform_values! do |v|
`git log --format=%h #{first}#{v}`.chomp.split("\n").to_h { |k| [k, nil] }
end
def render(sha, rest)
color = if $forks[:magenta]&.key?(sha)
"\e[35m"
elsif $forks[:blue]&.key?(sha)
"\e[34m"
elsif $forks[:cyan]&.key?(sha)
"\e[36m"
else
"\e[32m"
end
"#{color}#{sha}\e#{rest.chomp}\e[0m"
end
print "\x1b[?7l"
print render(sha, rest)
while gets
puts
print render(*$_.split("\e", 2))
end
puts "\x1b[?7h"
3 changes: 1 addition & 2 deletions bin/git_main_base_branch
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash

# The most canonical branch

git_main_remote_branch || git_main_branch
git_main_remote_branch || git_main_branch_no_remote
22 changes: 4 additions & 18 deletions bin/git_main_branch
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
#!/usr/bin/env bash

branch_if_exist()
{
git branch --list --format="%(refname:short)" "$1"
}
branch_fallback()
{
branch_if_exist "$(git config init.defaultBranch)" || \
branch_if_exist main || \
branch_if_exist master || \
branch_if_exist trunk || \
branch_if_exist primary || \
git_branch_name
}

remote_branch=$(git_main_remote_branch)
branch=${remote_branch#*/}

echo ${branch:-$(branch_fallback)}
# the local version of the most canonical branch
remote_branch="$(git_main_remote_branch)"
branch="${remote_branch#*/}"
echo "${branch:-"$(git_main_branch_no_remote)"}"
9 changes: 9 additions & 0 deletions bin/git_main_branch_no_remote
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# origin/HEAD only works if we have an origin, otherwise, guess.
git_branch_if_exist "$(git config init.defaultBranch)" || \
git_branch_if_exist main || \
git_branch_if_exist master || \
git_branch_if_exist trunk || \
git_branch_if_exist primary || \
git_branch_name
31 changes: 25 additions & 6 deletions bin/git_main_remote_branch
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
#!/usr/bin/env bash

remotes=( $(git remote) );
if (( ${#remotes[@]} == 0 )); then
# remotes can't contain spaces:
unsorted_remotes=( $(git remote) );

if (( ${#unsorted_remotes[@]} == 0 )); then
false
else
for remote in ${remotes[@]}; do
git rev-parse --verify --quiet $remote/HEAD >/dev/null 2>&1 || git remote set-head "$remote" -a >/dev/null 2>&1
git rev-parse --verify --symbolic-full-name --abbrev-ref=strict remotes/"$remote"/HEAD 2>/dev/null && break
false
# sort origin and upstream first
origin=()
upstream=()
rest_remotes=()

for remote in "${unsorted_remotes[@]}"; do
case "$remote" in
origin) origin+=(origin) ;;
upstream) upstream+=(upstream) ;;
*) rest_remotes+=($remote) ;;
esac
done

found=''

for remote in "${origin[@]}" "${upstream[@]}" "${rest_remotes[@]}"; do
git_branch_if_exist "$remote"/HEAD >/dev/null 2>&1 || \
git remote set-head "$remote" -a >/dev/null 2>&1 || \
( git fetch "$remote" >/dev/null 2>&1 && \ git remote set-head "$remote" -a >/dev/null 2>&1 )
[[ -z "$found" ]] && found=$(git_branch_name "$remote"/HEAD 2>/dev/null)
done
[[ ! -z "$found" ]] && echo $found || false
fi
2 changes: 1 addition & 1 deletion bin/git_modified
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

git diff --name-only HEAD --diff-filter=ACM -- "${@/#/*}"
git diff --name-only HEAD --diff-filter=ACM -- "${@/#/*}"
Loading

0 comments on commit 6ad7412

Please sign in to comment.