这是什么?近距离投票?也许有人认为这是无法完成的。 ;)
我呈现给你完整的解决方案(你可以找到最最新版本的github):
〜/ UTIL /混帐的Diff-木偶:
#!/bin/sh
# This script runs git diff through tmux at the current directory, so that you can
# interactively scroll it. Listens for changes to the filesystem at this directory
# and tmux is used to issue commands to reload the diff.
set -e
[[ -f .tmp_git_diff ]] && echo "found .tmp_git_diff, exiting" && exit -1
# save the current git diff string to use for comparison
git diff > .tmp_git_diff
function cleanup {
kill $FSWATCHPID
rm .tmp_git_diff
tmux kill-session -t git-diff-puppet
}
trap cleanup EXIT
tmux new-session -d -s git-diff-puppet sh
tmux send-keys -t git-diff-puppet "git diff" enter
fswatch . ~/util/git-diff-puppet-onchange &
FSWATCHPID=$!
tmux attach -t git-diff-puppet
echo "tmux finished: puppet script exiting"
〜/ util/git-diff-puppet-onchange:
#!/bin/sh
# This script is not for invoking directly. It is for use in conjunction (as a "callback") with
# git-diff-puppet: this script will be looking for the .tmp_git_diff file
set -e
[[ ! -f .tmp_git_diff ]] && echo ".tmp_git_diff not found; i was probably invoked in error, aborting" && exit 1
# diffing the current diff with the saved diff to see if we should re-show the git diff in tmux
if ! git diff | diff - .tmp_git_diff > /dev/null; then
tmux send-keys -t git-diff-puppet q "git diff" enter
git diff > .tmp_git_diff
fi
这是光荣的。瞬间更新感谢the super fast fswatch
program。
什么也不错,是我帐户fswatch
虚假开火(它不幸的是)。如果我的git diff
未更改,则不会通过tmux执行重新运行,因此将保留滚动偏移量。
只是想说至少有一个开发人员(这个!)仍然对这个程序化解决方案的信息感兴趣(不需要'tmux'包装器)。 – ELLIOTTCABLE 2014-10-04 08:32:12
包装并没有真正的工作。呃,实际上,也许它确实有效。尽管如此,它只是可怕的,所以我永远不会使用它。现在好消息是,iTerm2最近获得了这项功能。你可以在自己的任期窗口滚动一整天!然而,它仍然不能在tmux内部工作,所以这很吸引人。 – 2014-10-04 09:19:24