diff options
Diffstat (limited to 'git-prompt.sh')
-rwxr-xr-x | git-prompt.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/git-prompt.sh b/git-prompt.sh index 5a7591c..ccb16bd 100755 --- a/git-prompt.sh +++ b/git-prompt.sh @@ -54,6 +54,8 @@ max_file_list_length=${max_file_list_length:-100} upcase_hostname=${upcase_hostname:-on} + aj_max=20 + ##################################################################### post config @@ -587,6 +589,22 @@ enable_set_shell_label() { set_shell_label $BASH_COMMAND' DEBUG >& /dev/null } +# autojump (see http://wiki.github.com/joelthelion/autojump) +j (){ + : ${1? usage: j dir-beginning} + # go in ring buffer starting from current index. cd to first matching dir + for (( i=(aj_idx+1)%aj_max; i != aj_idx%aj_max; i=++i%aj_max )) ; do + #echo == ${aj_dir_list[$i]} == $i + if [[ ${aj_dir_list[$i]} =~ ^.*/$1[^/]*$ ]] ; then + cd "${aj_dir_list[$i]}" + return + fi + done + echo '?' +} + +alias jumpstart='echo ${aj_dir_list[@]}' + ###################################################################### PROMPT_COMMAND prompt_command_function() { @@ -603,6 +621,11 @@ prompt_command_function() { parse_vcs_status + # autojump + if [[ ${aj_dir_list[aj_idx%aj_max]} != $PWD ]] ; then + aj_dir_list[++aj_idx%aj_max]="$PWD" + fi + # if cwd_cmd have back-slash, then assign it value to cwd # else eval cwd_cmd, cwd should have path after exection eval "${cwd_cmd/\\/cwd=\\\\}" |