Commit graph

33 commits

Author SHA1 Message Date
Ian C. Anderson
005324f802 Use command -v instead of which
https://stackoverflow.com/questions/592620/how-to-check-if-a-program-exists-from-a-bash-script/677212#677212
2018-12-27 14:01:59 -05:00
Ian C. Anderson
b132c644be Use rg if it's present in bin/replace
I like this `bin/replace` script, but I've recently switched from `ag`
to [ripgrep](https://github.com/BurntSushi/ripgrep). This checks for the
presence of `rg` and uses it in `bin/replace`, passing the correct
parameter to disable colors.
2018-12-27 14:01:59 -05:00
Geoff Harcourt
ee30830241 Remove no-longer functional git-pr script
The Github `hub` utilty has added a `pr` subcommand, which takes
precedence over `git-pr` in execution order, so this script is no longer
accessible with `git pr` or `hub pr`.
2018-07-13 16:03:07 -04:00
Geoff Harcourt
0786549686 merge-branch: exit 1 if origin and local differ
This change prevents chained commands from continuing execution if the
`git merge` is operation would be unsuccessful such as a common
operation when a feature branch is ready to be merged and pushed:

```
git merge-branch && git push origin
```

If the origin/master and the local master have any difference, we return
status 1 and stop execution rather then emit a false success.

h/t: @croaky

Fix #563.
2017-12-18 22:51:13 -05:00
Derrick Carr
b860504752
Revert accidental merge from fork (#571)
This reverts two commits that were accidentally merged from a fork.
- commit c3180360ac
- commit ccb51c97c6
2017-11-17 16:36:59 -08:00
Derrick Carr
ccb51c97c6 Make tmux splits oen in working directory 2017-11-17 14:44:00 -08:00
Sean Doyle
384d4ad5e6 Add bin/git-trust-bin command
To [append a project's local `bin/` directory to `$PATH`][dotfiles],
the dotfiles check for the existence of a special directory: `git/.safe`.

This commit is inspired by [thoughtbot/suspenders#837][#837]:

> The idea behind the .git/safe is that I run it manually and explicitly
> after I trust the directoy and the team behind the project.

> Creating it as part of the setup script defeats the point of that. Doing
> so without explcitly telling the user comes across as sneaky, perhaps.
> (I do expect all devs to read setup scripts before running them -- but I
> also know that they do not!)

> Switch this script to inform the user that they have no `.git/safe`
> directory but might like to make one.

Since suspenders may no longer mark projects safe by default, this
commit introduces the `git trust-bin` command to do so.

[dotfiles]: af75a673b1/zsh/configs/post/path.zsh (L9-L10)
[#837]: https://github.com/thoughtbot/suspenders/pull/837
2017-08-25 09:28:16 -04:00
Dan Croak
8fbef47fda Remove git churn command
I added this four years ago but haven't been using it.
Not common enough to be included in company-wide dotfiles?
Can move to personal dotfiles if desired.
2017-04-25 22:19:45 -07:00
Blaine Schmeisser
1dc550d985 Overwrite internal field separator when replacing.
Problem:
Currently the `for` in bash will break up lists by whitespace, so if a
filename has a space in it the `for` will break it up incorrectly.

AG will separate the files with a newline character, so this temporarily
overwrites the `IFS` to be used correctly for this use case.

[Docs](https://bash.cyberciti.biz/guide/$IFS)
2016-04-15 10:36:33 -04:00
pedro-nonfree
2d9e8bf0e8 Update bin/replace script for better portability
The existing implementation of the `replace` script does not work on
GNU/Linux due to differences in the implementation of `sed`. This change
reworks the process of the replacement to create temporary files,
apply the changes to the files, and then move them into place. It will
improve the script's portability for more OSes.
2015-12-11 11:01:32 -05:00
Geoff Harcourt
21830dd035 Bring more shell syntax into shellcheck compliance
**Bring executables into better shellcheck compliance**

While evaluating linting and testing options for our shell
configuration, a run of Shellcheck against our executables turned up
some places where we could use more consistent syntax across our
executables, such as always using a shebang or quoting `$HOME` when we
build up a larger directory.

**Update syntax for zsh functions and completions**

A few changes found while linting zsh configs with shellcheck:

* thoughtbot's [style guide] [guide] calls for `$(..)` over backticks
  when capturing command output
* use `-gt` to test array length in arguments

[guide]: https://github.com/thoughtbot/guides/tree/master/best-practices
2015-10-30 12:50:02 -04:00
Geoff Harcourt
3b4de90ab4 Fix minor spelling error in command code comment 2015-10-21 08:19:17 -04:00
Mike Burns
24634ada70
Remove unused Easter egg
The `ranch` subcommand is annoying to skip and adds clutter to our
system, which only encourages people not to use our dotfiles as a base.
Remove it to get customizability back.
2015-10-09 13:17:54 +02:00
Joël Quenneville
dbb72cea5f Add custom git command git ranch
Sometimes when typing `git branch` I leave off the leading `b`, leading
to the boring message:

> git: 'ranch' is not a git command. See 'git --help'.

This adds a custom `git ranch` command with a friendlier funny message.
2015-10-09 11:53:36 +01:00
Timothy Fenney
74fd8a362e Add quotes for variables in replace 2015-07-28 21:20:01 -04:00
Blaine Schmeisser
f908cc9b8f Update amend to set the current date on the commit. 2015-07-12 13:16:26 -07:00
Grayson Wright
d68ba14669 Update tat script to accept optional session name
If no session name is provided,
it will generate one from the current directory.
2015-05-15 17:37:25 -07:00
Derek Prior
734c130822 Add "bundle search" subcommand
Bundler 1.8+ added support for git-style subcommands. Any scripts
starting with `bundler-` in your path are executable as bundler
subcommands.

This adds `search` as a subcommand that uses `ag` to search for a string
among all gems in your bundle (default) or optionally a specific gem.
I've found this useful for finding the source of puzzling deprecations,
finding what gem provides a method, and other various things.
2015-05-08 14:44:00 -07:00
Dan Croak
24b34d1bec Move Git aliases to subcommand scripts
Any executable script on you PATH
that is named `git-some-name`
will be available as a git subcommand,
which means you could do `git some-name` to run the script.

Git adds them to `git help -a` under the title
"git commands available from elsewhere on your $PATH",
which will then power the auto completion,
so that will also work for any command you add.

http://blog.zamith.pt/blog/2014/11/05/supercharging-your-git/

Examples of other projects that structure their dotfiles like this:

https://github.com/robbyrussell/oh-my-zsh
https://github.com/tj/git-extras
https://github.com/holman/dotfiles
2015-04-27 13:47:52 -07:00
Zachary Jones
44f678312d set --nocolor flag to make piping xargs safe 2015-02-23 14:39:06 -08:00
Chris Toomey
fa18537afd Update tat script to also work from within tmux
The existing script would fail if run from within tmux as the default
behavior would cause a nested tmux session which is bad. This update
detects if the current context is within tmux and properly handles this
by creating a detached session and switching to it as needed.

The idea with this is for tat to behave correctly regardless of context,
which I believe this update achieves. Existing users and workflows all
work identically, but now this adds support for a workflow that remains
within tmux at all times.

I prefer to remain within tmux all the time, rather than falling back to
the shell, navigating to another directory, and then creating the
session from there. With this update, I split a pane in the current tmux
window, navigate to the directory for the new session, and use `tat` to
open (or attach) to the new-session without ever leaving tmux.

I actually [have a binding that I use for this][], `C-b` (I am
"breaking" out a new session), that is mapped to `bind C-b send-keys
'tat && exit' 'C-m'`, which also cleans up the pane.

The reason for wanting this workflow is I am pretty strict about keeping
a tmux session focused to a single project (~ maps to a git repo). I
regularly want to reference another app and will use this workflow to
quickly open that project in a new session.

A "detached" session is one which has no clients attached. [From the man
page entry][] for `new-session`: `The new session is attached to the
current terminal unless -d is given.` This essentially creates it in the
background, preventing nesting. Then the script can attach the current
client using the `switch-client` command.

[have a binding that I use for this]: 01cc928672/tmux/tmux.conf (L89)
[From the man page entry]: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/tmux.1?query=tmux&sec=1
2014-12-09 13:06:49 -05:00
Ian C. Anderson
48873f79cb tat command now works in directories with periods
- Running `tat` in the robots.thoughtbot.com directory was throwing a
'bad session name' tmux error
- See http://sourceforge.net/p/tmux/tickets/109/
2014-07-22 20:58:15 -04:00
Dustan Kasten
7c4a093ef6 tat: create tmux session if nonexistent 2014-06-16 10:20:16 -07:00
Dan Croak
64e6dfa4c6 Isolate credits to README
Per @mikeburns' suggestion.
2013-06-18 16:47:01 -07:00
Dan Croak
cb6170d2f8 Extract dev/staging/prod binaries to parity gem
https://github.com/croaky/parity
2013-05-12 17:38:22 -07:00
Gabe Berke-Williams
1f4e6d1370 Use ag instead of ack
https://github.com/ggreer/the_silver_searcher

* ag is faster than ack
* ag searches all files by default (but still ignores gitignored files). This
  removes the need for ack's `--type-add=` options.
* The command is 33% shorter than ack!
2013-03-01 23:28:36 -05:00
Dan Croak
99c8831c94 Add replace script
Find and replace by a given list of files.
2013-02-28 10:24:36 -08:00
Joe Ferris
6603b694b0 Replace s shell script with rspec shell function and alias
* Use a regular alias to make `s` short for `rspec`
* Use an `rspec` shell function to route to zeus when appropriate
* Removes confusion from `s` working differently than `rspec`
* Removes need to use a special alias to get zeus working
2013-01-18 13:24:53 -05:00
Dan Croak
8649403044 Add Heroku scripts
staging:

    staging console
    staging migrate
    staging process
    staging open
    watch staging ps
    staging tail

production:

    production backup
    production console
    production migrate
    production open
    watch production ps
    production tail

load-backup-into:

    load-backup-into staging
    load-backup-into development

Notes on the last command:

* Copy latest production database backup into development database using
  preferred pgbackups + pg_restore method recommended by Heroku.
* Do not assume local development database name.
* Get local database name from config/database.yml.
* This did not previously exist in dotfiles.

Supporting change for these commands:

* Add ~/.bin to the PATH.

https://github.com/thoughtbot/dotfiles/pull/76
2013-01-12 18:06:12 -08:00
Dan Croak
df3dd5129b Attach to tmux session w/ current directory name
I've been experimenting with a workflow where I only run long-running
processes in tmux. Examples:

    zeus start
    foreman start
    rake

tmux (or screen) are good at that: maintaining a long-running process
across shell sessions.

Instead of opening another tmux pane for vim and another for git
commands, Rails generators, test runs, etc., I do all of that outside of
tmux in my normal shell window. Those are all targeted, quick, actions.
They are what I am doing *right now*. It's my workspace.

While experimenting with this process, I noticed, I do jump into tmux
more often. Therefore, I wanted a shorter command for attaching to the
tmux session with the same name as the current directory.
2013-01-08 16:45:28 -08:00
Greg Lazarev
9de82eb791 Pass all parameters to the executable 2012-12-03 09:07:14 -08:00
Dan Croak
80b77cdefc Run specs directly from vim
* Run current spec file.
* Run spec nearest cursor.
* Run last spec that was run.
* Convert s alias to s script, use Zeus if present.
2012-11-19 09:04:34 -08:00
Dan Croak
d8adb07377 Add git-churn script
After you commit a bug fix to a feature branch, find out if the code
you changed to fix the bug is in files that change often:

    git-churn

If the buggy code changes often, find smells and refactor them. Separate
the parts that change often from the parts that don't.

Conversely, avoid refactoring areas with low churn. Refactoring changes
code, and with each change, you risk introducing new bugs.

Example:

     [feature-branch][~/dev/rails-app] churn
     2 app/controllers/accepts_controller.rb
     2 config/database.yml
     4 app/helpers/application_helper.rb
     4 config/application.rb
     9 spec/models/user_spec.rb
     9 spec/spec_helper.rb
    12 spec/requests/dashboard_spec.rb
    13 spec/models/feedback_spec.rb
    19 app/models/feedback.rb
    21 app/models/user.rb
2012-11-15 22:46:10 -08:00