diff options
Diffstat (limited to 'plugins/osx')
-rw-r--r-- | plugins/osx/README.md | 33 | ||||
-rw-r--r-- | plugins/osx/osx.plugin.zsh | 46 | ||||
-rw-r--r-- | plugins/osx/spotify | 13 |
3 files changed, 70 insertions, 22 deletions
diff --git a/plugins/osx/README.md b/plugins/osx/README.md index d3a8f94df..3559dee02 100644 --- a/plugins/osx/README.md +++ b/plugins/osx/README.md @@ -42,19 +42,20 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## Commands -| Command | Description | -| :-------------- | :----------------------------------------------- | -| `tab` | Open the current directory in a new tab | -| `split_tab` | Split the current terminal tab horizontally | -| `vsplit_tab` | Split the current terminal tab vertically | -| `ofd` | Open the current directory in a Finder window | -| `pfd` | Return the path of the frontmost Finder window | -| `pfs` | Return the current Finder selection | -| `cdf` | `cd` to the current Finder directory | -| `pushdf` | `pushd` to the current Finder directory | -| `quick-look` | Quick-Look a specified file | -| `man-preview` | Open a specified man page in Preview app | -| `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.| +| Command | Description | +| :-------------- | :-------------------------------------------------- | +| `tab` | Open the current directory in a new tab | +| `split_tab` | Split the current terminal tab horizontally | +| `vsplit_tab` | Split the current terminal tab vertically | +| `ofd` | Open the current directory in a Finder window | +| `pfd` | Return the path of the frontmost Finder window | +| `pfs` | Return the current Finder selection | +| `cdf` | `cd` to the current Finder directory | +| `pushdf` | `pushd` to the current Finder directory | +| `quick-look` | Quick-Look a specified file | +| `man-preview` | Open a specified man page in Preview app | +| `showfiles` | Show hidden files | +| `hidefiles` | Hide the hidden files | +| `itunes` | Control iTunes. Use `itunes -h` for usage details | +| `spotify` | Control Spotify and search by artist, album, trackā¦ | +| `rmdsstore` | Remove .DS\_Store files recursively in a directory | diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index b7d6aca72..7deed0ba6 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -51,6 +51,17 @@ EOF end tell end tell EOF + elif [[ "$the_app" == 'Hyper' ]]; then + osascript >/dev/null <<EOF + tell application "System Events" + tell process "Hyper" to keystroke "t" using command down + end tell + delay 1 + tell application "System Events" + keystroke "${command}" + key code 36 #(presses enter) + end tell +EOF else echo "tab: unsupported terminal app: $the_app" @@ -91,6 +102,19 @@ EOF end tell end tell EOF + + elif [[ "$the_app" == 'Hyper' ]]; then + osascript >/dev/null <<EOF + tell application "System Events" + tell process "Hyper" + tell menu item "Split Vertically" of menu "Shell" of menu bar 1 + click + end tell + end tell + delay 1 + keystroke "${command} \n" + end tell +EOF else echo "$0: unsupported terminal app: $the_app" >&2 @@ -132,6 +156,19 @@ EOF end tell EOF + elif [[ "$the_app" == 'Hyper' ]]; then + osascript >/dev/null <<EOF + tell application "System Events" + tell process "Hyper" + tell menu item "Split Horizontally" of menu "Shell" of menu bar 1 + click + end tell + end tell + delay 1 + keystroke "${command} \n" + end tell +EOF + else echo "$0: unsupported terminal app: $the_app" >&2 false @@ -209,7 +246,7 @@ if [[ ! -z "$playlist" ]]; then opt="play" else opt="stop" - fi + fi else opt="set allPlaylists to (get name of every playlist)" fi @@ -241,7 +278,7 @@ if [[ ! -z "$playlist" ]]; then case "$state" in on|off) - # Inspired by: http://stackoverflow.com/a/14675583 + # Inspired by: https://stackoverflow.com/a/14675583 osascript 1>/dev/null 2>&1 <<-EOF tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" ) EOF @@ -282,3 +319,8 @@ source ${ZSH}/plugins/osx/spotify # 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" + +# Remove .DS_Store files recursively in a directory, default . +function rmdsstore() { + find "${@:-.}" -type f -name .DS_Store -delete +} diff --git a/plugins/osx/spotify b/plugins/osx/spotify index 69f6c5419..b4215dbe7 100644 --- a/plugins/osx/spotify +++ b/plugins/osx/spotify @@ -1,7 +1,7 @@ #!/usr/bin/env bash function spotify() { -# Copyright (c) 2012--2017 Harish Narayanan <mail@harishnarayanan.org> +# Copyright (c) 2012--2018 Harish Narayanan <mail@harishnarayanan.org> # # Contains numerous helpful contributions from Jorge Colindres, Thomas # Pritchard, iLan Epstein, Gabriele Bonetti, Sean Heller, Eric Martin @@ -134,8 +134,13 @@ showStatus () { if [ $# = 0 ]; then showHelp; else + if [ ! -d /Applications/Spotify.app ] && [ ! -d $HOME/Applications/Spotify.app ]; then + echo "The Spotify application must be installed." + exit 1 + fi + if [ $(osascript -e 'application "Spotify" is running') = "false" ]; then - osascript -e 'tell application "Spotify" to activate' + osascript -e 'tell application "Spotify" to activate' || exit 1 sleep 2 fi fi @@ -160,7 +165,7 @@ while [ $# -gt 0 ]; do showAPIHelp; exit 1; fi - SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"); + SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r'); SPOTIFY_PLAY_URI=""; getAccessToken() { @@ -408,7 +413,7 @@ while [ $# -gt 0 ]; do uri=`osascript -e 'tell application "Spotify" to spotify url of current track'`; remove='spotify:track:' url=${uri#$remove} - url="http://open.spotify.com/track/$url" + url="https://open.spotify.com/track/$url" if [ "$2" = "" ]; then cecho "Spotify URL: $url" |