Skip to content

Commit

Permalink
Merge thoughtbot repo into this and add ~/.config/
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagogabriel committed Jul 13, 2024
1 parent d397ff2 commit e0a30eb
Show file tree
Hide file tree
Showing 76 changed files with 1,539 additions and 184 deletions.
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
LICENSE

The MIT License

Copyright (c) 2009-2016 thoughtbot, inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
1 change: 1 addition & 0 deletions agignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor
25 changes: 25 additions & 0 deletions aliases.local → aliases
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
# Unix
alias ll="ls -al"
alias ln="ln -v"
alias mkdir="mkdir -p"
alias e="$EDITOR"
alias v="$VISUAL"

# Bundler
alias b="bundle"

# Rails
alias migrate="bin/rails db:migrate db:rollback && bin/rails db:migrate db:test:prepare"
alias s="rspec"

# Pretty print the path
alias path='echo $PATH | tr -s ":" "\n"'

# Easier navigation: ..., ...., ....., and -
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias -- -="cd -"

alias mux='tmuxinator'
alias muxs='tmuxinator start'

alias notes='nvim -c "set nonumber" -c "set wrap" ~/Dropbox/TODO.txt'

# Ruby
alias befs='bundle exec foreman start'
alias fs='foreman start'
Expand Down
1 change: 1 addition & 0 deletions asdfrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
legacy_version_file = yes
15 changes: 15 additions & 0 deletions bin/bundler-search
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# Search your bundle for the provided pattern
# Requires bundler 1.8+ for execution as a bundler subcommand.
# Examples:
# bundle search Kernel.warn
# bundle search current_user clearance
# bundle search "Change your password" clearance
#
# Arguments:
# 1. What to search for
# 2. Which gem names to search (defaults to all gems)

pattern="$1"; shift
ag "$pattern" $(bundle show --paths "$@")
15 changes: 15 additions & 0 deletions bin/clear-port
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# Kills the process running on the provided port
#
# clear-port 3000

if [ -n "$1" ]; then
port_num="$(lsof -ti4TCP:"$1")"
if [ $? -eq 0 ]; then
kill "$port_num"
fi
else
echo >&2 Usage: clear-port port-number
exit 1
fi
3 changes: 3 additions & 0 deletions bin/git-ca
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

git commit --amend -v --date="$(date +%Y-%m-%dT%H:%M:%S)"
24 changes: 24 additions & 0 deletions bin/git-co-upstream-pr
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -e

pull_request_number=$1
local_branch_name=$2

if [ -z "$pull_request_number" -o -z "$local_branch_name" ]; then
echo "usage: git co-upstream-pr <pull_request_number> <local_branch_name>"
exit 1
fi

if git remote -v | grep -q upstream; then
git fetch upstream "pull/$pull_request_number/head:$local_branch_name"
git checkout "$local_branch_name"
else
cat <<HELP
You don't have an upstream remote set.
Use:
git remote add upstream {upstream_remote_url}
to set the reference and then try again.
HELP
fi
9 changes: 9 additions & 0 deletions bin/git-create-branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

set -e

git push origin "HEAD:refs/heads/$1"
git fetch origin
git branch --track "$1" "origin/$1"
cd .
git checkout "$1"
6 changes: 6 additions & 0 deletions bin/git-ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -e

[ -f .git/hooks/ctags ] || git init
.git/hooks/ctags
5 changes: 5 additions & 0 deletions bin/git-current-branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e

git rev-parse --abbrev-ref HEAD
6 changes: 6 additions & 0 deletions bin/git-delete-branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -e

git push origin :refs/heads/"$1"
git branch --delete "$1"
26 changes: 26 additions & 0 deletions bin/git-merge-branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

set -e

if git symbolic-ref --short refs/remotes/origin/HEAD >/dev/null; then
main_branch="$(git symbolic-ref --short refs/remotes/origin/HEAD | sed 's@^origin/@@')" "$@"
else
echo "You don't have a primary branch reference set for your origin remote.
Use:
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/{name_of_your_primary_branch}
to set the reference and then try merging again."

exit 1
fi

git fetch origin
line_count=$(git diff origin/$main_branch..$main_branch | wc -l)

if [ $line_count -gt 0 ]; then
printf "failed: $main_branch is not up to date with origin/$main_branch\n"
exit 1
fi

git checkout $main_branch
git merge "@{-1}"
8 changes: 8 additions & 0 deletions bin/git-rename-branch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -e

old=$(git current-branch)
git branch -m "$old" "$1"
git push origin --set-upstream "$1"
git push origin --delete "$old"
3 changes: 3 additions & 0 deletions bin/git-trust-bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

mkdir -p .git/safe
16 changes: 16 additions & 0 deletions bin/git-up
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -e

git fetch origin

if git symbolic-ref --short refs/remotes/origin/HEAD >/dev/null; then
git fetch origin
git rebase "$(git symbolic-ref --short refs/remotes/origin/HEAD)" "$@"
else
echo "You don't have a primary branch reference set for your origin remote.
Use:
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/{name_of_your_primary_branch}
to set the reference and then try rebasing again."
fi
22 changes: 22 additions & 0 deletions bin/replace
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
#
# Find and replace by a given list of files.
#
# replace foo bar **/*.rb

find_this="$1"
shift
replace_with="$1"
shift

if command -v rg &>/dev/null ; then
items=$(rg -l --color never "$find_this" "$@")
else
items=$(ag -l --nocolor "$find_this" "$@")
fi

temp="${TMPDIR:-/tmp}/replace_temp_file.$$"
IFS=$'\n'
for item in $items; do
sed "s/$find_this/$replace_with/g" "$item" > "$temp" && mv "$temp" "$item"
done
31 changes: 31 additions & 0 deletions bin/tat
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
#
# Attach or create tmux session named the same as current directory.

path_name="$(basename "$PWD" | tr . -)"
session_name=${1-$path_name}

not_in_tmux() {
[ -z "$TMUX" ]
}

session_exists() {
tmux has-session -t "=$session_name"
}

create_detached_session() {
(TMUX='' tmux new-session -Ad -s "$session_name")
}

create_if_needed_and_attach() {
if not_in_tmux; then
tmux new-session -As "$session_name"
else
if ! session_exists; then
create_detached_session
fi
tmux switch-client -t "$session_name"
fi
}

create_if_needed_and_attach
16 changes: 16 additions & 0 deletions bin/whats-in-port
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

# List process running on provided port
#
# whats-in-port 3000
#
# output:
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# ruby 25583 root 11u IPv4 0xee20607697a79bf7 0t0 TCP *:irdmi (LISTEN)

if [ -n "$1" ]; then
lsof -ni4TCP:"$1"
else
echo >&2 Usage: whats-in-port port-number
exit 1
fi
44 changes: 44 additions & 0 deletions config/alacritty/alacritty.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import = ['/home/borges/.config/alacritty/dracula/dracula.toml']

[font]
size = 13.0

[font.normal]
family = "MesloLGS NF"

[[keyboard.bindings]]
action = "ToggleFullscreen"
key = "Return"
mods = "Alt"

[[keyboard.bindings]]
chars = "\u001B[94;5u"
key = "Key6"
mods = "Control"

[[keyboard.bindings]]
chars = "\u001B[13;2u"
key = "Return"
mods = "Shift"

[[keyboard.bindings]]
chars = "\u001B[13;5u"
key = "Return"
mods = "Control"

# [shell]
# args = ["--cd ~/Projects/hs"]
# program = 'C:\Windows\System32\wsl.exe'

[window.dimensions]
columns = 205
lines = 55

[window.position]
x = 200
y = 50

# [window]
# decorations = 'none'
# padding.x = 0
# padding.y = 0
Loading

0 comments on commit e0a30eb

Please sign in to comment.