Skip to content
This repository

Added plugin for auto completing the Android Debug Bridge (adb). #532

Closed
wants to merge 18 commits into from

2 participants

Frederik Mogensen Robby Russell
Frederik Mogensen

Auto completing for adb supporting the following commands:
bugreport -- return all information from the device that should be included in a bug report.
connect -- connect to a device via TCP/IP Port 5555 is default.
devices -- list all connected devices
disconnect -- disconnect from a TCP/IP device. Port 5555 is default.
emu -- run emulator console command
forward -- forward socket connections
help -- show the help message
install -- push this package file to the device and install it
jdwp -- list PIDs of processes hosting a JDWP transport
logcat -- View device log
pull -- copy file/dir from device
push -- copy file/dir to device
shell -- run remote shell interactively
sync -- copy host->device only if changed (-l means list but dont copy)
uninstall -- remove this app package from the device
version -- show version num

Robby Russell robbyrussell closed this March 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
39  plugins/adb/_adb
... ...
@@ -0,0 +1,39 @@
  1
+#compdef adb
  2
+#autoload
  3
+
  4
+# in order to make this work, you will need to have the android adb tools
  5
+
  6
+# adb zsh completion, based on homebrew completion
  7
+
  8
+local -a _1st_arguments
  9
+_1st_arguments=(
  10
+'bugreport:return all information from the device that should be included in a bug report.'
  11
+'connect:connect to a device via TCP/IP Port 5555 is default.'
  12
+'devices:list all connected devices'
  13
+'disconnect:disconnect from a TCP/IP device. Port 5555 is default.'
  14
+'emu:run emulator console command'
  15
+'forward:forward socket connections'
  16
+'help:show the help message'
  17
+'install:push this package file to the device and install it'
  18
+'jdwp:list PIDs of processes hosting a JDWP transport'
  19
+'logcat:View device log'
  20
+'pull:copy file/dir from device'
  21
+'push:copy file/dir to device'
  22
+'shell:run remote shell interactively'
  23
+'sync:copy host->device only if changed (-l means list but dont copy)'
  24
+'uninstall:remove this app package from the device'
  25
+'version:show version num'
  26
+)
  27
+
  28
+local expl
  29
+local -a pkgs installed_pkgs
  30
+
  31
+_arguments \
  32
+	'*:: :->subcmds' && return 0
  33
+
  34
+if (( CURRENT == 1 )); then
  35
+	_describe -t commands "adb subcommand" _1st_arguments
  36
+	return
  37
+fi
  38
+
  39
+_files
107  themes/mogensen.zsh-theme
... ...
@@ -0,0 +1,107 @@
  1
+# On a mac with snow leopard, for nicer terminal colours:
  2
+
  3
+# - Install SIMBL: http://www.culater.net/software/SIMBL/SIMBL.php
  4
+# - Download'Terminal-Colours': http://bwaht.net/code/TerminalColours.bundle.zip
  5
+# - Place that bundle in ~/Library/Application\ Support/SIMBL/Plugins (create that folder if it doesn't exist)
  6
+# - Open Terminal preferences. Go to Settings -> Text -> More
  7
+# - Change default colours to your liking.
  8
+# 
  9
+# Here are the colours from Textmate's Monokai theme:
  10
+# 
  11
+# Black: 0, 0, 0
  12
+# Red: 229, 34, 34
  13
+# Green: 166, 227, 45
  14
+# Yellow: 252, 149, 30
  15
+# Blue: 196, 141, 255
  16
+# Magenta: 250, 37, 115
  17
+# Cyan: 103, 217, 240
  18
+# White: 242, 242, 242
  19
+
  20
+# Thanks to Steve Losh: http://stevelosh.com/blog/2009/03/candy-colored-terminal/
  21
+
  22
+# The prompt
  23
+
  24
+PROMPT='%F{green}%2c%F{blue} $%f '
  25
+
  26
+# The right-hand prompt
  27
+
  28
+RPROMPT='${time} %{$fg[magenta]%}$(git_prompt_info)%{$reset_color%}$(git_prompt_status)%{$reset_color%}'
  29
+
  30
+# Add this at the start of RPROMPT to include rvm info showing ruby-version@gemset-name
  31
+# %{$fg[yellow]%}$(~/.rvm/bin/rvm-prompt)%{$reset_color%} 
  32
+
  33
+# local time, color coded by last return code
  34
+time_enabled="%(?.%{$fg[green]%}.%{$fg[red]%})%*%{$reset_color%}"
  35
+time_disabled="%{$fg[green]%}%*%{$reset_color%}"
  36
+time=$time_enabled
  37
+
  38
+ZSH_THEME_GIT_PROMPT_PREFIX=" ☁  %{$fg[red]%}"
  39
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
  40
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%} DIRTY" # Ⓓ
  41
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} UNTRACKED" # ⓣ
  42
+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} CLEAN" # Ⓞ
  43
+
  44
+ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[cyan]%} ADDED" # ⓐ ⑃
  45
+ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%} MODIFIED"  # ⓜ ⑁
  46
+ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} DELETED" # ⓧ ⑂
  47
+ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%} RENAMED" # ⓡ ⑄
  48
+ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[magenta]%} UNMERGED" # ⓤ ⑊
  49
+
  50
+# More symbols to choose from:
  51
+# ☀ ✹ ☄ ♆ ♀ ♁ ♐ ♇ ♈ ♉ ♚ ♛ ♜ ♝ ♞ ♟ ♠ ♣ ⚢ ⚲ ⚳ ⚴ ⚥ ⚤ ⚦ ⚒ ⚑ ⚐ ♺ ♻ ♼ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷
  52
+# ✡ ✔ ✖ ✚ ✱ ✤ ✦ ❤ ➜ ➟ ➼ ✂ ✎ ✐ ⨀ ⨁ ⨂ ⨍ ⨎ ⨏ ⨷ ⩚ ⩛ ⩡ ⩱ ⩲ ⩵  ⩶ ⨠ 
  53
+# ⬅ ⬆ ⬇ ⬈ ⬉ ⬊ ⬋ ⬒ ⬓ ⬔ ⬕ ⬖ ⬗ ⬘ ⬙ ⬟  ⬤ 〒 ǀ ǁ ǂ ĭ Ť Ŧ
  54
+
  55
+# Determine if we are using a gemset.
  56
+function rvm_gemset() {
  57
+    GEMSET=`rvm gemset list | grep '=>' | cut -b4-`
  58
+    if [[ -n $GEMSET ]]; then
  59
+        echo "%{$fg[yellow]%}$GEMSET%{$reset_color%}|"
  60
+    fi 
  61
+}
  62
+
  63
+# Determine the time since last commit. If branch is clean,
  64
+# use a neutral color, otherwise colors will vary according to time.
  65
+function git_time_since_commit() {
  66
+    if git rev-parse --git-dir > /dev/null 2>&1; then
  67
+        # Only proceed if there is actually a commit.
  68
+        if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
  69
+            # Get the last commit.
  70
+            last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
  71
+            now=`date +%s`
  72
+            seconds_since_last_commit=$((now-last_commit))
  73
+
  74
+            # Totals
  75
+            MINUTES=$((seconds_since_last_commit / 60))
  76
+            HOURS=$((seconds_since_last_commit/3600))
  77
+           
  78
+            # Sub-hours and sub-minutes
  79
+            DAYS=$((seconds_since_last_commit / 86400))
  80
+            SUB_HOURS=$((HOURS % 24))
  81
+            SUB_MINUTES=$((MINUTES % 60))
  82
+            
  83
+            if [[ -n $(git status -s 2> /dev/null) ]]; then
  84
+                if [ "$MINUTES" -gt 30 ]; then
  85
+                    COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
  86
+                elif [ "$MINUTES" -gt 10 ]; then
  87
+                    COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
  88
+                else
  89
+                    COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
  90
+                fi
  91
+            else
  92
+                COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
  93
+            fi
  94
+
  95
+            if [ "$HOURS" -gt 24 ]; then
  96
+                echo "($(rvm_gemset)$COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
  97
+            elif [ "$MINUTES" -gt 60 ]; then
  98
+                echo "($(rvm_gemset)$COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
  99
+            else
  100
+                echo "($(rvm_gemset)$COLOR${MINUTES}m%{$reset_color%}|"
  101
+            fi
  102
+        else
  103
+            COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
  104
+            echo "($(rvm_gemset)$COLOR~|"
  105
+        fi
  106
+    fi
  107
+}
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.