Unverified Commit cad48e38 authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

Merge branch 'master' into fabric_task_description

parents 225425fe 40df67bc
# Nyan plugin
This plugin adds a command to display [Nyan Cat](https://en.wikipedia.org/wiki/Nyan_Cat) right inside your terminal.
**Plugin is deprecated**. Check [official repo](https://github.com/klange/nyancat) for more information.
\ No newline at end of file
if [[ -x `which nc` ]]; then print -Pn '%F{yellow}'
alias nyan='nc -v nyancat.dakko.us 23' # nyan cat cat >&2 <<-EOD
fi nyan plugin:
The nyancat server used by this plugin was shut down due to increased
bandwidth costs, so the nyan plugin no longer works. You can get the
same functionality in some distributions by installing the nyancat package,
or you can compile it yourself.
See https://github.com/klange/nyancat for more information.
EOD
print -Pn '%f'
# OC - OpenShift CLI
This plugin provides autocompletion for [OC](https://docs.openshift.com/container-platform/3.7/cli_reference/index.html) commands, building, managing and updating operations.
To use it, add `oc` to the plugins array of your zshrc file:
```bash
plugins=(... oc)
```
## Contributors
+ [kevinkirkup](https://github.com/kevinkirkup) - Plugin Author
# Autocompletion for oc, the command line interface for OpenShift
#
# Author: https://github.com/kevinkirkup
if [ $commands[oc] ]; then
source <(oc completion zsh)
fi
...@@ -12,22 +12,50 @@ plugins=(... osx) ...@@ -12,22 +12,50 @@ plugins=(... osx)
Original author: [Sorin Ionescu](https://github.com/sorin-ionescu) Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
## Acknowledgements
This application makes use of the following third party scripts:
[shpotify](https://github.com/hnarayanan/shpotify)
Copyright (c) 2012–2019 [Harish Narayanan](https://harishnarayanan.org/).
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## Commands ## Commands
| Command | Description | | Command | Description |
| :-------------- | :----------------------------------------------- | | :-------------- | :-------------------------------------------------- |
| `tab` | Open the current directory in a new tab | | `tab` | Open the current directory in a new tab |
| `split_tab` | Split the current terminal tab horizontally | | `split_tab` | Split the current terminal tab horizontally |
| `vsplit_tab` | Split the current terminal tab vertically | | `vsplit_tab` | Split the current terminal tab vertically |
| `ofd` | Open the current directory in a Finder window | | `ofd` | Open the current directory in a Finder window |
| `pfd` | Return the path of the frontmost Finder window | | `pfd` | Return the path of the frontmost Finder window |
| `pfs` | Return the current Finder selection | | `pfs` | Return the current Finder selection |
| `cdf` | `cd` to the current Finder directory | | `cdf` | `cd` to the current Finder directory |
| `pushdf` | `pushd` to the current Finder directory | | `pushdf` | `pushd` to the current Finder directory |
| `quick-look` | Quick-Look a specified file | | `quick-look` | Quick-Look a specified file |
| `man-preview` | Open a specified man page in Preview app | | `man-preview` | Open a specified man page in Preview app |
| `showfiles` | Show hidden files | | `showfiles` | Show hidden files |
| `hidefiles` | Hide the hidden files | | `hidefiles` | Hide the hidden files |
| `itunes` | Control iTunes. User `itunes -h` for usage details | | `itunes` | Control iTunes. Use `itunes -h` for usage details |
| `spotify` | Control Spotify and search by artist, album, track and etc.| | `spotify` | Control Spotify and search by artist, album, track… |
| `rmdsstore` | Remove .DS\_Store files recursively in a directory |
...@@ -51,6 +51,17 @@ EOF ...@@ -51,6 +51,17 @@ EOF
end tell end tell
end tell end tell
EOF 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 else
echo "tab: unsupported terminal app: $the_app" echo "tab: unsupported terminal app: $the_app"
...@@ -91,6 +102,19 @@ EOF ...@@ -91,6 +102,19 @@ EOF
end tell end tell
end tell end tell
EOF 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 else
echo "$0: unsupported terminal app: $the_app" >&2 echo "$0: unsupported terminal app: $the_app" >&2
...@@ -132,6 +156,19 @@ EOF ...@@ -132,6 +156,19 @@ EOF
end tell end tell
EOF 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 else
echo "$0: unsupported terminal app: $the_app" >&2 echo "$0: unsupported terminal app: $the_app" >&2
false false
...@@ -184,6 +221,7 @@ function vncviewer() { ...@@ -184,6 +221,7 @@ function vncviewer() {
# iTunes control function # iTunes control function
function itunes() { function itunes() {
local opt=$1 local opt=$1
local playlist=$2
shift shift
case "$opt" in case "$opt" in
launch|play|pause|stop|rewind|resume|quit) launch|play|pause|stop|rewind|resume|quit)
...@@ -198,8 +236,33 @@ function itunes() { ...@@ -198,8 +236,33 @@ function itunes() {
opt="$opt track" opt="$opt track"
;; ;;
vol) vol)
opt="set sound volume to $1" #$1 Due to the shift local new_volume volume=$(osascript -e 'tell application "iTunes" to get sound volume')
if [[ $# -eq 0 ]]; then
echo "Current volume is ${volume}."
return 0
fi
case $1 in
up) new_volume=$((volume + 10 < 100 ? volume + 10 : 100)) ;;
down) new_volume=$((volume - 10 > 0 ? volume - 10 : 0)) ;;
<0-100>) new_volume=$1 ;;
*) echo "'$1' is not valid. Expected <0-100>, up or down."
return 1 ;;
esac
opt="set sound volume to ${new_volume}"
;; ;;
playlist)
# Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
if [[ ! -z "$playlist" ]]; then
osascript -e 'tell application "iTunes"' -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null;
if [[ $? -eq 0 ]]; then
opt="play"
else
opt="stop"
fi
else
opt="set allPlaylists to (get name of every playlist)"
fi
;;
playing|status) playing|status)
local state=`osascript -e 'tell application "iTunes" to player state as string'` local state=`osascript -e 'tell application "iTunes" to player state as string'`
if [[ "$state" = "playing" ]]; then if [[ "$state" = "playing" ]]; then
...@@ -227,7 +290,7 @@ function itunes() { ...@@ -227,7 +290,7 @@ function itunes() {
case "$state" in case "$state" in
on|off) on|off)
# Inspired by: http://stackoverflow.com/a/14675583 # Inspired by: https://stackoverflow.com/a/14675583
osascript 1>/dev/null 2>&1 <<-EOF 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" ) 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 EOF
...@@ -248,8 +311,9 @@ EOF ...@@ -248,8 +311,9 @@ EOF
echo "\tmute|unmute\tcontrol volume set" echo "\tmute|unmute\tcontrol volume set"
echo "\tnext|previous\tplay next or previous track" echo "\tnext|previous\tplay next or previous track"
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer." echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
echo "\tvol\tSet the volume, takes an argument from 0 to 100" echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
echo "\tplaying|status\tShow what song is currently playing in iTunes." echo "\tplaying|status\tShow what song is currently playing in iTunes."
echo "\tplaylist [playlist name]\t Play specific playlist"
echo "\thelp\tshow this message and exit" echo "\thelp\tshow this message and exit"
return 0 return 0
;; ;;
...@@ -262,269 +326,13 @@ EOF ...@@ -262,269 +326,13 @@ EOF
} }
# Spotify control function # Spotify control function
function spotify() { source ${ZSH}/plugins/osx/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 # Show/hide hidden files in the Finder
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall 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" 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
}
#!/usr/bin/env bash
function spotify() {
# Copyright (c) 2012--2019 Harish Narayanan <mail@harishnarayanan.org>
#
# Contains numerous helpful contributions from Jorge Colindres, Thomas
# Pritchard, iLan Epstein, Gabriele Bonetti, Sean Heller, Eric Martin
# and Peter Fonseca.
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
USER_CONFIG_DEFAULTS="CLIENT_ID=\"\"\nCLIENT_SECRET=\"\"";
USER_CONFIG_FILE="${HOME}/.shpotify.cfg";
if ! [[ -f "${USER_CONFIG_FILE}" ]]; then
touch "${USER_CONFIG_FILE}";
echo -e "${USER_CONFIG_DEFAULTS}" > "${USER_CONFIG_FILE}";
fi
source "${USER_CONFIG_FILE}";
showAPIHelp() {
echo;
echo "Connecting to Spotify's API:";
echo;
echo " This command line application needs to connect to Spotify's API in order to";
echo " find music by name. It is very likely you want this feature!";
echo;
echo " To get this to work, you need to sign up (or in) and create an 'Application' at:";
echo " https://developer.spotify.com/my-applications/#!/applications/create";
echo;
echo " Once you've created an application, find the 'Client ID' and 'Client Secret'";
echo " values, and enter them into your shpotify config file at '${USER_CONFIG_FILE}'";
echo;
echo " Be sure to quote your values and don't add any extra spaces!";
echo " When done, it should look like this (but with your own values):";
echo ' CLIENT_ID="abc01de2fghijk345lmnop"';
echo ' CLIENT_SECRET="qr6stu789vwxyz"';
}
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 " play uri <uri> # Play songs from specific uri.";
echo;
echo " next # Skips to the next song in a playlist.";
echo " prev # Returns to the previous song in a playlist.";
echo " replay # Replays the current track from the beginning.";
echo " pos <time> # Jumps to a time (in secs) in the current song.";
echo " pause # Pauses (or resumes) Spotify playback.";
echo " stop # Stops playback.";
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 " status artist # Shows the currently playing artist.";
echo " status album # Shows the currently playing album.";
echo " status track # Shows the currently playing track.";
echo;
echo " share # Displays the current song's Spotify URL and URI."
echo " share url # Displays the current song's Spotify URL and copies it to the clipboard."
echo " share uri # Displays the current song's Spotify URI and copies it to the clipboard."
echo;
echo " toggle shuffle # Toggles shuffle playback mode.";
echo " toggle repeat # Toggles repeat playback mode.";
showAPIHelp
}
cecho(){
bold=$(tput bold);
green=$(tput setaf 2);
reset=$(tput sgr0);
echo $bold$green"$1"$reset;
}
showArtist() {
echo `osascript -e 'tell application "Spotify" to artist of current track as string'`;
}
showAlbum() {
echo `osascript -e 'tell application "Spotify" to album of current track as string'`;
}
showTrack() {
echo `osascript -e 'tell application "Spotify" to name of current track as string'`;
}
showStatus () {
state=`osascript -e 'tell application "Spotify" to player state as string'`;
cecho "Spotify is currently $state.";
duration=`osascript -e 'tell application "Spotify"
set durSec to (duration of current track / 1000) as text
set tM to (round (durSec / 60) rounding down) as text
if length of ((durSec mod 60 div 1) as text) is greater than 1 then
set tS to (durSec mod 60 div 1) as text
else
set tS to ("0" & (durSec mod 60 div 1)) as text
end if
set myTime to tM as text & ":" & tS as text
end tell
return myTime'`;
position=`osascript -e 'tell application "Spotify"
set pos to player position
set nM to (round (pos / 60) rounding down) as text
if length of ((round (pos mod 60) rounding down) as text) is greater than 1 then
set nS to (round (pos mod 60) rounding down) as text
else
set nS to ("0" & (round (pos mod 60) rounding down)) as text
end if
set nowAt to nM as text & ":" & nS as text
end tell
return nowAt'`;
echo -e $reset"Artist: $(showArtist)\nAlbum: $(showAlbum)\nTrack: $(showTrack) \nPosition: $position / $duration";
}
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' || exit 1
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_TOKEN_URI="https://accounts.spotify.com/api/token";
if [ -z "${CLIENT_ID}" ]; then
cecho "Invalid Client ID, please update ${USER_CONFIG_FILE}";
showAPIHelp;
exit 1;
fi
if [ -z "${CLIENT_SECRET}" ]; then
cecho "Invalid Client Secret, please update ${USER_CONFIG_FILE}";
showAPIHelp;
exit 1;
fi
SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r');
SPOTIFY_PLAY_URI="";
getAccessToken() {
cecho "Connecting to Spotify's API";
SPOTIFY_TOKEN_RESPONSE_DATA=$( \
curl "${SPOTIFY_TOKEN_URI}" \
--silent \
-X "POST" \
-H "Authorization: Basic ${SHPOTIFY_CREDENTIALS}" \
-d "grant_type=client_credentials" \
)
if ! [[ "${SPOTIFY_TOKEN_RESPONSE_DATA}" =~ "access_token" ]]; then
cecho "Autorization failed, please check ${USER_CONFG_FILE}"
cecho "${SPOTIFY_TOKEN_RESPONSE_DATA}"
showAPIHelp
exit 1
fi
SPOTIFY_ACCESS_TOKEN=$( \
printf "${SPOTIFY_TOKEN_RESPONSE_DATA}" \
| grep -E -o '"access_token":".*",' \
| sed 's/"access_token"://g' \
| sed 's/"//g' \
| sed 's/,.*//g' \
)
}
searchAndPlay() {
type="$1"
Q="$2"
getAccessToken;
cecho "Searching ${type}s for: $Q";
SPOTIFY_PLAY_URI=$( \
curl -s -G $SPOTIFY_SEARCH_API \
-H "Authorization: Bearer ${SPOTIFY_ACCESS_TOKEN}" \
-H "Accept: application/json" \
--data-urlencode "q=$Q" \
-d "type=$type&limit=1&offset=0" \
| grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1
)
echo "play uri: ${SPOTIFY_PLAY_URI}"
}
case $2 in
"list" )
_args=${array[@]:2:$len};
Q=$_args;
getAccessToken;
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" -H "Authorization: Bearer ${SPOTIFY_ACCESS_TOKEN}" \
| grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \
)
count=$( \
echo "$results" | grep -c "spotify:playlist" \
)
if [ "$count" -gt 0 ]; then
random=$(( $RANDOM % $count));
SPOTIFY_PLAY_URI=$( \
echo "$results" | awk -v random="$random" '/spotify:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \
)
fi;;
"album" | "artist" | "track" )
_args=${array[@]:2:$len};
searchAndPlay $2 "$_args";;
"uri" )
SPOTIFY_PLAY_URI=${array[@]:2:$len};;
* )
_args=${array[@]:1:$len};
searchAndPlay track "$_args";;
esac
if [ "$SPOTIFY_PLAY_URI" != "" ]; then
if [ "$2" = "uri" ]; then
cecho "Playing Spotify URI: $SPOTIFY_PLAY_URI";
else
cecho "Playing ($Q Search) -> Spotify URI: $SPOTIFY_PLAY_URI";
fi
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 ;;
"stop" )
state=`osascript -e 'tell application "Spotify" to player state as string'`;
if [ $state = "playing" ]; then
cecho "Pausing Spotify.";
osascript -e 'tell application "Spotify" to playpause';
else
cecho "Spotify is already stopped."
fi
break ;;
"quit" ) cecho "Quitting Spotify.";
osascript -e 'tell application "Spotify" to quit';
exit 0 ;;
"next" ) cecho "Going to next track." ;
osascript -e 'tell application "Spotify" to next track';
showStatus;
break ;;
"prev" ) cecho "Going to previous track.";
osascript -e '
tell application "Spotify"
set player position to 0
previous track
end tell';
showStatus;
break ;;
"replay" ) cecho "Replaying current track.";
osascript -e 'tell application "Spotify" to set player position to 0'
break ;;
"vol" )
vol=`osascript -e 'tell application "Spotify" to sound volume as integer'`;
if [[ $2 = "" || $2 = "show" ]]; 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 =~ ^[0-9]+$ ]] && [[ $2 -ge 0 && $2 -le 100 ]]; then
newvol=$2;
cecho "Setting Spotify volume level to $newvol";
else
echo "Improper use of 'vol' command"
echo "The 'vol' command should be used as follows:"
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 # Shows the current Spotify volume.";
exit 1;
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 ;;
"status" )
if [ $# != 1 ]; then
# There are additional arguments, a status subcommand
case $2 in
"artist" )
showArtist;
break ;;
"album" )
showAlbum;
break ;;
"track" )
showTrack;
break ;;
esac
else
# status is the only param
showStatus;
fi
break ;;
"info" )
info=`osascript -e 'tell application "Spotify"
set durSec to (duration of current track / 1000)
set tM to (round (durSec / 60) rounding down) as text
if length of ((durSec mod 60 div 1) as text) is greater than 1 then
set tS to (durSec mod 60 div 1) as text
else
set tS to ("0" & (durSec mod 60 div 1)) as text
end if
set myTime to tM as text & "min " & tS as text & "s"
set pos to player position
set nM to (round (pos / 60) rounding down) as text
if length of ((round (pos mod 60) rounding down) as text) is greater than 1 then
set nS to (round (pos mod 60) rounding down) as text
else
set nS to ("0" & (round (pos mod 60) rounding down)) as text
end if
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: " & durSec
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 url 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'`
cecho "$info";
break ;;
"share" )
uri=`osascript -e 'tell application "Spotify" to spotify url of current track'`;
remove='spotify:track:'
url=${uri#$remove}
url="https://open.spotify.com/track/$url"
if [ "$2" = "" ]; then
cecho "Spotify URL: $url"
cecho "Spotify URI: $uri"
echo "To copy the URL or URI to your clipboard, use:"
echo "\`spotify share url\` or"
echo "\`spotify share uri\` respectively."
elif [ "$2" = "url" ]; then
cecho "Spotify URL: $url";
echo -n $url | pbcopy
elif [ "$2" = "uri" ]; then
cecho "Spotify URI: $uri";
echo -n $uri | pbcopy
fi
break ;;
"pos" )
cecho "Adjusting Spotify play position."
osascript -e "tell application \"Spotify\" to set player position to $2";
break ;;
"help" )
showHelp;
break ;;
* )
showHelp;
exit 1;
esac
done
}
export OTP_HOME=~/.otp
mkdir -p $OTP_HOME
function ot () {
if ! command -v oathtool > /dev/null 2>&1; then
echo "Note: you need to install oathtool or oath-toolkit, depending on your OS or distribution."
return 1
fi
if ! command -v gpg > /dev/null 2>&1; then
echo "Note: you need to install gpg and create an ID using 'gpg --gen-key', unless you have one already."
return 1
fi
if [[ `uname` == 'Darwin' ]] then # MacOS X
export COPY_CMD='pbcopy'
elif command -v xsel > /dev/null 2>&1; then # Any Unix with xsel installed
export COPY_CMD='xsel --clipboard --input'
else
COPY_CMD='true'
fi
if [[ "x$1" == "x" ]]; then
echo "usage: otpw <profile.name>"
return 1
elif [ ! -f $OTP_HOME/$1.otp.asc ]; then
echo "missing profile $1, you might need to create it first using otp_add_device"
return 1
else
totpkey=$(gpg --decrypt $OTP_HOME/$1.otp.asc)
oathtool --totp --b $totpkey | tee /dev/stderr | `echo $COPY_CMD`
if [[ $COPY_CMD == 'true' ]] then
echo "Note: you might consider installing xsel for clipboard integration"
fi
fi
}
function otp_add_device () {
if [[ "x$1" == "x" ]] then
echo "usage: otp_add <profile.name>"
return 1
else
echo "Enter an email address attached to your GPG private key, then paste the secret configuration key followed by ^D"
rm -f $OTP_HOME/$1.otp.asc
gpg --armor --encrypt --output $OTP_HOME/$1.otp.asc /dev/stdin
fi
}
function otp_devices () {
reply=($(find $OTP_HOME -name \*.otp.asc | xargs basename -s .otp.asc))
}
compctl -K otp_devices ot
# pass
This plugin provides completion for the [pass](https://www.passwordstore.org/) password manager.
To use it, add `pass` to the plugins array in your zshrc file.
```
plugins=(... pass)
```
## Configuration
### Multiple repositories
If you use multiple repositories, you can configure completion like this:
```zsh
compdef _pass workpass
zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"
workpass() {
PASSWORD_STORE_DIR=$HOME/work/pass pass $@
}
```
...@@ -6,11 +6,17 @@ ...@@ -6,11 +6,17 @@
# Brian Mattern <rephorm@rephorm.com> # Brian Mattern <rephorm@rephorm.com>
# Jason A. Donenfeld <Jason@zx2c4.com>. # Jason A. Donenfeld <Jason@zx2c4.com>.
# All Rights Reserved. # All Rights Reserved.
#
# This file is licensed under the GPLv2+. # This file is licensed under the GPLv2+.
# Please visit http://git.zx2c4.com/password-store/tree/COPYING for more information. # Please visit https://git.zx2c4.com/password-store/tree/COPYING for more information.
# If you use multiple repositories, you can configure completion like this:
# #
# Oh my zsh plugin maintainer: Santiago Borrazás <sanbor@gmail.com> # compdef _pass workpass
# zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"
# workpass() {
# PASSWORD_STORE_DIR=$HOME/work/pass pass $@
# }
_pass () { _pass () {
...@@ -117,8 +123,9 @@ _pass_cmd_show () { ...@@ -117,8 +123,9 @@ _pass_cmd_show () {
} }
_pass_complete_entries_helper () { _pass_complete_entries_helper () {
local IFS=$'\n' local IFS=$'\n'
local prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}" local prefix
_values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' | sort):-""} zstyle -s ":completion:${curcontext}:" prefix prefix || prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
_values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' -e 's#\\#\\\\#' | sort):-""}
} }
_pass_complete_entries_with_subdirs () { _pass_complete_entries_with_subdirs () {
......
# pep8 plugin
This plugin adds completion for [pep8](https://pep8.readthedocs.io/en/release-1.7.x/#), a tool to check your Python code against some of the style conventions in [PEP 8](http://www.python.org/dev/peps/pep-0008/).
To use it, add pep8 to the plugins array of your zshrc file:
```
plugins=(... pep8)
```
[Per-Directory-History][6] per-directory-history plugin
========================= ----------------------------
Per directory history for zsh, as well as global history, and the This plugin adds per-directory history for zsh, as well as a global history,
ability to toggle between them with ^G. and the ability to toggle between them with a keyboard shortcut. This is a
bundle of the [official plugin by @jimhester][5].
This is a implementation of per directory history for zsh, some To use it, add `per-directory-history` to the plugins array in your zshrc file:
implementations of which exist in bash[1][],[2][]. It also implements
a per-directory-history-toggle-history function to change from using the
directory history to using the global history. In both cases the history is
always saved to both the global history and the directory history, so the
toggle state will not effect the saved histories. Being able to switch
between global and directory histories on the fly is a novel feature as far
as I am aware.
This is a standalone repository for the script, however it is also included in ```zsh
[oh-my-zsh][4] as a plugin. plugins=(... per-directory-history)
```
---------------------------------------------------------------------------- This is an implementation of per-directory history for zsh, some implementations
Usage of which exist in bash[1][],[2][]. It also implements a toggle-history function
---------------------------------------------------------------------------- to change from using the directory history to using the global history. In both
cases the history is always saved to both the global history and the directory
history, so the toggle state will not effect the saved histories. Being able to
switch between global and directory histories on the fly is a novel feature.
1. Load this script into your interactive ZSH session: ## Usage
% source zsh-per-directory-history.zsh The default mode is per directory history, interact with your history as normal.
2. The default mode if per directory history, interact with your history as normal. Press ^G (the <kbd>Control</kbd> and <kbd>G</kbd> keys simultaneously) to toggle
between local and global histories. If you would prefer a different shortcut to
toggle set the `PER_DIRECTORY_HISTORY_TOGGLE` environment variable.
3. Press ^G (the Control and G keys simultaneously) to toggle between local ## Configuration
and global histories.
* `HISTORY_BASE` is a global variable that defines the base directory in which the
directory histories are stored (default `$HOME/.directory_history`).
* `per-directory-history-toggle-history` is the function to toggle between local
and global histories.
* `PER_DIRECTORY_HISTORY_TOGGLE` is the key binding used to run the toggle-history
function above (default `^G`)
## History
------------------------------------------------------------------------------- The idea/inspiration for a per directory history is from [Stewart MacArthur][1]
Configuration and [Dieter][2], the implementation idea is from [Bart Schaefer][3]. The
------------------------------------------------------------------------------- implementation is by [Jim Hester][4] in September 2012.
* HISTORY_BASE a global variable that defines the base directory in which the
directory histories are stored
* per-directory-history-toggle-history is the function to toggle the history
-------------------------------------------------------------------------------
History
-------------------------------------------------------------------------------
The idea/inspiration for a per directory history is from [Stewart MacArthur][1]
and [Dieter][2], the implementation idea is from [Bart Schaefer][3]. The
implementation is by [Jim Hester][5] in September 2012.
[1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
[2]: http://dieter.plaetinck.be/per_directory_bash [2]: http://dieter.plaetinck.be/per_directory_bash
[3]: http://www.zsh.org/mla/users/1997/msg00226.html [3]: https://www.zsh.org/mla/users/1997/msg00226.html
[4]: https://github.com/robbyrussell/oh-my-zsh [4]: https://jimhester.com
[5]: http://jimhester.com [5]: https://github.com/jimhester/per-directory-history
[6]: http://github.com/jimhester/per-directory-history
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
# #
################################################################################ ################################################################################
# #
# Copyright (c) 2012 Jim Hester # Copyright (c) 2014 Jim Hester
# #
# This software is provided 'as-is', without any express or implied warranty. # This software is provided 'as-is', without any express or implied warranty.
# In no event will the authors be held liable for any damages arising from the # In no event will the authors be held liable for any damages arising from the
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history" [[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
[[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G'
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# toggle global/directory history used for searching - ctrl-G by default # toggle global/directory history used for searching - ctrl-G by default
...@@ -76,7 +77,7 @@ function per-directory-history-toggle-history() { ...@@ -76,7 +77,7 @@ function per-directory-history-toggle-history() {
autoload per-directory-history-toggle-history autoload per-directory-history-toggle-history
zle -N per-directory-history-toggle-history zle -N per-directory-history-toggle-history
bindkey '^G' per-directory-history-toggle-history bindkey $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# implementation details # implementation details
...@@ -108,8 +109,13 @@ function _per-directory-history-change-directory() { ...@@ -108,8 +109,13 @@ function _per-directory-history-change-directory() {
} }
function _per-directory-history-addhistory() { function _per-directory-history-addhistory() {
print -Sr -- ${1%%$'\n'} # respect hist_ignore_space
fc -p $_per_directory_history_directory if [[ -o hist_ignore_space ]] && [[ "$1" == \ * ]]; then
true
else
print -Sr -- "${1%%$'\n'}"
fc -p $_per_directory_history_directory
fi
} }
...@@ -140,8 +146,9 @@ function _per-directory-history-set-global-history() { ...@@ -140,8 +146,9 @@ function _per-directory-history-set-global-history() {
#add functions to the exec list for chpwd and zshaddhistory #add functions to the exec list for chpwd and zshaddhistory
chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory") autoload -U add-zsh-hook
zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory") add-zsh-hook chpwd _per-directory-history-change-directory
add-zsh-hook zshaddhistory _per-directory-history-addhistory
#start in directory mode #start in directory mode
mkdir -p ${_per_directory_history_directory:h} mkdir -p ${_per_directory_history_directory:h}
......
## percol
Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/jump/jump.plugin.zsh)
### Requirements
```shell
pip install percol
```
And [jump](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement.
### Usage
For default
- `^-r` bind to `percol_select_history`.You can use it to grep your history with percol.
- `^-b` bind to `percol_select_marks`.You can use it to grep your bookmarks with percol.
if which percol &> /dev/null; then
function percol_select_history() {
local tac
which gtac &> /dev/null && tac="gtac" || { which tac &> /dev/null && tac="tac" || { tac="tail -r" } }
BUFFER=$(fc -l -n 1 | eval $tac | percol --query "$LBUFFER")
CURSOR=$#BUFFER
zle -R -c
}
zle -N percol_select_history
bindkey '^R' percol_select_history
if which marks &> /dev/null; then
function percol_select_marks() {
BUFFER=$(marks | percol --query "$LBUFFER" | awk '{print $3}')
CURSOR=$#BUFFER # move cursor
zle -R -c # refresh
}
zle -N percol_select_marks
bindkey '^B' percol_select_marks
fi
fi
# Perl
This plugin adds [perl](https://www.perl.org/) useful aliases/functions.
To use it, add `perl` to the plugins array in your zshrc file:
```zsh
plugins=(... perl)
```
## Aliases
| Aliases | Command | Description |
| :------------ | :----------------- | :------------------------------------- |
| pbi | `perlbrew install` | Install specific perl version |
| pbl | `perlbrew list` | List all perl version installed |
| pbo | `perlbrew off` | Go back to the system perl |
| pbs | `perlbrew switch` | Turn it back on |
| pbu | `perlbrew use` | Use specific version of perl |
| pd | `perldoc` | Show the perl documentation |
| ple | `perl -wlne` | Use perl like awk/sed |
| latest-perl | `curl ...` | Show the latest stable release of Perl |
## Functions
* `newpl`: creates a basic Perl script file and opens it with $EDITOR.
* `pgs`: Perl Global Substitution: `pgs <find_pattern> <replace_pattern> <filename>`
Looks for `<find_pattern>` and replaces it with `<replace_pattern>` in `<filename>`.
* `prep`: Perl grep, because 'grep -P' is terrible: `prep <pattern> [<filename>]`
Lets you work with pipes or files (if no `<filename>` provided, use stdin).
## Requirements
In order to make this work, you will need to have perl installed.
More info on the usage and install: https://www.perl.org/get.html
...@@ -21,7 +21,7 @@ alias pd='perldoc' ...@@ -21,7 +21,7 @@ alias pd='perldoc'
alias ple='perl -wlne' alias ple='perl -wlne'
# show the latest stable release of Perl # show the latest stable release of Perl
alias latest-perl='curl -s http://www.perl.org/get.html | perl -wlne '\''if (/perl\-([\d\.]+)\.tar\.gz/) { print $1; exit;}'\' alias latest-perl='curl -s https://www.perl.org/get.html | perl -wlne '\''if (/perl\-([\d\.]+)\.tar\.gz/) { print $1; exit;}'\'
......
...@@ -4,6 +4,6 @@ Plugin to handle some unix filesystem permissions quickly ...@@ -4,6 +4,6 @@ Plugin to handle some unix filesystem permissions quickly
### Usage ### Usage
* `set755` recursively sets all directories located within the current working directory and sub directories to octal 755. * `set755` recursively sets all given directories (default to .) to octal 755.
* `set644` recursively sets all files located within the current working directory and sub directories to octal 644. * `set644` recursively sets all given files (default to .) to octal 644.
* `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two aliases. * `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two aliases.
\ No newline at end of file
...@@ -6,10 +6,14 @@ ...@@ -6,10 +6,14 @@
### Aliases ### Aliases
# Set all files' permissions to 644 recursively in a directory # Set all files' permissions to 644 recursively in a directory
alias set644='find . -type f ! -perm 644 -print0 | xargs -0 chmod 644' set644() {
find "${@:-.}" -type f ! -perm 644 -print0 | xargs -0 chmod 644
}
# Set all directories' permissions to 755 recursively in a directory # Set all directories' permissions to 755 recursively in a directory
alias set755='find . -type d ! -perm 755 -print0 | xargs -0 chmod 755' set755() {
find "${@:-.}" -type d ! -perm 755 -print0 | xargs -0 chmod 755
}
### Functions ### Functions
......
# Phing plugin
This plugin adds autocompletion for [`phing`](https://github.com/phingofficial/phing) targets.
To use it, add `phing` to the plugins array of your `.zshrc` file:
```
plugins=(... eecms)
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment