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

Merge branch 'master' into clipboard

parents d81cd753 368198b7
......@@ -29,4 +29,4 @@ alias nmap_full_udp="sudo nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,443
alias nmap_traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute "
alias nmap_full_with_scripts="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all "
alias nmap_web_safe_osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy "
alias nmap_ping_scan="nmap -n -sP"
(( $+commands[npm] )) && {
__NPM_COMPLETION_FILE="${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion"
if [[ ! -f $__NPM_COMPLETION_FILE ]]; then
npm completion >! $__NPM_COMPLETION_FILE 2>/dev/null
[[ $? -ne 0 ]] && rm -f $__NPM_COMPLETION_FILE
fi
[[ -f $__NPM_COMPLETION_FILE ]] && source $__NPM_COMPLETION_FILE
unset __NPM_COMPLETION_FILE
rm -f "${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion"
_npm_completion() {
local si=$IFS
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
COMP_LINE=$BUFFER \
COMP_POINT=0 \
npm completion -- "${words[@]}" \
2>/dev/null)
IFS=$si
}
compdef _npm_completion npm
}
# Install dependencies globally
......
# 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
......@@ -43,7 +43,7 @@ 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 |
......@@ -56,6 +56,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| `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 |
| `itunes` | DEPRECATED. Use `music` from macOS Catalina on |
| `music` | Control Apple Music. Use `music -h` for usage details |
| `spotify` | Control Spotify and search by artist, album, track… |
| `rmdsstore` | Remove .DS\_Store files recursively in a directory |
......@@ -219,7 +219,19 @@ function vncviewer() {
}
# iTunes control function
function itunes() {
function itunes music() {
local APP_NAME=Music
autoload is-at-least
if is-at-least 10.15 $(sw_vers -productVersion); then
if [[ $0 = itunes ]]; then
echo >&2 The itunes function name is deprecated. Use \`music\' instead.
return 1
fi
else
APP_NAME=iTunes
fi
local opt=$1
local playlist=$2
shift
......@@ -236,7 +248,7 @@ function itunes() {
opt="$opt track"
;;
vol)
local new_volume volume=$(osascript -e 'tell application "iTunes" to get sound volume')
local new_volume volume=$(osascript -e "tell application \"$APP_NAME\" to get sound volume")
if [[ $# -eq 0 ]]; then
echo "Current volume is ${volume}."
return 0
......@@ -252,8 +264,8 @@ function itunes() {
;;
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 [[ ! -z "$playlist" ]]; then
osascript -e "tell application \"$APP_NAME\"" -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
......@@ -264,13 +276,13 @@ if [[ ! -z "$playlist" ]]; then
fi
;;
playing|status)
local state=`osascript -e 'tell application "iTunes" to player state as string'`
local state=`osascript -e "tell application \"$APP_NAME\" to player state as string"`
if [[ "$state" = "playing" ]]; then
currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'`
currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'`
currenttrack=`osascript -e "tell application \"$APP_NAME\" to name of current track as string"`
currentartist=`osascript -e "tell application \"$APP_NAME\" to artist of current track as string"`
echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color";
else
echo "iTunes is" $state;
echo "$APP_NAME is" $state;
fi
return 0
;;
......@@ -284,7 +296,7 @@ if [[ ! -z "$playlist" ]]; then
if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]]
then
print "Usage: itunes shuffle [on|off|toggle]. Invalid option."
print "Usage: $0 shuffle [on|off|toggle]. Invalid option."
return 1
fi
......@@ -305,14 +317,14 @@ EOF
esac
;;
""|-h|--help)
echo "Usage: itunes <option>"
echo "Usage: $0 <option>"
echo "option:"
echo "\tlaunch|play|pause|stop|rewind|resume|quit"
echo "\tmute|unmute\tcontrol volume set"
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 "\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 Music."
echo "\tplaylist [playlist name]\t Play specific playlist"
echo "\thelp\tshow this message and exit"
return 0
......@@ -322,7 +334,7 @@ EOF
return 1
;;
esac
osascript -e "tell application \"iTunes\" to $opt"
osascript -e "tell application \"$APP_NAME\" to $opt"
}
# Spotify control function
......
......@@ -148,11 +148,11 @@ if [ $# = 0 ]; then
else
if [ ! -d /Applications/Spotify.app ] && [ ! -d $HOME/Applications/Spotify.app ]; then
echo "The Spotify application must be installed."
exit 1
return 1
fi
if [ $(osascript -e 'application "Spotify" is running') = "false" ]; then
osascript -e 'tell application "Spotify" to activate' || exit 1
osascript -e 'tell application "Spotify" to activate' || return 1
sleep 2
fi
fi
......@@ -170,12 +170,12 @@ while [ $# -gt 0 ]; do
if [ -z "${CLIENT_ID}" ]; then
cecho "Invalid Client ID, please update ${USER_CONFIG_FILE}";
showAPIHelp;
exit 1;
return 1
fi
if [ -z "${CLIENT_SECRET}" ]; then
cecho "Invalid Client Secret, please update ${USER_CONFIG_FILE}";
showAPIHelp;
exit 1;
return 1
fi
SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r');
SPOTIFY_PLAY_URI="";
......@@ -194,7 +194,7 @@ while [ $# -gt 0 ]; do
cecho "Autorization failed, please check ${USER_CONFG_FILE}"
cecho "${SPOTIFY_TOKEN_RESPONSE_DATA}"
showAPIHelp
exit 1
return 1
fi
SPOTIFY_ACCESS_TOKEN=$( \
printf "${SPOTIFY_TOKEN_RESPONSE_DATA}" \
......@@ -307,7 +307,7 @@ while [ $# -gt 0 ]; do
"quit" ) cecho "Quitting Spotify.";
osascript -e 'tell application "Spotify" to quit';
exit 0 ;;
break ;;
"next" ) cecho "Going to next track." ;
osascript -e 'tell application "Spotify" to next track';
......@@ -358,7 +358,7 @@ while [ $# -gt 0 ]; do
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;
return 1
fi
osascript -e "tell application \"Spotify\" to set sound volume to $newvol";
......@@ -468,9 +468,10 @@ while [ $# -gt 0 ]; do
"help" )
showHelp;
break ;;
* )
showHelp;
exit 1;
return 1 ;;
esac
done
......
# otp plugin
This plugin allows you to create one-time passwords using [`oathtool`](https://www.nongnu.org/oath-toolkit/man-oathtool.html),
able to replace MFA devices. The oathtool key is kept in a GPG-encrypted file so the codes
can only be generated by a user able to decrypt it.
To use it, add `otp` to the plugins array in your zshrc file:
```zsh
plugins=(... otp)
```
Provided aliases:
- `otp_add_device`: creates a new encrypted storage for an oathtool key and stores it
on the disk. For encrypting the key, it will ask for a GPG user ID (your GPG key's
email address). Then the OTP key needs to be pasted, followed by a CTRL+D character
inserted on an empty line.
- `ot`: generates a MFA code based on the given key and copies it to the clipboard
(on Linux it relies on xsel, on MacOS X it uses pbcopy instead).
The plugin uses `$HOME/.otp` to store its internal files.
......@@ -12,32 +12,23 @@ function ot () {
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>"
if [[ -z "$1" ]]; then
echo "usage: $0 <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
oathtool --totp --b $totpkey | tee /dev/stderr | clipcopy
fi
}
function otp_add_device () {
if [[ "x$1" == "x" ]] then
echo "usage: otp_add <profile.name>"
echo "usage: $0 <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"
......
# 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 $@
}
```
# Paver
This plugin adds completion for the `paver` command-line tool of [Paver](https://pythonhosted.org/Paver/).
To use it, add `paver` to the plugins array of your zshrc file:
```zsh
plugins=(... paver)
```
The completion function creates a cache of paver tasks with the name `.paver_tasks`,
in the current working directory. It regenerates that cache when the `pavement.py`
changes.
_paver_does_target_list_need_generating () {
[ ! -f .paver_targets ] && return 0;
[ pavement.py -nt .paver_targets ] && return 0;
return 1;
[ ! -f .paver_targets ] && return 0
[ pavement.py -nt .paver_targets ] && return 0
return 1
}
_paver () {
......
## 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)
Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh)
### Requirements
......@@ -8,7 +8,7 @@ Provides some useful function to make [percol](https://github.com/mooz/percol) w
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.
And [jump](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement.
### Usage
......
# 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
# 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)
```
# pip plugin
This plugin adds completion for [pip](https://pip.pypa.io/en/latest/),
the Python package manager.
To use it, add `pip` to the plugins array in your zshrc file:
```zsh
plugins=(... pip)
```
## pip cache
The pip plugin caches the names of available pip packages from the PyPI index.
To trigger the caching process, try to complete `pip install`,
or you can run `zsh-pip-cache-packages` directly.
To reset the cache, run `zsh-pip-clear-cache` and it will be rebuilt next
the next time you autocomplete `pip install`.
......@@ -23,7 +23,8 @@ _togglePipenvShell() {
fi
fi
}
chpwd_functions+=(_togglePipenvShell)
autoload -U add-zsh-hook
add-zsh-hook chpwd _togglePipenvShell
# Aliases
alias pch="pipenv check"
......
# pod
This plugin adds completion for [`CocoaPods`](https://cocoapods.org/).
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.
To use it, add `pod` to the plugins array in your zshrc file:
```zsh
plugins=(... pod)
```
# pow plugin
This plugin adds completion and commands for [pow](http://pow.cx/), a
zero-configuration Rack server for macOS.
To use it, add pow to the plugins array of your zshrc file:
```sh
plugins=(... pow)
```
## Commands
- `kapow` will restart an app.
```bash
kapow myapp
```
- `kaput` will show the standard output from any pow app.
- `repow` will restart the pow process.
# Powder
This plugin provides completion for [powder](https://github.com/powder-rb/powder/).
To use it, add powder to the plugins array of your zshrc file:
```
plugins=(... powder)
```
# powify plugin
This plugin adds autocompletion for [powify](https://github.com/sethvargo/powify),
an easy-to-use wrapper for Basecamp's [pow](https://github.com/basecamp/pow).
To use it, add powify to the plugins array of your zshrc file:
```sh
plugins=(... powify)
```
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