diff options
| author | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-21 12:36:09 -0600 | 
|---|---|---|
| committer | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-21 12:36:09 -0600 | 
| commit | e3a28817b0a7ee5724884d9c132763af4a64182c (patch) | |
| tree | 094a2e25f2efa94a922750b76643dacba7ace598 | |
| parent | 2d833d0b20726f58e8776a7158aaa7eca05d5ee9 (diff) | |
| parent | 973c92cd91d595fde37a4dbd5a6389072654252f (diff) | |
| download | zsh-e3a28817b0a7ee5724884d9c132763af4a64182c.tar.gz zsh-e3a28817b0a7ee5724884d9c132763af4a64182c.tar.bz2 zsh-e3a28817b0a7ee5724884d9c132763af4a64182c.zip  | |
merge agnoster theme
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | plugins/brew-cask/brew-cask.plugin.zsh | 84 | ||||
| -rw-r--r-- | plugins/brew/_brew | 174 | ||||
| -rw-r--r-- | plugins/docker/_docker | 13 | ||||
| -rw-r--r-- | plugins/git/git.plugin.zsh | 1 | ||||
| -rw-r--r-- | plugins/npm/npm.plugin.zsh | 6 | ||||
| -rw-r--r-- | plugins/osx/README.md | 1 | ||||
| -rw-r--r-- | plugins/osx/osx.plugin.zsh | 264 | ||||
| -rw-r--r-- | plugins/perms/perms.plugin.zsh | 12 | ||||
| -rw-r--r-- | plugins/rails/rails.plugin.zsh | 1 | ||||
| -rw-r--r-- | plugins/ssh-agent/ssh-agent.plugin.zsh | 2 | ||||
| -rw-r--r-- | plugins/xcode/README.md | 2 | ||||
| -rw-r--r-- | plugins/xcode/xcode.plugin.zsh | 13 | ||||
| -rw-r--r-- | themes/agnoster.zsh-theme | 22 | ||||
| -rw-r--r-- | themes/peepcode.zsh-theme | 8 | 
15 files changed, 329 insertions, 280 deletions
@@ -211,3 +211,9 @@ We have [stickers](http://shop.planetargon.com/products/ohmyzsh-stickers-set-of-  ## License  Oh My Zsh is released under the [MIT license](LICENSE.txt). + +## About Planet Argon + + + +Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](https://www.planetargon.com/skills/ruby-on-rails-development?utm_source=github). diff --git a/plugins/brew-cask/brew-cask.plugin.zsh b/plugins/brew-cask/brew-cask.plugin.zsh deleted file mode 100644 index 91ce0f498..000000000 --- a/plugins/brew-cask/brew-cask.plugin.zsh +++ /dev/null @@ -1,84 +0,0 @@ -# Autocompletion for homebrew-cask. -# -# This script intercepts calls to the brew plugin and adds autocompletion -# for the cask subcommand. -# -# Author: https://github.com/pstadler - -compdef _brew-cask brew - -_brew-cask() -{ -  local curcontext="$curcontext" state line -  typeset -A opt_args - -  _arguments -C \ -    ':command:->command' \ -    ':subcmd:->subcmd' \ -    '*::options:->options' - -  case $state in -    (command) -      __call_original_brew -      cask_commands=( -        'cask:manage casks' -      ) -      _describe -t commands 'brew cask command' cask_commands ;; - -    (subcmd) -      case "$line[1]" in -        cask) -          if (( CURRENT == 3 )); then -            local -a subcommands -            subcommands=( -              "alfred:used to modify Alfred's scope to include the Caskroom" -              'audit:verifies installability of casks' -              'checklinks:checks for bad cask links' -              'cleanup:cleans up cached downloads' -              'create:creates a cask of the given name and opens it in an editor' -              'doctor:checks for configuration issues' -              'edit:edits the cask of the given name' -              'fetch:downloads Cask resources to local cache' -              'home:opens the homepage of the cask of the given name' -              'info:displays information about the cask of the given name' -              'install:installs the cask of the given name' -              'list:with no args, lists installed casks; given installed casks, lists installed files' -              'search:searches all known casks' -              'uninstall:uninstalls the cask of the given name' -              "update:a synonym for 'brew update'" -            ) -            _describe -t commands "brew cask subcommand" subcommands -          fi ;; - -        *) -          __call_original_brew ;; -      esac ;; - -    (options) -      local -a casks installed_casks -      local expl -      case "$line[2]" in -        list|uninstall) -          __brew_installed_casks -          _wanted installed_casks expl 'installed casks' compadd -a installed_casks ;; -        audit|edit|home|info|install) -          __brew_all_casks -          _wanted casks expl 'all casks' compadd -a casks ;; -      esac ;; -  esac -} - -__brew_all_casks() { -  casks=(`brew cask search`) -} - -__brew_installed_casks() { -  installed_casks=(`brew cask list`) -} - -__call_original_brew() -{ -  local ret=1 -  _call_function ret _brew -  compdef _brew-cask brew -} diff --git a/plugins/brew/_brew b/plugins/brew/_brew deleted file mode 100644 index 19cfb22cb..000000000 --- a/plugins/brew/_brew +++ /dev/null @@ -1,174 +0,0 @@ -#compdef brew -#autoload - -# imported from https://github.com/Homebrew/homebrew/blob/29f73d2212c2b202fe25f69dcbf440d8391fa4c9/Library/Contributions/brew_zsh_completion.zsh - -# Brew ZSH completion function -# Drop this somewhere in your $fpath (like /usr/share/zsh/site-functions) -# and rename it _brew -# -# altered from _fink - -_brew_all_formulae() { -  formulae=(`brew search`) -} - -_brew_installed_formulae() { -  installed_formulae=(`brew list`) -} - -_brew_installed_taps() { -  installed_taps=(`brew tap`) -} - -_brew_official_taps() { -  official_taps=(`brew tap --list-official`) -} - -_brew_pinned_taps() { -  pinned_taps=(`brew tap --list-pinned`) -} - -_brew_outdated_formulae() { -  outdated_formulae=(`brew outdated`) -} - -_brew_installed_services() { -  installed_services=(`brew services list | awk '{print $1}' | tail -n+2`) -} - -local -a _1st_arguments -_1st_arguments=( -  'audit:check formulae for Homebrew coding style' -  'cat:display formula file for a formula' -  'cleanup:uninstall unused and old versions of packages' -  'commands:show a list of commands' -  'config:show homebrew and system configuration' -  'create:create a new formula' -  'deps:list dependencies and dependants of a formula' -  'desc:display a description of a formula' -  'doctor:audits your installation for common issues' -  'edit:edit a formula' -  'fetch:download formula resources to the cache' -  'gist-logs:generate a gist of the full build logs' -  'home:visit the homepage of a formula or the brew project' -  'info:information about a formula' -  'install:install a formula' -  'reinstall:install a formula anew; re-using its current options' -  'leaves:show installed formulae that are not dependencies of another installed formula' -  'link:link a formula' -  'linkapps:symlink .app bundles provided by formulae into /Applications' -  'list:list files in a formula or not-installed formulae' -  'log:git commit log for a formula' -  'missing:check all installed formuale for missing dependencies.' -  'migrate:migrate renamed formula to new name' -  'outdated:list formulae for which a newer version is available' -  'pin:pin specified formulae' -  'postinstall:perform post_install for a given formula' -  'prune:remove dead links' -  'remove:remove a formula' -  'search:search for a formula (/regex/ or string)' -  'services:manage services' -  'switch:switch between different versions of a formula' -  'tap:tap a new formula repository from GitHub, or list existing taps' -  'tap-info:information about a tap' -  'tap-pin:pin a tap' -  'tap-unpin:unpin a tap' -  'test-bot:test a formula and build a bottle' -  'uninstall:uninstall a formula' -  'unlink:unlink a formula' -  'unlinkapps:remove symlinked .app bundles provided by formulae from /Applications' -  'unpin:unpin specified formulae' -  'untap:remove a tapped repository' -  'update:fetch latest version of Homebrew and all formulae' -  'upgrade:upgrade outdated formulae' -  'uses:show formulae which depend on a formula' -  `brew commands --quiet --include-aliases` -) - -local expl -local -a formulae installed_formulae installed_taps official_taps outdated_formulae installed_services - -_arguments \ -  '(-v)-v[verbose]' \ -  '(--cellar)--cellar[brew cellar]' \ -  '(--env)--env[brew environment]' \ -  '(--repository)--repository[brew repository]' \ -  '(--version)--version[version information]' \ -  '(--prefix)--prefix[where brew lives on this system]' \ -  '(--cache)--cache[brew cache]' \ -  '*:: :->subcmds' && return 0 - -if (( CURRENT == 1 )); then -  _describe -t commands "brew subcommand" _1st_arguments -  return -fi - -case "$words[1]" in -  install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|desc|edit|options|switch) -    _brew_all_formulae -    _wanted formulae expl 'all formulae' compadd -a formulae ;; -  linkapps|unlinkapps) -    _arguments \ -      '(--local)--local[operate on ~/Applications instead of /Applications]' \ -      '1: :->forms' && return 0 - -    if [[ "$state" == forms ]]; then -      _brew_installed_formulae -      _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae -    fi ;; -  list|ls) -    _arguments \ -      '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ -      '(--pinned)--pinned[list all versions of pinned formulae]' \ -      '(--versions)--versions[list all installed versions of a formula]' \ -      '1: :->forms' && return 0 - -      if [[ "$state" == forms ]]; then -        _brew_installed_formulae -        _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae -      fi ;; -  remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin) -    _brew_installed_formulae -    _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; -  search|-S) -    _arguments \ -      '(--macports)--macports[search the macports repository]' \ -      '(--fink)--fink[search the fink repository]' ;; -  untap|tap-info|tap-pin) -    _brew_installed_taps -    _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;; -  tap) -    _brew_official_taps -    _wanted official_taps expl 'official taps' compadd -a official_taps ;; -  tap-unpin) -    _brew_pinned_taps -    _wanted pinned_taps expl 'pinned taps' compadd -a pinned_taps ;; -  upgrade) -    _brew_outdated_formulae -    _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;; -  services) -     _arguments -C \ -      '1: :->command' \ -      '2: :->service' && return 0 - -    local -a commands - -    commands=( -      'cleanup:Get rid of stale services and unused plists' -      'list:List all services managed by brew services' -      'restart:Gracefully restart selected service' -      'start:Start selected service' -      'stop:Stop selected service' -    ) - -    case $state in -      command) -        _describe -t commands 'Action' commands -        ;; -      service) -        _brew_installed_services -       _describe -t subcommands 'Services' installed_services -       ;; -    esac -esac diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 66dfeea9e..1366fd61b 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -228,7 +228,7 @@ __docker_get_log_options() {      journald_options=("env" "labels" "tag")      json_file_options=("env" "labels" "max-file" "max-size")      syslog_options=("env" "labels" "syslog-address" "syslog-facility" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "tag") -    splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-format" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag") +    splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-format" "splunk-gzip" "splunk-gzip-level" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag")      [[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0      [[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0 @@ -434,7 +434,7 @@ __docker_complete_events_filter() {              (event)                  local -a event_opts                  event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach' -                'exec_start' 'export' 'import' 'kill' 'load'  'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start' +                'exec_start' 'export' 'health_status' 'import' 'kill' 'load'  'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start'                  'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update')                  _describe -t event-filter-opts "event filter options" event_opts && ret=0                  ;; @@ -792,7 +792,7 @@ __docker_node_commands() {          "ls:List nodes in the swarm"          "promote:Promote a node as manager in the swarm"          "rm:Remove one or more nodes from the swarm" -        "ps:List tasks running on a node" +        "ps:List tasks running on a node, defaults to current node"          "update:Update a node"      )      _describe -t docker-node-commands "docker node command" _docker_node_subcommands @@ -1083,6 +1083,7 @@ __docker_service_subcommand() {          "($help)*--constraint=[Placement constraints]:constraint: "          "($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)"          "($help)*"{-e=,--env=}"[Set environment variables]:env: " +        "($help)*--group-add=[Add additional user groups to the container]:group:_groups"          "($help)*--label=[Service labels]:label: "          "($help)--limit-cpu=[Limit CPUs]:value: "          "($help)--limit-memory=[Limit Memory]:value: " @@ -1177,6 +1178,7 @@ __docker_service_subcommand() {                  "($help)--arg=[Service command args]:arguments: _normal" \                  "($help)*--container-label-add=[Add or update container labels]:label: " \                  "($help)*--container-label-rm=[Remove a container label by its key]:label: " \ +                "($help)*--group-rm=[Remove previously added user groups from the container]:group:_groups" \                  "($help)--image=[Service image tag]:image:__docker_repositories" \                  "($help -)1:service:__docker_complete_services" && ret=0              ;; @@ -1658,7 +1660,8 @@ __docker_subcommand() {                  $opts_help \                  "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \                  "($help)--since=[Events created since this timestamp]:timestamp: " \ -                "($help)--until=[Events created until this timestamp]:timestamp: " && ret=0 +                "($help)--until=[Events created until this timestamp]:timestamp: " \ +                "($help)--format=[Format the output using the given go template]:template: " && ret=0              ;;          (exec)              local state @@ -1701,7 +1704,7 @@ __docker_subcommand() {                  "($help -a --all)"{-a,--all}"[Show all images]" \                  "($help)--digests[Show digests]" \                  "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \ -                "($help)--format[Pretty-print containers using a Go template]:template: " \ +                "($help)--format[Pretty-print images using a Go template]:template: " \                  "($help)--no-trunc[Do not truncate output]" \                  "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \                  "($help -): :__docker_repositories" && ret=0 diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 6197c234b..25da03509 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -46,6 +46,7 @@ alias gapa='git add --patch'  alias gb='git branch'  alias gba='git branch -a' +alias gbd='git branch -d'  alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'  alias gbl='git blame -b -w'  alias gbnm='git branch --no-merged' diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 02e4f3e93..43aedc36d 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -32,6 +32,12 @@ alias npmE='PATH="$(npm bin)":"$PATH"'  # Check which npm modules are outdated  alias npmO="npm outdated" +# Check package versions +alias npmV="npm -v" + +# List packages +alias npmL="npm list" +  # Run npm start  alias npmst="npm start" diff --git a/plugins/osx/README.md b/plugins/osx/README.md index 0fcd23dd5..b77daecc5 100644 --- a/plugins/osx/README.md +++ b/plugins/osx/README.md @@ -30,3 +30,4 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)  | `showfiles`     | Show hidden files                                |  | `hidefiles`     | Hide the hidden files                            |  | `itunes`        | Control iTunes. User `itunes -h` for usage details | +| `spotify`       | Control Spotify and search by artist, album, track and etc.| diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a3e550972..aa6a256c1 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -261,6 +261,270 @@ EOF  	osascript -e "tell application \"iTunes\" to $opt"  } +# Spotify control function +function spotify() { + +  showHelp () { +    echo "Usage:"; +    echo; +    echo "  $(basename "$0") <command>"; +    echo; +    echo "Commands:"; +    echo; +    echo "  play                         # Resumes playback where Spotify last left off."; +    echo "  play [song name]             # Finds a song by name and plays it."; +    echo "  play album [album name]      # Finds an album by name and plays it."; +    echo "  play artist [artist name]    # Finds an artist by name and plays it."; +    echo "  play list [playlist name]    # Finds a playlist by name and plays it."; +    echo "  pause                        # Pauses Spotify playback."; +    echo "  next                         # Skips to the next song in a playlist."; +    echo "  prev                         # Returns to the previous song in a playlist."; +    echo "  pos [time]                   # Jumps to a time (in secs) in the current song."; +    echo "  quit                         # Stops playback and quits Spotify."; +    echo; +    echo "  vol up                       # Increases the volume by 10%."; +    echo "  vol down                     # Decreases the volume by 10%."; +    echo "  vol [amount]                 # Sets the volume to an amount between 0 and 100."; +    echo "  vol show                     # Shows the current Spotify volume."; +    echo; +    echo "  status                       # Shows the current player status."; +    echo "  share                        # Copies the current song URL to the clipboard." +    echo "  info                         # Shows Full Information about song that is playing."; +    echo; +    echo "  toggle shuffle               # Toggles shuffle playback mode."; +    echo "  toggle repeat                # Toggles repeat playback mode."; +  } + +  cecho(){ +    bold=$(tput bold); +    green=$(tput setaf 2); +    reset=$(tput sgr0); +    echo "$bold$green$1$reset"; +  } + +  showStatus () { +      state=$(osascript -e 'tell application "Spotify" to player state as string'); +      cecho "Spotify is currently $state."; +      if [ "$state" = "playing" ]; then +        artist=$(osascript -e 'tell application "Spotify" to artist of current track as string'); +        album=$(osascript -e 'tell application "Spotify" to album of current track as string'); +        track=$(osascript -e 'tell application "Spotify" to name of current track as string'); +        duration=$(osascript -e 'tell application "Spotify" to duration of current track as string'); +        duration=$(echo "scale=2; $duration / 60 / 1000" | bc); +        position=$(osascript -e 'tell application "Spotify" to player position as string' | tr ',' '.'); +        position=$(echo "scale=2; $position / 60" | bc | awk '{printf "%0.2f", $0}'); + +        printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s" "$artist" "$album" "$track" "$position" "$duration"; +      fi +  } + + + +  if [ $# = 0 ]; then +    showHelp; +  else +    if [ "$(osascript -e 'application "Spotify" is running')" = "false" ]; then +      osascript -e 'tell application "Spotify" to activate' +      sleep 2 +    fi +  fi + +  while [ $# -gt 0 ]; do +    arg=$1; + +    case $arg in +      "play"    ) +        if [ $# != 1 ]; then +          # There are additional arguments, so find out how many +          array=( $@ ); +          len=${#array[@]}; +          SPOTIFY_SEARCH_API="https://api.spotify.com/v1/search" +          SPOTIFY_PLAY_URI=""; + +          searchAndPlay() { +            type="$1" +            Q="$2" + +            cecho "Searching ${type}s for: $Q"; + +            SPOTIFY_PLAY_URI=$( \ +              curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=$type&limit=1&offset=0" -H "Accept: application/json" \ +              | grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1 +              ) +          } + +          case $2 in +            "list"  ) +              _args=${array[*]:2:$len}; +              Q=$_args; + +              cecho "Searching playlists for: $Q"; + +              results=$( \ +                curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" \ +                | grep -E -o "spotify:user:[a-zA-Z0-9_]+:playlist:[a-zA-Z0-9]+" -m 10 \ +                ) + +              count=$( \ +                echo "$results" | grep -c "spotify:user" \ +                ) + +              if [ "$count" -gt 0 ]; then +                random=$(( RANDOM % count)); + +                SPOTIFY_PLAY_URI=$( \ +                  echo "$results" | awk -v random="$random" '/spotify:user:[a-zA-Z0-9]+:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \ +                  ) +              fi;; + +            "album" | "artist" | "track"    ) +              _args=${array[*]:2:$len}; +              searchAndPlay "$2" "$_args";; + +            *   ) +              _args=${array[*]:1:$len}; +              searchAndPlay track "$_args";; +          esac + +          if [ "$SPOTIFY_PLAY_URI" != "" ]; then +            cecho "Playing ($Q Search) -> Spotify URL: $SPOTIFY_PLAY_URI"; + +            osascript -e "tell application \"Spotify\" to play track \"$SPOTIFY_PLAY_URI\""; + +          else +            cecho "No results when searching for $Q"; +          fi +        else +          # play is the only param +          cecho "Playing Spotify."; +          osascript -e 'tell application "Spotify" to play'; +        fi +        break ;; + +      "pause"    ) +        state=$(osascript -e 'tell application "Spotify" to player state as string'); +        if [ "$state" = "playing" ]; then +          cecho "Pausing Spotify."; +        else +          cecho "Playing Spotify."; +        fi + +        osascript -e 'tell application "Spotify" to playpause'; +        break ;; + +      "quit"    )  +        cecho "Quitting Spotify."; +        osascript -e 'tell application "Spotify" to quit'; +        exit 1 ;; + +      "next"    )  +        cecho "Going to next track." ; +        osascript -e 'tell application "Spotify" to next track'; +        break ;; + +      "prev"    )  +        cecho "Going to previous track."; +        osascript -e 'tell application "Spotify" to previous track'; +        break ;; + +      "vol"    ) +        vol=$(osascript -e 'tell application "Spotify" to sound volume as integer'); +        if [[ "$2" = "show" || "$2" = "" ]]; then +          cecho "Current Spotify volume level is $vol."; +          break ; +        elif [ "$2" = "up" ]; then +          if [ "$vol" -le 90 ]; then +            newvol=$(( vol+10 )); +            cecho "Increasing Spotify volume to $newvol."; +          else +            newvol=100; +            cecho "Spotify volume level is at max."; +          fi +        elif [ "$2" = "down" ]; then +          if [ "$vol" -ge 10 ]; then +            newvol=$(( vol-10 )); +            cecho "Reducing Spotify volume to $newvol."; +          else +            newvol=0; +            cecho "Spotify volume level is at min."; +          fi +        elif [ "$2" -ge 0 ]; then +          newvol=$2; +        fi + +        osascript -e "tell application \"Spotify\" to set sound volume to $newvol"; +        break ;; + +      "toggle"  ) +        if [ "$2" = "shuffle" ]; then +          osascript -e 'tell application "Spotify" to set shuffling to not shuffling'; +          curr=$(osascript -e 'tell application "Spotify" to shuffling'); +          cecho "Spotify shuffling set to $curr"; +        elif [ "$2" = "repeat" ]; then +          osascript -e 'tell application "Spotify" to set repeating to not repeating'; +          curr=$(osascript -e 'tell application "Spotify" to repeating'); +          cecho "Spotify repeating set to $curr"; +        fi +        break ;; + +      "pos"   ) +        cecho "Adjusting Spotify play position." +        osascript -e "tell application \"Spotify\" to set player position to $2"; +        break;; + +      "status" ) +        showStatus; +        break ;; + +      "info" ) +        info=$(osascript -e 'tell application "Spotify" +          set tM to round (duration of current track / 60) rounding down +          set tS to duration of current track mod 60 +          set pos to player position as text +          set myTime to tM as text & "min " & tS as text & "s" +          set nM to round (player position / 60) rounding down +          set nS to round (player position mod 60) rounding down +          set nowAt to nM as text & "min " & nS as text & "s" +          set info to "" & "\nArtist:         " & artist of current track +          set info to info & "\nTrack:          " & name of current track +          set info to info & "\nAlbum Artist:   " & album artist of current track +          set info to info & "\nAlbum:          " & album of current track +          set info to info & "\nSeconds:        " & duration of current track +          set info to info & "\nSeconds played: " & pos +          set info to info & "\nDuration:       " & mytime +          set info to info & "\nNow at:         " & nowAt +          set info to info & "\nPlayed Count:   " & played count of current track +          set info to info & "\nTrack Number:   " & track number of current track +          set info to info & "\nPopularity:     " & popularity of current track +          set info to info & "\nId:             " & id of current track +          set info to info & "\nSpotify URL:    " & spotify url of current track +          set info to info & "\nArtwork:        " & artwork of current track +          set info to info & "\nPlayer:         " & player state +          set info to info & "\nVolume:         " & sound volume +          set info to info & "\nShuffle:        " & shuffling +          set info to info & "\nRepeating:      " & repeating +          end tell +          return info') +        echo "$info"; +        break ;; + +    "share"     ) +      url=$(osascript -e 'tell application "Spotify" to spotify url of current track'); +      remove='spotify:track:' +      url=${url#$remove} +      url="http://open.spotify.com/track/$url" +      cecho "Share URL: $url"; +      cecho -n "$url" | pbcopy +      break;; + +      -h|--help| *) +        showHelp; +        break ;; +    esac +  done +} + +  # Show/hide hidden files in the Finder  alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"  alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder" diff --git a/plugins/perms/perms.plugin.zsh b/plugins/perms/perms.plugin.zsh index 81f56d577..7cdebab7f 100644 --- a/plugins/perms/perms.plugin.zsh +++ b/plugins/perms/perms.plugin.zsh @@ -6,10 +6,10 @@  ### Aliases  # Set all files' permissions to 644 recursively in a directory -alias set644='find . -type f -print0 | xargs -0 chmod 644' +alias set644='find . -type f ! -perm 644 -print0 | xargs -0 chmod 644'  # Set all directories' permissions to 755 recursively in a directory -alias set755='find . -type d -print0 | xargs -0 chmod 755' +alias set755='find . -type d ! -perm 755 -print0 | xargs -0 chmod 755'  ### Functions @@ -63,14 +63,14 @@ EOF    exit_status=0;    if [[ $use_slow == true ]]; then      # Process directories first so non-traversable ones are fixed as we go -    find "$target" -type d -exec chmod $chmod_opts 755 {} \; +    find "$target" -type d ! -perm 755 -exec chmod $chmod_opts 755 {} \;      if [[ $? != 0 ]]; then exit_status=$?; fi -    find "$target" -type f -exec chmod $chmod_opts 644 {} \; +    find "$target" -type f ! -perm 644 -exec chmod $chmod_opts 644 {} \;      if [[ $? != 0 ]]; then exit_status=$?; fi    else -    find "$target" -type d -print0 | xargs -0 chmod $chmod_opts 755 +    find "$target" -type d ! -perm 755 -print0 | xargs -0 chmod $chmod_opts 755      if [[ $? != 0 ]]; then exit_status=$?; fi -    find "$target" -type f -print0 | xargs -0 chmod $chmod_opts 644 +    find "$target" -type f ! -perm 644 -print0 | xargs -0 chmod $chmod_opts 644      if [[ $? != 0 ]]; then exit_status=$?; fi    fi    echo "Complete" diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index e532639b5..c8974b5f4 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -36,6 +36,7 @@ alias -g RET='RAILS_ENV=test'  # Rails aliases  alias rc='rails console' +alias rcs='rails console --sandbox'  alias rd='rails destroy'  alias rdb='rails dbconsole'  alias rg='rails generate' diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index b668fa3b2..20f97c6f1 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -30,7 +30,7 @@ if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then  elif [[ -f "$_ssh_env_cache" ]]; then  	# Source SSH settings, if applicable  	. $_ssh_env_cache > /dev/null -	pgrep ssh-agent | grep -q $SSH_AGENT_PID || { +	ps x | grep ssh-agent | grep -q $SSH_AGENT_PID || {  		_start_agent  	}  else diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md index 15e657859..c12ce047f 100644 --- a/plugins/xcode/README.md +++ b/plugins/xcode/README.md @@ -26,7 +26,7 @@ plugins=(... xcode)  ###  `xc` -Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. +Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files.  Returns 1 if it didn't find any relevant files.  ###  `simulator` diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 0a2fa0839..f711c39fb 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -7,10 +7,19 @@ alias xcsel='sudo xcode-select --switch'  # source: http://gist.github.com/subdigital/5420709  function xc {    local xcode_proj -  xcode_proj=(*.{xcworkspace,xcodeproj}(N)) +  if [[ $# == 0 ]]; then +    xcode_proj=(*.{xcworkspace,xcodeproj}(N)) +  else +    xcode_proj=($1/*.{xcworkspace,xcodeproj}(N)) +  fi +    if [[ ${#xcode_proj} -eq 0 ]]; then -    echo "No xcworkspace/xcodeproj file found in the current directory." +    if [[ $# == 0 ]]; then +      echo "No xcworkspace/xcodeproj file found in the current directory." +    else +      echo "No xcworkspace/xcodeproj file found in $1." +    fi      return 1    else      echo "Found ${xcode_proj[1]}" diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index c6ded38d8..278a70181 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -127,6 +127,27 @@ prompt_git() {    fi  } +prompt_bzr() { +    if (bzr status >/dev/null 2>&1); then +        status_mod=`bzr status | head -n1 | grep "modified" | wc -m` +        status_all=`bzr status | head -n1 | wc -m` +        revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'` +        if [[ $status_mod -gt 0 ]] ; then +            prompt_segment yellow black +            echo -n "bzr@"$revision "✚ " +        else +            if [[ $status_all -gt 0 ]] ; then +                prompt_segment yellow black +                echo -n "bzr@"$revision + +            else +                prompt_segment green black +                echo -n "bzr@"$revision +            fi +        fi +    fi +} +  prompt_hg() {    (( $+commands[hg] )) || return    local rev status @@ -208,6 +229,7 @@ build_prompt() {    prompt_dir    prompt_git    prompt_cabal_sandbox +  prompt_bzr    prompt_hg    prompt_end  } diff --git a/themes/peepcode.zsh-theme b/themes/peepcode.zsh-theme index 9dc58294a..b6dfa6870 100644 --- a/themes/peepcode.zsh-theme +++ b/themes/peepcode.zsh-theme @@ -41,10 +41,4 @@ PROMPT='  %~  ${smiley}  %{$reset_color%}' -if [[ -d ~/.rvm ]] && [[ -e ~/.rvm/bin/rvm-prompt ]]; then -    rvm_prompt='$(~/.rvm/bin/rvm-prompt)' -else -    rvm_prompt='' -fi - -RPROMPT='%{$fg[white]%} $rvm_prompt$(git_prompt)%{$reset_color%}' +RPROMPT='%{$fg[white]%} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}'  | 
