From 96e26be5e493e9b9e63c812b9fa188fe928164f7 Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Thu, 10 May 2012 08:06:44 -0500 Subject: [PATCH] j, ipcc, ipcd: support gitk and gitka verbs, to spawn gitk on a git repo --- ipcc | 27 +++++++++++++++++++++++++-- ipcd | 18 ++++++++++++++++++ j | 2 ++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/ipcc b/ipcc index 26dc844..342ff28 100755 --- a/ipcc +++ b/ipcc @@ -17,8 +17,7 @@ pebkac() { do_editor() { while [ "${1}" ] do - arg="${1}" - arg="$(readlink -f "${arg}")" + arg="$(readlink -f "${1}")" echo "editor ${arg}" > "${jipc}" shift done @@ -34,10 +33,32 @@ do_browser() { done } +do_gitk() { + [ "${*}" ] || set -- "$(pwd)" + while [ "${1}" ] + do + arg="$(readlink -f "${1}")" + echo "gitk ${arg}" > "${jipc}" + shift + done +} + +do_gitka() { + [ "${*}" ] || set -- "$(pwd)" + while [ "${1}" ] + do + arg="$(readlink -f "${1}")" + echo "gitka ${arg}" > "${jipc}" + shift + done +} + case "$(basename "${0}")" in ipcc) cmd="${1}"; shift ;; ee) cmd="editor" ;; ff) cmd="browser" ;; +gitk) cmd="gitk" ;; +gitka)cmd="gitka" ;; *) pebkac ;; esac arg="${1}" @@ -45,5 +66,7 @@ arg="${1}" case "${cmd}" in editor|edit|ee) do_editor "${@}" ;; browser|browse|ff) do_browser "${@}" ;; +gitk) do_gitk "${@}" ;; +gitka) do_gitka "${@}" ;; *) pebkac ;; esac diff --git a/ipcd b/ipcd index 05e03e5..05f73e4 100755 --- a/ipcd +++ b/ipcd @@ -42,6 +42,22 @@ do_browser() { [ "${arg}" ] && ( "${browser}" "${arg}" || zenity --error --text="Error launching browser:\n${browser} ${arg}" ) & } +do_gitk() { + arg="$(resolve_path "${1}")" + ( + [ -d "${arg}/.git" -o -f "${arg}/config" ] && ( cd "${arg}"; gitk ) || \ + zenity --error --text="Not a git repository:\n${arg}" + ) & +} + +do_gitka() { + arg="$(resolve_path "${1}")" + ( + [ -d "${arg}/.git" -o -f "${arg}/config" ] && ( cd "${arg}"; gitk --all ) || \ + zenity --error --text="Not a git repository:\n${arg}" + ) & +} + do_error() { cmd="${1}" arg="${2}" @@ -59,6 +75,8 @@ do exit|die|kill) kill $$; exit 0 ;; editor) do_editor "${arg}" ;; browser) do_browser "${arg}" ;; + gitk) do_gitk "${arg}" ;; + gitka) do_gitka "${arg}" ;; *) do_error "${cmd}" "${arg}" ;; esac sleep 0.25 diff --git a/j b/j index 47c1c3d..dc5d597 100755 --- a/j +++ b/j @@ -157,6 +157,8 @@ j_ipc_setup() { ( cd "${jroot}/bin" [ -e ee ] || ln -s ipcc ee [ -e ff ] || ln -s ipcc ff + [ -e gitk ] || ln -s ipcc gitk + [ -e gitka ] || ln -s ipcc gitka ) } -- 2.44.0