From 9d76784b3ed85115e1830d48d91b3a08236a6538 Mon Sep 17 00:00:00 2001 From: Simon Frost Date: Tue, 15 Jul 2014 14:22:24 +0100 Subject: Add support for jira-prefix configuration file --- plugins/jira/jira.plugin.zsh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'plugins/jira') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 739ee7142..3d510e430 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -29,15 +29,23 @@ open_jira_issue () { return 0 fi + if [ -f .jira-prefix ]; then + jira_prefix=$(cat .jira-prefix) + elif [ -f ~/.jira-prefix ]; then + jira_prefix=$(cat ~/.jira-prefix) + else + jira_prefix="" + fi + if [ -z "$1" ]; then echo "Opening new issue" $open_cmd "$jira_url/secure/CreateIssue!default.jspa" else echo "Opening issue #$1" if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then - $open_cmd "$jira_url/issues/$1" + $open_cmd "$jira_url/issues/$jira_prefix$1" else - $open_cmd "$jira_url/browse/$1" + $open_cmd "$jira_url/browse/$jira_prefix$1" fi fi } -- cgit v1.2.3-70-g09d2 From 63bae2aba9c43a70bbb374fc46e287d7bc46cc54 Mon Sep 17 00:00:00 2001 From: Christian Höltje Date: Wed, 23 Apr 2014 10:13:26 -0400 Subject: Use $OSTYPE instead of uname to speed things up The $OSTYPE variable is set at ZSH compile time and can be safely used to determine the OS of the system. e.g. darwin (os x) --- plugins/battery/battery.plugin.zsh | 2 +- plugins/bundler/bundler.plugin.zsh | 2 +- plugins/jira/jira.plugin.zsh | 2 +- plugins/node/node.plugin.zsh | 2 +- plugins/rake-fast/rake-fast.plugin.zsh | 2 +- plugins/sublime/sublime.plugin.zsh | 2 +- plugins/web-search/web-search.plugin.zsh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins/jira') diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 32dd4b624..014bb15dd 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -8,7 +8,7 @@ # Modified to add support for Apple Mac # ########################################### -if [[ $(uname) == "Darwin" ]] ; then +if [[ "$OSTYPE" = darwin* ]] ; then function battery_pct() { local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 617dcde71..ba3d3f623 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -54,7 +54,7 @@ bundle_install() { if _bundler-installed && _within-bundled-project; then local bundler_version=`bundle version | cut -d' ' -f3` if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then - if [[ "$(uname)" == 'Darwin' ]] + if [[ "$OSTYPE" = darwin* ]] then local cores_num="$(sysctl hw.ncpu | awk '{print $2}')" else diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 3d510e430..e4881151e 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -12,7 +12,7 @@ # jira ABC-123 # Opens an existing issue open_jira_issue () { local open_cmd - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then open_cmd='open' else open_cmd='xdg-open' diff --git a/plugins/node/node.plugin.zsh b/plugins/node/node.plugin.zsh index 2d78f2b4c..39d8b10d9 100644 --- a/plugins/node/node.plugin.zsh +++ b/plugins/node/node.plugin.zsh @@ -3,7 +3,7 @@ function node-docs { # get the open command local open_cmd - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then open_cmd='open' else open_cmd='xdg-open' diff --git a/plugins/rake-fast/rake-fast.plugin.zsh b/plugins/rake-fast/rake-fast.plugin.zsh index cb84f69a1..cfc9a079f 100644 --- a/plugins/rake-fast/rake-fast.plugin.zsh +++ b/plugins/rake-fast/rake-fast.plugin.zsh @@ -10,7 +10,7 @@ _rake_refresh () { _rake_does_task_list_need_generating () { if [ ! -f .rake_tasks ]; then return 0; else - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then accurate=$(stat -f%m .rake_tasks) changed=$(stat -f%m Rakefile) else diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh index 438f386fb..5acc75cc7 100644 --- a/plugins/sublime/sublime.plugin.zsh +++ b/plugins/sublime/sublime.plugin.zsh @@ -17,7 +17,7 @@ if [[ $('uname') == 'Linux' ]]; then fi done -elif [[ $('uname') == 'Darwin' ]]; then +elif [[ "$OSTYPE" = darwin* ]]; then local _sublime_darwin_paths > /dev/null 2>&1 _sublime_darwin_paths=( "/usr/local/bin/subl" diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 8eedb90ee..f056e38e8 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -4,7 +4,7 @@ function web_search() { # get the open command local open_cmd - if [[ $(uname -s) == 'Darwin' ]]; then + if [[ "$OSTYPE" = darwin* ]]; then open_cmd='open' else open_cmd='xdg-open' -- cgit v1.2.3-70-g09d2 From df1b0b328983dba57b4cea123b5a05c24493ae8f Mon Sep 17 00:00:00 2001 From: Tom Cammann Date: Tue, 19 Aug 2014 15:42:39 +0100 Subject: Update jira plugin to allow lookup of issues Plugin now supports lookup of tickets by assignee and reporter --- plugins/jira/jira.plugin.zsh | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'plugins/jira') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 3d510e430..a6d08410f 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -26,7 +26,7 @@ open_jira_issue () { jira_url=$JIRA_URL else echo "JIRA url is not specified anywhere." - return 0 + return 1 fi if [ -f .jira-prefix ]; then @@ -39,7 +39,9 @@ open_jira_issue () { if [ -z "$1" ]; then echo "Opening new issue" - $open_cmd "$jira_url/secure/CreateIssue!default.jspa" + $open_cmd "${jira_url}/secure/CreateIssue!default.jspa" + elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then + jira_query $@ else echo "Opening issue #$1" if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then @@ -50,4 +52,39 @@ open_jira_issue () { fi } +jira_name () { + if [[ -z "$1" ]]; then + if [[ "x${JIRA_NAME}" != "x" ]]; then + jira_name=${JIRA_NAME} + else + echo "JIRA_NAME not specified" + return 1 + fi + else + jira_name=$@ + fi +} + +jira_query () { + verb="$1" + if [[ "${verb}" = "reported" ]]; then + lookup=reporter + preposition=by + elif [[ "${verb}" = "assigned" ]]; then + lookup=assignee + preposition=to + else + echo "not a valid lookup $verb" + return 1 + fi + shift 1 + jira_name $@ + if [[ $? = 1 ]]; then + return 1 + fi + echo "Browsing issues ${verb} ${preposition} ${jira_name}" + $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" +} + alias jira='open_jira_issue' + -- cgit v1.2.3-70-g09d2 From 8652fd64efe7bcf950494856fd10ef1f5627a9ea Mon Sep 17 00:00:00 2001 From: David Hartmann Date: Sun, 22 Jun 2014 03:10:53 +0200 Subject: added comment functionality added commenting functionality by appending 'm' after the issue key (regular JIRA shortcut) --- plugins/jira/jira.plugin.zsh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'plugins/jira') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 4a36b882d..8ad60b8fe 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -49,6 +49,20 @@ open_jira_issue () { else $open_cmd "$jira_url/browse/$jira_prefix$1" fi + else + local addcomment='' + if [[ "$2" == "m" ]]; then + addcomment="#add-comment" + echo "Add comment to issue #$1" + else + echo "Opening issue #$1" + fi + + if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then + $open_cmd "$jira_url/issues/$1$addcomment" + else + $open_cmd "$jira_url/browse/$1$addcomment" + fi fi } -- cgit v1.2.3-70-g09d2 From d0670aa2bd5186357961dd90c4a97c2c3842f728 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Mon, 15 Jun 2015 16:55:25 -0400 Subject: Fix merge conflict for jira-prefix and jira add comment --- plugins/jira/jira.plugin.zsh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'plugins/jira') diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 8ad60b8fe..ca540c84c 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -42,13 +42,6 @@ open_jira_issue () { $open_cmd "${jira_url}/secure/CreateIssue!default.jspa" elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then jira_query $@ - else - echo "Opening issue #$1" - if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then - $open_cmd "$jira_url/issues/$jira_prefix$1" - else - $open_cmd "$jira_url/browse/$jira_prefix$1" - fi else local addcomment='' if [[ "$2" == "m" ]]; then @@ -59,9 +52,9 @@ open_jira_issue () { fi if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then - $open_cmd "$jira_url/issues/$1$addcomment" + $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" else - $open_cmd "$jira_url/browse/$1$addcomment" + $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" fi fi } -- cgit v1.2.3-70-g09d2 From d1d06b5675bebbe54f3d876eb993b6e89d8963c7 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 5 Aug 2015 00:32:57 +0200 Subject: Use standard open command in current plugins Substitutes the current duplicate logic for the standard and cross-platform function open_command in plugins: frontend-search, jira, node, web-search --- plugins/frontend-search/frontend-search.plugin.zsh | 10 +--------- plugins/jira/jira.plugin.zsh | 15 ++++----------- plugins/node/node.plugin.zsh | 10 +--------- plugins/web-search/web-search.plugin.zsh | 12 +----------- 4 files changed, 7 insertions(+), 40 deletions(-) (limited to 'plugins/jira') diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index b9fb8634c..f7485621b 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -2,14 +2,6 @@ function frontend() { - # get the open command - local open_cmd - if [[ $(uname -s) == 'Darwin' ]]; then - open_cmd='open' - else - open_cmd='xdg-open' - fi - # no keyword provided, simply show how call methods if [[ $# -le 1 ]]; then echo "Please provide a search-content and a search-term for app.\nEx:\nfrontend \n" @@ -113,7 +105,7 @@ function frontend() { echo "$url" - $open_cmd "$url" + open_command "$url" } diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index ca540c84c..9a8932702 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -11,13 +11,6 @@ # Usage: jira # opens a new issue # jira ABC-123 # Opens an existing issue open_jira_issue () { - local open_cmd - if [[ "$OSTYPE" = darwin* ]]; then - open_cmd='open' - else - open_cmd='xdg-open' - fi - if [ -f .jira-url ]; then jira_url=$(cat .jira-url) elif [ -f ~/.jira-url ]; then @@ -39,7 +32,7 @@ open_jira_issue () { if [ -z "$1" ]; then echo "Opening new issue" - $open_cmd "${jira_url}/secure/CreateIssue!default.jspa" + open_command "${jira_url}/secure/CreateIssue!default.jspa" elif [[ "$1" = "assigned" || "$1" = "reported" ]]; then jira_query $@ else @@ -52,9 +45,9 @@ open_jira_issue () { fi if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then - $open_cmd "$jira_url/issues/$jira_prefix$1$addcomment" + open_command "$jira_url/issues/$jira_prefix$1$addcomment" else - $open_cmd "$jira_url/browse/$jira_prefix$1$addcomment" + open_command "$jira_url/browse/$jira_prefix$1$addcomment" fi fi } @@ -90,7 +83,7 @@ jira_query () { return 1 fi echo "Browsing issues ${verb} ${preposition} ${jira_name}" - $open_cmd "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" + open_command "${jira_url}/secure/IssueNavigator.jspa?reset=true&jqlQuery=${lookup}+%3D+%22${jira_name}%22+AND+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC" } alias jira='open_jira_issue' diff --git a/plugins/node/node.plugin.zsh b/plugins/node/node.plugin.zsh index 39d8b10d9..2463815ac 100644 --- a/plugins/node/node.plugin.zsh +++ b/plugins/node/node.plugin.zsh @@ -1,13 +1,5 @@ # Open the node api for your current version to the optional section. # TODO: Make the section part easier to use. function node-docs { - # get the open command - local open_cmd - if [[ "$OSTYPE" = darwin* ]]; then - open_cmd='open' - else - open_cmd='xdg-open' - fi - - $open_cmd "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1" + open_command "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1" } diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index d407edb96..7c3ad9046 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -14,16 +14,6 @@ function web_search() { github "https://github.com/search?q=" ) - # define the open command - case "$OSTYPE" in - darwin*) open_cmd="open" ;; - cygwin*) open_cmd="cygstart" ;; - linux*) open_cmd="xdg-open" ;; - *) echo "Platform $OSTYPE not supported" - return 1 - ;; - esac - # check whether the search engine is supported if [[ -z "$urls[$1]" ]]; then echo "Search engine $1 not supported." @@ -41,7 +31,7 @@ function web_search() { url="${(j://:)${(s:/:)urls[$1]}[1,2]}" fi - nohup $open_cmd "$url" &>/dev/null + open_command "$url" } -- cgit v1.2.3-70-g09d2