From 9248052e917a1d9296d4b79fa229b081cefbc698 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 03:31:49 +0430 Subject: initial spotify control --- plugins/osx/osx.plugin.zsh | 98 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index a3e550972..948d69a29 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -261,6 +261,104 @@ EOF osascript -e "tell application \"iTunes\" to $opt" } +# Spotify control function +function spotify() { + showHelp () { + echo "Usage:"; + echo; + echo " $(basename "$0") "; + echo; + echo "Commands:"; + echo; + echo " play # Resumes playback where Spotify last left off."; + 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 [amount] # Sets the volume to an amount between 0 and 100."; + echo " vol show # Shows the current Spotify volume."; + echo; + echo " toggle shuffle # Toggles shuffle playback mode."; + echo " toggle repeat # Toggles repeat playback mode."; + } + + 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" ) + echo "Playing Spotify."; + osascript -e 'tell application "Spotify" to play'; + break ;; + + "pause" ) + echo "Pausing Spotify."; + osascript -e 'tell application "Spotify" to pause'; + break ;; + + "quit" ) + echo "Quitting Spotify."; + osascript -e 'tell application "Spotify" to quit'; + exit 1 ;; + + "next" ) + echo "Going to next track." ; + osascript -e 'tell application "Spotify" to next track'; + break ;; + + "prev" ) + echo "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 + echo "Current Spotify volume level is $vol."; + break ; + 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'); + echo "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'); + echo "Spotify repeating set to $curr"; + fi + break ;; + + "pos" ) + echo "Adjusting Spotify play position." + osascript -e "tell application \"Spotify\" to set player position to $2"; + 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" -- cgit v1.2.3-70-g09d2 From 8f47c96453a229ad5488bbd1e4ee8b7c522b6a15 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 03:37:53 +0430 Subject: volume up/down added --- plugins/osx/osx.plugin.zsh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 948d69a29..386507dbc 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -327,6 +327,22 @@ function spotify() { if [[ "$2" = "show" || "$2" = "" ]]; then echo "Current Spotify volume level is $vol."; break ; + elif [ "$2" = "up" ]; then + if [ "$vol" -le 90 ]; then + newvol=$(( vol+10 )); + echo "Increasing Spotify volume to $newvol."; + else + newvol=100; + echo "Spotify volume level is at max."; + fi + elif [ "$2" = "down" ]; then + if [ "$vol" -ge 10 ]; then + newvol=$(( vol-10 )); + echo "Reducing Spotify volume to $newvol."; + else + newvol=0; + echo "Spotify volume level is at min."; + fi elif [ "$2" -ge 0 ]; then newvol=$2; fi -- cgit v1.2.3-70-g09d2 From 92586e38c72a4a3a112a5c2b13cca6fc250e7447 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 03:50:53 +0430 Subject: add info, share and status option --- plugins/osx/osx.plugin.zsh | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 386507dbc..dc68916bf 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -263,6 +263,7 @@ EOF # Spotify control function function spotify() { + showHelp () { echo "Usage:"; echo; @@ -277,13 +278,35 @@ function spotify() { 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."; } + showStatus () { + state=$(osascript -e 'tell application "Spotify" to player state as string'); + echo "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}'); + + echo "$reset""Artist: $artist\nAlbum: $album\nTrack: $track \nPosition: $position / $duration"; + fi + } + if [ $# = 0 ]; then showHelp; else @@ -367,6 +390,51 @@ function spotify() { 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" + echo "Share URL: $url"; + echo -n "$url" | pbcopy + break;; + -h|--help| *) showHelp; break ;; -- cgit v1.2.3-70-g09d2 From 2a5321f4e69b55f626c94993a40b1dee6a73c26f Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 03:56:21 +0430 Subject: add color echo --- plugins/osx/osx.plugin.zsh | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index dc68916bf..19acd3dd5 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -263,7 +263,7 @@ EOF # Spotify control function function spotify() { - + showHelp () { echo "Usage:"; echo; @@ -291,9 +291,16 @@ function spotify() { 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'); - echo "Spotify is currently $state."; + 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'); @@ -307,6 +314,8 @@ function spotify() { fi } + + if [ $# = 0 ]; then showHelp; else @@ -321,50 +330,50 @@ function spotify() { case $arg in "play" ) - echo "Playing Spotify."; + cecho "Playing Spotify."; osascript -e 'tell application "Spotify" to play'; break ;; "pause" ) - echo "Pausing Spotify."; + cecho "Pausing Spotify."; osascript -e 'tell application "Spotify" to pause'; break ;; "quit" ) - echo "Quitting Spotify."; + cecho "Quitting Spotify."; osascript -e 'tell application "Spotify" to quit'; exit 1 ;; "next" ) - echo "Going to next track." ; + cecho "Going to next track." ; osascript -e 'tell application "Spotify" to next track'; break ;; "prev" ) - echo "Going to previous track."; + 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 - echo "Current Spotify volume level is $vol."; + cecho "Current Spotify volume level is $vol."; break ; elif [ "$2" = "up" ]; then if [ "$vol" -le 90 ]; then newvol=$(( vol+10 )); - echo "Increasing Spotify volume to $newvol."; + cecho "Increasing Spotify volume to $newvol."; else newvol=100; - echo "Spotify volume level is at max."; + cecho "Spotify volume level is at max."; fi elif [ "$2" = "down" ]; then if [ "$vol" -ge 10 ]; then newvol=$(( vol-10 )); - echo "Reducing Spotify volume to $newvol."; + cecho "Reducing Spotify volume to $newvol."; else newvol=0; - echo "Spotify volume level is at min."; + cecho "Spotify volume level is at min."; fi elif [ "$2" -ge 0 ]; then newvol=$2; @@ -377,16 +386,16 @@ function spotify() { if [ "$2" = "shuffle" ]; then osascript -e 'tell application "Spotify" to set shuffling to not shuffling'; curr=$(osascript -e 'tell application "Spotify" to shuffling'); - echo "Spotify shuffling set to $curr"; + 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'); - echo "Spotify repeating set to $curr"; + cecho "Spotify repeating set to $curr"; fi break ;; "pos" ) - echo "Adjusting Spotify play position." + cecho "Adjusting Spotify play position." osascript -e "tell application \"Spotify\" to set player position to $2"; break;; @@ -431,8 +440,8 @@ function spotify() { remove='spotify:track:' url=${url#$remove} url="http://open.spotify.com/track/$url" - echo "Share URL: $url"; - echo -n "$url" | pbcopy + cecho "Share URL: $url"; + cecho -n "$url" | pbcopy break;; -h|--help| *) -- cgit v1.2.3-70-g09d2 From 96d57dc33ec7ce473a7ce06d7c0166eabd14e1c8 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 03:58:15 +0430 Subject: change pause to play/pause --- plugins/osx/osx.plugin.zsh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 19acd3dd5..058576f0b 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -335,8 +335,14 @@ function spotify() { break ;; "pause" ) - cecho "Pausing Spotify."; - osascript -e 'tell application "Spotify" to 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" ) -- cgit v1.2.3-70-g09d2 From 3b2f827d5b37d51bdd0c165dc2b66501704990c4 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 04:12:13 +0430 Subject: add Search Option for album,artist and tracks --- plugins/osx/osx.plugin.zsh | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 058576f0b..031740633 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -330,9 +330,49 @@ function spotify() { 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 + "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: $"; + + 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'; - break ;; + fi + break ;; "pause" ) state=$(osascript -e 'tell application "Spotify" to player state as string'); -- cgit v1.2.3-70-g09d2 From b808555678ea6a960d3ab31f1bdce4bd18ab0a10 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 04:18:22 +0430 Subject: add search option for playlist --- plugins/osx/osx.plugin.zsh | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 031740633..4ba2026c0 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -350,6 +350,29 @@ function spotify() { } 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";; @@ -367,12 +390,12 @@ function spotify() { 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 ;; + 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'); -- cgit v1.2.3-70-g09d2 From 6cbba3353f20174c1cd55246507182dfab65ed97 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 04:35:29 +0430 Subject: fix showStatus output --- plugins/osx/osx.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 4ba2026c0..84eec9eed 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -310,7 +310,7 @@ function spotify() { position=$(osascript -e 'tell application "Spotify" to player position as string' | tr ',' '.'); position=$(echo "scale=2; $position / 60" | bc | awk '{printf "%0.2f", $0}'); - echo "$reset""Artist: $artist\nAlbum: $album\nTrack: $track \nPosition: $position / $duration"; + printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s" "$artist" "$album" "$track" "$position" "$duration"; fi } -- cgit v1.2.3-70-g09d2 From d099022e440a72b1352ac09773a1863d9833dbb1 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Wed, 31 Aug 2016 04:41:54 +0430 Subject: complete help --- plugins/osx/osx.plugin.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 84eec9eed..d75e3d2d6 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -272,6 +272,10 @@ function spotify() { 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."; -- cgit v1.2.3-70-g09d2 From f820345afa9d500f0ff6b1ad1c45d4d37ef7d88a Mon Sep 17 00:00:00 2001 From: mahi97 Date: Thu, 1 Sep 2016 01:52:04 +0430 Subject: readme updated --- plugins/osx/README.md | 1 + 1 file changed, 1 insertion(+) 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.| -- cgit v1.2.3-70-g09d2 From d6e032035cde237f09306ea6670a22e5994c38f4 Mon Sep 17 00:00:00 2001 From: mahi97 Date: Thu, 1 Sep 2016 01:52:43 +0430 Subject: seach show Url of song --- plugins/osx/osx.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index d75e3d2d6..aa6a256c1 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -387,7 +387,7 @@ function spotify() { esac if [ "$SPOTIFY_PLAY_URI" != "" ]; then - cecho "Playing ($Q Search) -> Spotify URL: $"; + cecho "Playing ($Q Search) -> Spotify URL: $SPOTIFY_PLAY_URI"; osascript -e "tell application \"Spotify\" to play track \"$SPOTIFY_PLAY_URI\""; -- cgit v1.2.3-70-g09d2 From 7e5483d672aab9764231d9a569b6c7451474eecb Mon Sep 17 00:00:00 2001 From: Dawnflash Lightstring Date: Wed, 21 Sep 2016 12:20:08 +0200 Subject: Add check for git and bzr to agnoster theme Plugin command-not-found on Arch Linux returns 0 if git or bzr is found in repos, hence outputting unwanted pkgfile output. Checking if the commands exist first fixes all such issues. --- themes/agnoster.zsh-theme | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index e1a294ee8..07546fd34 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -86,7 +86,7 @@ prompt_context() { # Git: branch/detached head, dirty status prompt_git() { - + (( $+commands[git] )) || return local PL_BRANCH_CHAR () { local LC_ALL="" LC_CTYPE="en_US.UTF-8" @@ -128,6 +128,7 @@ prompt_git() { } prompt_bzr() { + (( $+commands[bzr] )) || return 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` -- cgit v1.2.3-70-g09d2 From bd599066d763a0792b6c6b1654f098f3ca6e1df7 Mon Sep 17 00:00:00 2001 From: Carlo Dapor Date: Fri, 12 Aug 2016 20:50:57 +0200 Subject: Added angular-cli (ng) completion. --- plugins/ng/ng.plugin.zsh | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 plugins/ng/ng.plugin.zsh diff --git a/plugins/ng/ng.plugin.zsh b/plugins/ng/ng.plugin.zsh new file mode 100644 index 000000000..8e9b4ab16 --- /dev/null +++ b/plugins/ng/ng.plugin.zsh @@ -0,0 +1,73 @@ + +ng_opts='addon asset-sizes b build completion d destroy doc e2e g generate get h help i init install lint make-this-awesome new s serve server set t test v version -h --help' + +_ng_completion () { + local words cword opts + read -Ac words + read -cn cword + let cword-=1 + + case $words[cword] in + addon ) + opts='-b --blueprint -d -dir --directory --dry-run -sb --skip-bower -sg --skip-git -sn --skip-npm -v --verbose' + ;; + + asset-sizes ) + opts='-o --output-path' + ;; + + i | install) + opts='' + ;; + + b | build ) + opts='--environment --output-path --suppress-sizes --watch --watcher -dev -e -prod' + ;; + + d | destroy ) + opts='--dry-run --verbose --pod --classic --dummy --in-repo --in-repo-addon -d -v -p -c -dum -id -ir' + ;; + + g | generate ) + opts='component directive pipe route service --generate -d --dry-run --verbose -v --pod -p --classic -c --dummy -dum -id --in-repo --in-repo-addon -ir' + ;; + + h | help | -h | --help) + opts='--json --verbose -v' + ;; + + init ) + opts='--blueprint --dry-run --link-cli --mobile --name --prefix --skip-bower --skip-npm --source-dir --style --verbose -b -d -lc -n -p -sb -sd -sn -v' + ;; + + new ) + opts='--blueprint --directory --dry-run --link-cli --mobile --prefix --skip-bower --skip-git --skip-npm --source-dir --style --verbose -b -d -dir -lc -p -sb -sd -sg -sn -v' + ;; + + s | serve | server ) + opts='--environment --host --insecure-proxy --inspr --live-reload --live-reload-host --live-reload-port --output-path --port --proxy --ssl --ssl-cert --ssl-key --watcher -H -dev -e -lr -lrbu -lrh -lrp -op -out -p -pr -prod -pxy -w' + ;; + + set ) + opts='--global -g' + ;; + + t | test ) + opts='--browsers --colors --config-file --environment --filter --host --launch --log-level --module --path --port --query --reporter --server --silent --test-page --test-port --watch -H -c -cf -e -f -m -r -s -tp -w' + ;; + + v | version ) + opts='--verbose' + ;; + + ng | *) + opts=$ng_opts + ;; + esac + + setopt shwordsplit + reply=($opts) + unset shwordsplit +} + +compctl -K _ng_completion ng -- cgit v1.2.3-70-g09d2 From a748f513a6270fafca8328d614c7200a6f1e7484 Mon Sep 17 00:00:00 2001 From: Carlo Dapor Date: Fri, 12 Aug 2016 21:01:51 +0200 Subject: The argument completion also has no extra options. --- plugins/ng/ng.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ng/ng.plugin.zsh b/plugins/ng/ng.plugin.zsh index 8e9b4ab16..ce34c8b54 100644 --- a/plugins/ng/ng.plugin.zsh +++ b/plugins/ng/ng.plugin.zsh @@ -16,7 +16,7 @@ _ng_completion () { opts='-o --output-path' ;; - i | install) + completion | i | install) opts='' ;; -- cgit v1.2.3-70-g09d2 From 3da2f7ea6a5aa6ea312846e070b534df5aa78baf Mon Sep 17 00:00:00 2001 From: Carlo Dapor Date: Fri, 12 Aug 2016 23:43:19 +0200 Subject: Updated options for generate. Added gh-pages:deploy / github-pages:deploy. --- plugins/ng/ng.plugin.zsh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/ng/ng.plugin.zsh b/plugins/ng/ng.plugin.zsh index ce34c8b54..2488bc230 100644 --- a/plugins/ng/ng.plugin.zsh +++ b/plugins/ng/ng.plugin.zsh @@ -1,5 +1,5 @@ -ng_opts='addon asset-sizes b build completion d destroy doc e2e g generate get h help i init install lint make-this-awesome new s serve server set t test v version -h --help' +ng_opts='addon asset-sizes b build completion d destroy doc e2e g generate get github-pages:deploy gh-pages:deploy h help i init install lint make-this-awesome new s serve server set t test v version -h --help' _ng_completion () { local words cword opts @@ -16,12 +16,8 @@ _ng_completion () { opts='-o --output-path' ;; - completion | i | install) - opts='' - ;; - b | build ) - opts='--environment --output-path --suppress-sizes --watch --watcher -dev -e -prod' + opts='--environment --output-path --suppress-sizes --target --watch --watcher -dev -e -prod' ;; d | destroy ) @@ -29,7 +25,11 @@ _ng_completion () { ;; g | generate ) - opts='component directive pipe route service --generate -d --dry-run --verbose -v --pod -p --classic -c --dummy -dum -id --in-repo --in-repo-addon -ir' + opts='class component directive enum module pipe route service --generate -d --dry-run --verbose -v --pod -p --classic -c --dummy -dum -id --in-repo --in-repo-addon -ir' + ;; + + gh-pages:deploy | github-pages:deploy ) + opts='--environment --gh-token --gh-username --skip-build --user-page --message' ;; h | help | -h | --help) @@ -45,7 +45,7 @@ _ng_completion () { ;; s | serve | server ) - opts='--environment --host --insecure-proxy --inspr --live-reload --live-reload-host --live-reload-port --output-path --port --proxy --ssl --ssl-cert --ssl-key --watcher -H -dev -e -lr -lrbu -lrh -lrp -op -out -p -pr -prod -pxy -w' + opts='--environment --host --insecure-proxy --inspr --live-reload --live-reload-base-url --live-reload-host --live-reload-live-css --live-reload-port --output-path --port --proxy --ssl --ssl-cert --ssl-key --target --watcher -H -dev -e -lr -lrbu -lrh -lrp -op -out -p -pr -prod -pxy -t -w' ;; set ) @@ -60,9 +60,13 @@ _ng_completion () { opts='--verbose' ;; - ng | *) + ng ) opts=$ng_opts ;; + + * ) + opts='' + ;; esac setopt shwordsplit -- cgit v1.2.3-70-g09d2 From 34bc556bd3500da316e020fb2cec3ba8dc6115ab Mon Sep 17 00:00:00 2001 From: Carlo Dapor Date: Mon, 15 Aug 2016 15:27:38 +0200 Subject: Added README.md --- plugins/ng/README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 plugins/ng/README.md diff --git a/plugins/ng/README.md b/plugins/ng/README.md new file mode 100644 index 000000000..86ad64041 --- /dev/null +++ b/plugins/ng/README.md @@ -0,0 +1,37 @@ +## NG Plugin + +This [ng plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/ng) + adds completion support for Angular's CLI (named ng). + +Ng is hosted on [ng home](https://github.com/catull/angular-cli) + +It is used to generate Angular 2 app "stubs", build those apps, configure them, +test them, lint them etc. + +Ahem, "stubs" is not what Angular engineers refer to the items ng can generate +for you. + +"Stubs" can be any one of: +- class +- component +- directive +- enum +- module +- pipe +- route +- service + +At the moment, `ng completion` creates a very rough completion for Zsh and +Bash. + +It is missing most of the options and a few arguments. +In future, this plugin may be shortened to simply being + +```zsh +eval `ng completion` +``` + +There is hope this materialises in the 21st century. + +### CONTRIBUTOR + - Carlo Dapor ([catull](https://github.com/catull)) -- cgit v1.2.3-70-g09d2 From 904d0ccef9a3508df61f9b0bb784d8b59d5e8bb2 Mon Sep 17 00:00:00 2001 From: Shang Yehua Date: Tue, 6 Sep 2016 11:10:42 +0800 Subject: Add some prompts for "install:install-file" (#5376) Add "-DgroupId= -DartifactId= -Dversion= -Dpackaging=jar -Dfile=" to options for "install:install-file" for when you need install a local jar file. Closes #5376. --- plugins/mvn/mvn.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index d290c98ec..625aad949 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -172,7 +172,7 @@ function listMavenCompletions { gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test # options - -Dmaven.test.skip=true -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true + -Dmaven.test.skip=true -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true -DgroupId= -DartifactId= -Dversion= -Dpackaging=jar -Dfile= # arguments -am -amd -B -C -c -cpu -D -e -emp -ep -f -fae -ff -fn -gs -h -l -N -npr -npu -nsu -o -P -pl -q -rf -s -T -t -U -up -V -v -X -- cgit v1.2.3-70-g09d2 From 0d897cca7499a4dd46536acbd999723fd0ca2b5d Mon Sep 17 00:00:00 2001 From: Gravemind Date: Thu, 22 Sep 2016 00:30:35 +0200 Subject: Fix hyphen and underscore filename completion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This deletes the previous hack that allowed completing files with the extension: e.g. `abcd.z` to `abcdefg.z`. It is still possible to use `abcd[TAB].z`, and hyphens or underscores are very much more important than this other trick. Source: https://github.com/robbyrussell/oh-my-zsh/issues/1398#issuecomment-169163149 Signed-off-by: Marc Cornellà --- lib/completion.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index f5b292471..85c892165 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -12,14 +12,14 @@ zmodload -i zsh/complist ## case-insensitive (all),partial-word and then substring completion if [ "x$CASE_SENSITIVE" = "xtrue" ]; then - zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' unset CASE_SENSITIVE else if [ "x$HYPHEN_INSENSITIVE" = "xtrue" ]; then - zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' unset HYPHEN_INSENSITIVE else - zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' fi fi -- cgit v1.2.3-70-g09d2 From 4e12024b0b883f31ab80a749d7ad6fadcee96904 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 22 Sep 2016 00:40:00 +0200 Subject: Fix styling of lib/completion.zsh --- lib/completion.zsh | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index 85c892165..bbd021656 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -1,4 +1,7 @@ # fixme - the load process here seems a bit bizarre +zmodload -i zsh/complist + +WORDCHARS='' unsetopt menu_complete # do not autoselect the first completion entry unsetopt flowcontrol @@ -6,32 +9,26 @@ setopt auto_menu # show completion menu on succesive tab press setopt complete_in_word setopt always_to_end -WORDCHARS='' - -zmodload -i zsh/complist +# should this be in keybindings? +bindkey -M menuselect '^o' accept-and-infer-next-history +zstyle ':completion:*:*:*:*:*' menu select -## case-insensitive (all),partial-word and then substring completion -if [ "x$CASE_SENSITIVE" = "xtrue" ]; then +# case insensitive (all), partial-word and substring completion +if [[ "$CASE_SENSITIVE" = true ]]; then zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' - unset CASE_SENSITIVE else - if [ "x$HYPHEN_INSENSITIVE" = "xtrue" ]; then + if [[ "$HYPHEN_INSENSITIVE" = true ]]; then zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' - unset HYPHEN_INSENSITIVE else zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' fi fi +unset CASE_SENSITIVE HYPHEN_INSENSITIVE zstyle ':completion:*' list-colors '' - -# should this be in keybindings? -bindkey -M menuselect '^o' accept-and-infer-next-history - -zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -if [ "$OSTYPE[0,7]" = "solaris" ] -then + +if [[ "$OSTYPE" = solaris* ]]; then zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm" else zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" -- cgit v1.2.3-70-g09d2 From 1b7fc2f3aca32ba8713be0e27305c5cf578033f6 Mon Sep 17 00:00:00 2001 From: Brad Urani Date: Thu, 22 Sep 2016 10:41:30 -0700 Subject: Add copybuffer function and keybinding (#5431) * Add copybuffer function and keybinding: binds ctrl-o to copy the command line buffer to the system clipboard. * Add README --- plugins/copybuffer/README.md | 11 +++++++++++ plugins/copybuffer/copybuffer.plugin.zsh | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 plugins/copybuffer/README.md create mode 100644 plugins/copybuffer/copybuffer.plugin.zsh diff --git a/plugins/copybuffer/README.md b/plugins/copybuffer/README.md new file mode 100644 index 000000000..da138bdbd --- /dev/null +++ b/plugins/copybuffer/README.md @@ -0,0 +1,11 @@ +# `copybuffer` plugin + +This plugin binds the ctrl-o keyboard shortcut to a command that copies the text +that is currently typed in the command line ($BUFFER) to the system clipboard. + +This is useful if you type a command - and before you hit enter to execute it - want +to copy it maybe so you can paste it into a script, gist or whatnot. + +```zsh +plugins=(... copybuffer) +``` diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh new file mode 100644 index 000000000..cc205d40f --- /dev/null +++ b/plugins/copybuffer/copybuffer.plugin.zsh @@ -0,0 +1,14 @@ +# copy the active line from the command line buffer +# onto the system clipboard (requires clipcopy plugin) + +copybuffer () { + if which clipcopy &>/dev/null; then + echo $BUFFER | clipcopy + else + echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly." + fi +} + +zle -N copybuffer + +bindkey "^O" copybuffer -- cgit v1.2.3-70-g09d2 From 57fcee0f1c520a7c5e3aa5e2bde974154cdaf0c3 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Sat, 24 Sep 2016 16:06:44 -0700 Subject: README copy updates --- README.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aab1af9fd..6da731890 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,15 @@ Oh My Zsh

-Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration. That sounds boring. Let's try this again. +Oh My Zsh is an open source, community-driven framework for managing your [zsh](http://www.zsh.org/) configuration. -__Oh My Zsh is a way of life!__ Once installed, your terminal prompt will become the talk of the town _or your money back!_ Each time you interact with your command prompt, you'll be able to take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, _"that is amazing. are you some sort of genius?"_ Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often. +That sounds boring. Let's try this again. + +__Oh My Zsh is a way of life!__ + +Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_ + +Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. To learn more, visit [ohmyz.sh](http://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. @@ -202,7 +208,10 @@ Thank you so much! ## Follow Us -We have an [@ohmyzsh](https://twitter.com/ohmyzsh) Twitter account. You should follow it. +We're on the social medias. + +* [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it. +* [Oh My Zsh](https://www.facebook.com/Oh-My-Zsh-296616263819290/) on Facebook. ## Merchandise -- cgit v1.2.3-70-g09d2