這是什麼?近距離投票?也許有人認爲這是無法完成的。 ;)
我呈現給你完整的解決方案(你可以找到最最新版本的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