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
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!
* 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
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
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.
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