This commit is contained in:
Peter Kingswell 2022-05-14 21:32:41 -04:00
commit ccabffa608
424 changed files with 47120 additions and 10679 deletions

1
.bash_profile Symbolic link
View file

@ -0,0 +1 @@
/Users/peter/.bash_profile

1
.gitconfig Symbolic link
View file

@ -0,0 +1 @@
/Users/peter/.gitconfig

1
.github/CODEOWNERS vendored
View file

@ -5,6 +5,7 @@ plugins/genpass/ @atoponce
plugins/git-lfs/ @hellovietduc plugins/git-lfs/ @hellovietduc
plugins/gitfast/ @felipec plugins/gitfast/ @felipec
plugins/sdk/ @rgoldberg plugins/sdk/ @rgoldberg
plugins/shell-proxy/ @septs
plugins/universalarchive/ @Konfekt plugins/universalarchive/ @Konfekt
plugins/wp-cli/ @joshmedeski plugins/wp-cli/ @joshmedeski
plugins/zoxide/ @ajeetdsouza plugins/zoxide/ @ajeetdsouza

2
.github/FUNDING.yml vendored
View file

@ -1,2 +1,2 @@
github: [robbyrussell, mcornella, larson-carter] github: [ohmyzsh, robbyrussell, mcornella, larson-carter, carlosala]
open_collective: ohmyzsh open_collective: ohmyzsh

View file

@ -1,46 +0,0 @@
---
name: Bug report
about: Create a report to help us improve Oh My Zsh
labels: 'Bug'
---
<!--
Fill this out before posting. You can delete irrelevant sections, but
an issue where no sections have been filled will be deleted without comment.
-->
**Describe the bug**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior, for example:
1. Enable this plugin '...'
2. Run command '...' or try the autocomplete command '...'
3. See error
**Expected behavior**
A brief description of what should happen.
**Screenshots and/or Recordings**
If applicable, add screenshots to help explain your problem.
You can also record an asciinema session: https://asciinema.org/
**Self Check**
- Have you tried reaching out on the [Discord server](https://discord.gg/ohmyzsh)?
This can help cut down on filling up issues. We always have a few people
online that are in a variety of timezones that are willing to help you!
- Also searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=) might help you get quicker support
**Desktop (please complete the following information):**
- OS / Distro: [e.g. Arch Linux, macOS]
- If on Windows what version of WSL: [e.g. WSL1, WSL2]
- Latest ohmyzsh update?: [e.g. Yes/No]
- ZSH Version: [e.g. 5.6]
- Terminal emulator: [e.g. iTerm2]
**Additional context**
Add any other context about the problem here. This can be themes, plugins, custom configs.

68
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View file

@ -0,0 +1,68 @@
name: Report a bug
description: Report a bug that isn't caused by Oh My Zsh. If unsure, use this form
body:
- type: markdown
attributes:
value: |
## Self Check
- Look for similar errors in existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed).
- Try reaching out on the [Discord server](https://discord.gg/ohmyzsh) for help.
- type: textarea
validations:
required: true
attributes:
label: Describe the bug
description: A clear description of what the bug is.
- type: textarea
validations:
required: true
attributes:
label: Steps to reproduce
description: |
Steps to reproduce the problem.
placeholder: |
For example:
1. Enable plugin '...'
2. Run command '...' or try to complete command '...'
3. See error
- type: textarea
validations:
required: true
attributes:
label: Expected behavior
description: A brief description of what should happen.
- type: textarea
attributes:
label: Screenshots and recordings
description: |
If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/
- type: input
validations:
required: true
attributes:
label: OS / Linux distribution
placeholder: Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15...
- type: input
validations:
required: true
attributes:
label: Zsh version
description: Run `echo $ZSH_VERSION` to check.
placeholder: "5.6"
- type: input
validations:
required: true
attributes:
label: Terminal emulator
placeholder: iTerm2, GNOME Terminal, Terminal.app...
- type: dropdown
attributes:
label: If using WSL on Windows, which version of WSL
description: Run `wsl -l -v` to check.
options:
- WSL1
- WSL2
- type: textarea
attributes:
label: Additional context
description: Add any other context about the problem here. This can be themes, plugins, custom settings...

View file

@ -0,0 +1,77 @@
name: Report a bug in Oh My Zsh
description: Create a report to help us improve Oh My Zsh
labels: ['Bug']
body:
- type: markdown
attributes:
value: |
## Self Check
- **Make sure this bug only happens with Oh My Zsh enabled**.
- Look for similar errors in existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed).
- Try reaching out on the [Discord server](https://discord.gg/ohmyzsh) for help.
- type: textarea
validations:
required: true
attributes:
label: Describe the bug
description: A clear description of what the bug is.
- type: textarea
validations:
required: true
attributes:
label: Steps to reproduce
description: |
Steps to reproduce the problem.
placeholder: |
For example:
1. Enable plugin '...'
2. Run command '...' or try to complete command '...'
3. See error
- type: textarea
validations:
required: true
attributes:
label: Expected behavior
description: A brief description of what should happen.
- type: textarea
attributes:
label: Screenshots and recordings
description: |
If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/
- type: input
validations:
required: true
attributes:
label: OS / Linux distribution
placeholder: Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15...
- type: input
validations:
required: true
attributes:
label: Zsh version
description: Run `echo $ZSH_VERSION` to check.
placeholder: "5.6"
- type: input
validations:
required: true
attributes:
label: Oh My Zsh version
description: Run `omz version` to check.
placeholder: master (bf303965)
- type: input
validations:
required: true
attributes:
label: Terminal emulator
placeholder: iTerm2, GNOME Terminal, Terminal.app...
- type: dropdown
attributes:
label: If using WSL on Windows, which version of WSL
description: Run `wsl -l -v` to check.
options:
- WSL1
- WSL2
- type: textarea
attributes:
label: Additional context
description: Add any other context about the problem here. This can be themes, plugins, custom settings...

View file

@ -1,29 +0,0 @@
---
name: Feature request
about: Suggest a feature for Oh My Zsh
labels: 'Feature'
---
<!--
Fill this out before posting. You can delete irrelevant sections, but
an issue where no sections have been filled will be deleted without comment.
-->
**Is your feature request related to a particular plugin or theme? If so, specify it.**
The name of the plugin, theme or alias that you would like us to improve. [...]
**Is your feature request related to a problem? Please describe.**
A description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A description of what you want to happen. [...]
**Describe alternatives you've considered**
A description of any alternative solutions or features you've considered. This can also include other plugins or themes.
**Additional context**
Add any other context, screenshots or discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at.
**Related Issues**
Is there any open or closed issues that is related to this feature request? If so please link them below! [...]

View file

@ -0,0 +1,37 @@
name: Feature request
description: Suggest a feature for Oh My Zsh
labels: ["Feature"]
body:
- type: markdown
attributes:
value: |
## Self Check
- Look for similar features in existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed).
- type: input
attributes:
label: If the feature request is for a plugin or theme, specify it here.
description: The name of the plugin or theme that you would like us to improve.
placeholder: e.g. Git plugin, Agnoster theme
- type: textarea
attributes:
label: If the feature solves a problem you have, specify it here.
description: A description of what the problem is.
placeholder: Ex. I'm always frustrated when...
- type: textarea
attributes:
label: Describe the proposed feature.
description: A description of what you want to happen. Be as specific as possible.
validations:
required: true
- type: textarea
attributes:
label: Describe alternatives you've considered
description: A description of any alternative solutions or features you've considered. This can also include other plugins or themes.
- type: textarea
attributes:
label: Additional context
description: Add any other context, screenshots or Discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at.
- type: textarea
attributes:
label: Related Issues
description: Is there any open or closed issues that is related to this feature request? If so please link them below!

View file

@ -10,10 +10,15 @@ on:
branches: branches:
- master - master
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs: jobs:
tests: tests:
name: Run tests name: Run tests
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
if: github.repository == 'ohmyzsh/ohmyzsh'
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest]

135
.github/workflows/project.yml vendored Normal file
View file

@ -0,0 +1,135 @@
name: Project tracking
on:
issues:
types: [opened, reopened]
pull_request_target:
types: [opened, reopened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
add-to-project:
name: Add to project
runs-on: ubuntu-latest
if: github.repository == 'ohmyzsh/ohmyzsh'
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }}
steps:
- name: Read project data
env:
ORGANIZATION: ohmyzsh
PROJECT_NUMBER: "1"
run: |
# Get Project data
gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectNext(number: $number) {
id
fields(first:20) {
nodes {
id
name
}
}
}
}
}
' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
# Parse project data
cat >> $GITHUB_ENV <<EOF
PROJECT_ID=$(jq '.data.organization.projectNext.id' project_data.json)
PLUGIN_FIELD_ID=$(jq '.data.organization.projectNext.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json)
THEME_FIELD_ID=$(jq '.data.organization.projectNext.fields.nodes[] | select(.name == "Theme") | .id' project_data.json)
EOF
- name: Add to project
env:
ISSUE_OR_PR_ID: ${{ github.event.issue.node_id || github.event.pull_request.node_id }}
run: |
item_id="$(gh api graphql -f query='
mutation($project: ID!, $content: ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $content}) {
projectNextItem {
id
}
}
}
' -f project=$PROJECT_ID -f content=$ISSUE_OR_PR_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
echo "ITEM_ID=$item_id" >> $GITHUB_ENV
- name: Classify Pull Request
if: github.event_name == 'pull_request_target'
run: |
touch plugins.list themes.list
gh pr view ${{ github.event.pull_request.number }} \
--repo ${{ github.repository }} \
--json files --jq '.files.[].path' | awk -F/ '
/^plugins\// {
plugins[$2] = 1
}
/^themes\// {
gsub(/\.zsh-theme$/, "", $2)
themes[$2] = 1
}
END {
for (plugin in plugins) {
print plugin >> "plugins.list"
}
for (theme in themes) {
print theme >> "themes.list"
}
}
'
# If only one plugin is modified, add it to the plugin field
if [[ $(wc -l < plugins.list) = 1 ]]; then
echo "PLUGIN=$(cat plugins.list)" >> $GITHUB_ENV
fi
# If only one theme is modified, add it to the theme field
if [[ $(wc -l < themes.list) = 1 ]]; then
echo "THEME=$(cat themes.list)" >> $GITHUB_ENV
fi
- name: Fill Pull Request fields in project
if: github.event_name == 'pull_request_target'
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$plugin_field: ID!
$plugin_value: String!
$theme_field: ID!
$theme_value: String!
) {
set_plugin: updateProjectNextItemField(input: {
projectId: $project
itemId: $item
fieldId: $plugin_field
value: $plugin_value
}) {
projectNextItem {
id
}
}
set_theme: updateProjectNextItemField(input: {
projectId: $project
itemId: $item
fieldId: $theme_field
value: $theme_value
}) {
projectNextItem {
id
}
}
}
' -f project=$PROJECT_ID -f item=$ITEM_ID \
-f plugin_field=$PLUGIN_FIELD_ID -f plugin_value=$PLUGIN \
-f theme_field=$THEME_FIELD_ID -f theme_value=$THEME \
--silent

View file

@ -0,0 +1,515 @@
function zsh_stats() {
fc -l 1 \
| awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
| grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl
}
function uninstall_oh_my_zsh() {
env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
}
function upgrade_oh_my_zsh() {
echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
omz update
}
function takedir() {
mkdir -p $@ && cd ${@:$#}
}
function open_command() {
local open_cmd
# define the open command
case "$OSTYPE" in
darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;;
linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
open_cmd='cmd.exe /c start ""'
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
} ;;
msys*) open_cmd='start ""' ;;
*) echo "Platform $OSTYPE not supported"
return 1
;;
esac
${=open_cmd} "$@" &>/dev/null
}
function takeurl() {
data=$(mktemp)
curl -L $1 > $data
tar xf $data
thedir=$(tar tf $data | head -1)
rm $data
cd $thedir
}
function takegit() {
git clone $1
cd $(basename ${1%%.git})
}
function take() {
if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then
takeurl $1
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
takegit $1
else
takedir $1
fi
}
#
# Get the value of an alias.
#
# Arguments:
# 1. alias - The alias to get its value from
# STDOUT:
# The value of alias $1 (if it has one).
# Return value:
# 0 if the alias was found,
# 1 if it does not exist
#
function alias_value() {
(( $+aliases[$1] )) && echo $aliases[$1]
}
#
# Try to get the value of an alias,
# otherwise return the input.
#
# Arguments:
# 1. alias - The alias to get its value from
# STDOUT:
# The value of alias $1, or $1 if there is no alias $1.
# Return value:
# Always 0
#
function try_alias_value() {
alias_value "$1" || echo "$1"
}
#
# Set variable "$1" to default value "$2" if "$1" is not yet defined.
#
# Arguments:
# 1. name - The variable to set
# 2. val - The default value
# Return value:
# 0 if the variable exists, 3 if it was set
#
function default() {
(( $+parameters[$1] )) && return 0
typeset -g "$1"="$2" && return 3
}
#
# Set environment variable "$1" to default value "$2" if "$1" is not yet defined.
#
# Arguments:
# 1. name - The env variable to set
# 2. val - The default value
# Return value:
# 0 if the env variable exists, 3 if it was set
#
function env_default() {
[[ ${parameters[$1]} = *-export* ]] && return 0
export "$1=$2" && return 3
}
# Required for $langinfo
zmodload zsh/langinfo
# URL-encode a string
#
# Encodes a string using RFC 2396 URL-encoding (%-escaped).
# See: https://www.ietf.org/rfc/rfc2396.txt
#
# By default, reserved characters and unreserved "mark" characters are
# not escaped by this function. This allows the common usage of passing
# an entire URL in, and encoding just special characters in it, with
# the expectation that reserved and mark characters are used appropriately.
# The -r and -m options turn on escaping of the reserved and mark characters,
# respectively, which allows arbitrary strings to be fully escaped for
# embedding inside URLs, where reserved characters might be misinterpreted.
#
# Prints the encoded string on stdout.
# Returns nonzero if encoding failed.
#
# Usage:
# omz_urlencode [-r] [-m] [-P] <string>
#
# -r causes reserved characters (;/?:@&=+$,) to be escaped
#
# -m causes "mark" characters (_.!~*''()-) to be escaped
#
# -P causes spaces to be encoded as '%20' instead of '+'
function omz_urlencode() {
emulate -L zsh
local -a opts
zparseopts -D -E -a opts r m P
local in_str=$1
local url_str=""
local spaces_as_plus
if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi
local str="$in_str"
# URLs must use UTF-8 encoding; convert str to UTF-8 if required
local encoding=$langinfo[CODESET]
local safe_encodings
safe_encodings=(UTF-8 utf8 US-ASCII)
if [[ -z ${safe_encodings[(r)$encoding]} ]]; then
str=$(echo -E "$str" | iconv -f $encoding -t UTF-8)
if [[ $? != 0 ]]; then
echo "Error converting string from $encoding to UTF-8" >&2
return 1
fi
fi
# Use LC_CTYPE=C to process text byte-by-byte
local i byte ord LC_ALL=C
export LC_ALL
local reserved=';/?:@&=+$,'
local mark='_.!~*''()-'
local dont_escape="[A-Za-z0-9"
if [[ -z $opts[(r)-r] ]]; then
dont_escape+=$reserved
fi
# $mark must be last because of the "-"
if [[ -z $opts[(r)-m] ]]; then
dont_escape+=$mark
fi
dont_escape+="]"
# Implemented to use a single printf call and avoid subshells in the loop,
# for performance (primarily on Windows).
local url_str=""
for (( i = 1; i <= ${#str}; ++i )); do
byte="$str[i]"
if [[ "$byte" =~ "$dont_escape" ]]; then
url_str+="$byte"
else
if [[ "$byte" == " " && -n $spaces_as_plus ]]; then
url_str+="+"
else
ord=$(( [##16] #byte ))
url_str+="%$ord"
fi
fi
done
echo -E "$url_str"
}
# URL-decode a string
#
# Decodes a RFC 2396 URL-encoded (%-escaped) string.
# This decodes the '+' and '%' escapes in the input string, and leaves
# other characters unchanged. Does not enforce that the input is a
# valid URL-encoded string. This is a convenience to allow callers to
# pass in a full URL or similar strings and decode them for human
# presentation.
#
# Outputs the encoded string on stdout.
# Returns nonzero if encoding failed.
#
# Usage:
# omz_urldecode <urlstring> - prints decoded string followed by a newline
function omz_urldecode {
emulate -L zsh
local encoded_url=$1
# Work bytewise, since URLs escape UTF-8 octets
local caller_encoding=$langinfo[CODESET]
local LC_ALL=C
export LC_ALL
# Change + back to ' '
local tmp=${encoded_url:gs/+/ /}
# Protect other escapes to pass through the printf unchanged
tmp=${tmp:gs/\\/\\\\/}
# Handle %-escapes by turning them into `\xXX` printf escapes
tmp=${tmp:gs/%/\\x/}
local decoded
eval "decoded=\$'$tmp'"
# Now we have a UTF-8 encoded string in the variable. We need to re-encode
# it if caller is in a non-UTF-8 locale.
local safe_encodings
safe_encodings=(UTF-8 utf8 US-ASCII)
if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then
decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding)
if [[ $? != 0 ]]; then
echo "Error converting string from UTF-8 to $caller_encoding" >&2
return 1
fi
fi
echo -E "$decoded"
}
##################################
# PSK Functions
##################################
# PSK List directories only
lsd() {
l | grep -E "^d"
}
# ls grep
lsg() {
l | grep -iE "$1"
}
# the ol' gfind. Doesn't take a file pattern.
function gfind-all() {
# fd -H -t f . -x grep --color=always -Hi ${1}
# Gah. Bye-bye gfind, here's an off-the-shelf improvement upon it https://github.com/burntsushi/ripgrep
# $1 is search term, $2 is path
# rg --no-ignore --hidden "$@"
# even better is ag / silver searcher https://github.com/ggreer/the_silver_searcher
ag -a --pager less "$@"
}
# the ol' gfind. Doesn't take a file pattern.
function gfind() {
# fd -t f . -x grep --color=always -Hi ${1}
ag --pager less "$@"
}
# Print out the matches only
function gfindf() {
# TODO make this a lot less shit e.g. don't search .git . Surely rg has
# the ability to do this.
find . -type f -exec grep --color=always -Hil $1 {} \;
}
function heroic-repo-configure() {
cp ${HOME}/src/spotify/prism-tools/heroic-test.yml ./heroic-guc.yml
cp ${HOME}/src/spotify/prism-tools/heroic-api-gae.yml ./heroic-gae.yml
ls -l | grep -E 'heroic.*yml|heroic.*yaml'
mkdir logs
}
# function h() {
# NUM_LINES = ${1:-1000}
# history | tail -n $NUM_LINES
# }
# function h() {
# set -x
# NUM_LINES = ${1:-25}
# \history -${NUM_LINES}
# }
function agl() {
ag --pager less "$@"
}
function kill-em-all() {
NAME=$1
echo "Attempting to kill $NAME by arg match..."
pkill -fli $1
echo "Attempting to kill $NAME by binary match..."
pkill -li $1
echo "...the killing... is done"
}
function dateline() {
echo ""
date
echo ""
}
function clean-slate() {
clear
dateline
}
alias clr=clean-slate
alias cls=clean-slate
function psgr() {
ps auwwwwx | grep -v 'grep ' | grep -E "%CPU|$1"
}
function edit() {
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code $1
}
function zshrc() {
pushd ~/.oh-my-zsh
edit .
popd
}
function dir-sizes() {
du -sh ./* | sort -h
}
function ssh-ds718() {
ssh -p 658 pskadmin@192.168.2.7
}
alias git-stash-list-all='gitk `git stash list --pretty=format:%gd`'
function master-show-protection() {
git branch -vv | grep "origin/`git branch --show-current`"
}
function git-show-branch() {
git branch -vv | grep `git branch --show-current`
}
function git-show-all-stashes() {
echo "Hit 'q' to go to next file"
echo ""
git stash list | awk -F: '{ print "\n\n\n\n"; print $0; print "\n\n"; system("git stash show -p " $1); }'
}
# kill most recent container instance
alias docker-kill-latest='docker ps -l --format='{{.Names}}' | xargs docker kill'
# stop all containers
docker-stop-all-containers () {
docker container stop -t 2 $(docker container ls -q) 2>/dev/null
}
function find-gig-files() {
find . -size +1G -ls | sort -k7n # Find files larger than 1GB and then order the list by the file size
}
function _start-cloud-storage() {
bgnotify "Booting cloud sync apps..."
cd /Applications
open Dropbox.app 2>/dev/null &
open Google\ Drive.app 2>/dev/null &
# Don't do this cos it downloads my backed up photos
# open "Google Drive File Stream.app" 2>/dev/null &
cd -
}
function start-cloud-storage() {
(
bgnotify "Waiting for local unison sync..."
/Users/peter/dotfiles_psk/bin/unison-cron-job.sh
sleep 7
_start-cloud-storage
) &
}
# Out of action - needs work
# function tree() {
# DIR=$1 ;
# shift # pops $1 off
# /usr/local/homebrew/bin/tree -a $DIR | colorize_less "$@"
# }
function _open-all-chrome-apps() {
for APP in "${1}"/*.app; do
echo "Opening $APP ..."
nohup open -a "$APP" &
done
}
function open-all-chrome-apps() {
CHROME_APP_DIR='/Users/peter/Dropbox (Personal)/_Settings/Chrome Apps/Chrome Apps.localized/'
_open-all-chrome-apps "$CHROME_APP_DIR"
CHROME_APP_DIR='/Users/peter/Dropbox (Personal)/_Settings/Chrome/Chrome Apps/Chrome Apps.localized/'
_open-all-chrome-apps "$CHROME_APP_DIR"
}
function post-boot-tasks() {
open-all-chrome-apps
docker-stop-all
}
function kill-cloud-storage() {
# TODO investigate pkill as alternative
# Don't do this cos it downloads my backed up photos
# killall "Google Drive File Stream" 2>/dev/null &
killall Dropbox 2>/dev/null &
killall "Google Drive" 2>/dev/null &
killall -v "FinderSyncExtension" -SIGKILL &
}
# For photos, pictures, DS718
function organise-into-dated-dirs() {
if [ $# -eq 0 ]
then
echo "Please supply an extension e.g. mov or mp4"
return
fi
for x in *.${1}; do
d=$(date -r "$x" +%Y-%m-%d)
mkdir -p "$d"
mv -- "$x" "$d/"
done
}
### peco functions ###
function peco-directories() {
local current_lbuffer="$LBUFFER"
local current_rbuffer="$RBUFFER"
if command -v fd >/dev/null 2>&1; then
local dir="$(command \fd --type directory --hidden --no-ignore --exclude .git/ --color never 2>/dev/null | peco )"
else
local dir="$(
command find \( -path '*/\.*' -o -fstype dev -o -fstype proc \) -type d -print 2>/dev/null \
| sed 1d \
| cut -b3- \
| awk '{a[length($0)" "NR]=$0}END{PROCINFO["sorted_in"]="@ind_num_asc"; for(i in a) print a[i]}' - \
| peco
)"
fi
if [ -n "$dir" ]; then
dir=$(echo "$dir" | tr -d '\n')
dir=$(printf %q "$dir")
# echo "PSK ${dir}"
BUFFER="${current_lbuffer}${file}${current_rbuffer}"
CURSOR=$#BUFFER
fi
}
function peco-files() {
local current_lbuffer="$LBUFFER"
local current_rbuffer="$RBUFFER"
if command -v fd >/dev/null 2>&1; then
local file="$(command \fd --type file --hidden --no-ignore --exclude .git/ --color never 2>/dev/null | peco)"
elif command -v rg >/dev/null 2>&1; then
local file="$(rg --glob "" --files --hidden --no-ignore-vcs --iglob !.git/ --color never 2>/dev/null | peco)"
elif command -v ag >/dev/null 2>&1; then
local file="$(ag --files-with-matches --unrestricted --skip-vcs-ignores --ignore .git/ --nocolor -g "" 2>/dev/null | peco)"
else
local file="$(
command find \( -path '*/\.*' -o -fstype dev -o -fstype proc \) -type f -print 2> /dev/null \
| sed 1d \
| cut -b3- \
| awk '{a[length($0)" "NR]=$0}END{PROCINFO["sorted_in"]="@ind_num_asc"; for(i in a) print a[i]}' - \
| peco
)"
fi
if [ -n "$file" ]; then
file=$(echo "$file" | tr -d '\n')
file=$(printf %q "$file")
BUFFER="${current_lbuffer}${file}${current_rbuffer}"
CURSOR=$#BUFFER
fi
}
zle -N peco-directories
bindkey '^Xf' peco-directories
zle -N peco-files
bindkey '^X^f' peco-files
### peco functions ###

View file

@ -0,0 +1,515 @@
function zsh_stats() {
fc -l 1 \
| awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
| grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl
}
function uninstall_oh_my_zsh() {
env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
}
function upgrade_oh_my_zsh() {
echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
omz update
}
function takedir() {
mkdir -p $@ && cd ${@:$#}
}
function open_command() {
local open_cmd
# define the open command
case "$OSTYPE" in
darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;;
linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
open_cmd='cmd.exe /c start ""'
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
} ;;
msys*) open_cmd='start ""' ;;
*) echo "Platform $OSTYPE not supported"
return 1
;;
esac
${=open_cmd} "$@" &>/dev/null
}
function takeurl() {
data=$(mktemp)
curl -L $1 > $data
tar xf $data
thedir=$(tar tf $data | head -1)
rm $data
cd $thedir
}
function takegit() {
git clone $1
cd $(basename ${1%%.git})
}
function take() {
if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then
takeurl $1
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
takegit $1
else
takedir $1
fi
}
#
# Get the value of an alias.
#
# Arguments:
# 1. alias - The alias to get its value from
# STDOUT:
# The value of alias $1 (if it has one).
# Return value:
# 0 if the alias was found,
# 1 if it does not exist
#
function alias_value() {
(( $+aliases[$1] )) && echo $aliases[$1]
}
#
# Try to get the value of an alias,
# otherwise return the input.
#
# Arguments:
# 1. alias - The alias to get its value from
# STDOUT:
# The value of alias $1, or $1 if there is no alias $1.
# Return value:
# Always 0
#
function try_alias_value() {
alias_value "$1" || echo "$1"
}
#
# Set variable "$1" to default value "$2" if "$1" is not yet defined.
#
# Arguments:
# 1. name - The variable to set
# 2. val - The default value
# Return value:
# 0 if the variable exists, 3 if it was set
#
function default() {
(( $+parameters[$1] )) && return 0
typeset -g "$1"="$2" && return 3
}
#
# Set environment variable "$1" to default value "$2" if "$1" is not yet defined.
#
# Arguments:
# 1. name - The env variable to set
# 2. val - The default value
# Return value:
# 0 if the env variable exists, 3 if it was set
#
function env_default() {
[[ ${parameters[$1]} = *-export* ]] && return 0
export "$1=$2" && return 3
}
# Required for $langinfo
zmodload zsh/langinfo
# URL-encode a string
#
# Encodes a string using RFC 2396 URL-encoding (%-escaped).
# See: https://www.ietf.org/rfc/rfc2396.txt
#
# By default, reserved characters and unreserved "mark" characters are
# not escaped by this function. This allows the common usage of passing
# an entire URL in, and encoding just special characters in it, with
# the expectation that reserved and mark characters are used appropriately.
# The -r and -m options turn on escaping of the reserved and mark characters,
# respectively, which allows arbitrary strings to be fully escaped for
# embedding inside URLs, where reserved characters might be misinterpreted.
#
# Prints the encoded string on stdout.
# Returns nonzero if encoding failed.
#
# Usage:
# omz_urlencode [-r] [-m] [-P] <string>
#
# -r causes reserved characters (;/?:@&=+$,) to be escaped
#
# -m causes "mark" characters (_.!~*''()-) to be escaped
#
# -P causes spaces to be encoded as '%20' instead of '+'
function omz_urlencode() {
emulate -L zsh
local -a opts
zparseopts -D -E -a opts r m P
local in_str=$1
local url_str=""
local spaces_as_plus
if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi
local str="$in_str"
# URLs must use UTF-8 encoding; convert str to UTF-8 if required
local encoding=$langinfo[CODESET]
local safe_encodings
safe_encodings=(UTF-8 utf8 US-ASCII)
if [[ -z ${safe_encodings[(r)$encoding]} ]]; then
str=$(echo -E "$str" | iconv -f $encoding -t UTF-8)
if [[ $? != 0 ]]; then
echo "Error converting string from $encoding to UTF-8" >&2
return 1
fi
fi
# Use LC_CTYPE=C to process text byte-by-byte
local i byte ord LC_ALL=C
export LC_ALL
local reserved=';/?:@&=+$,'
local mark='_.!~*''()-'
local dont_escape="[A-Za-z0-9"
if [[ -z $opts[(r)-r] ]]; then
dont_escape+=$reserved
fi
# $mark must be last because of the "-"
if [[ -z $opts[(r)-m] ]]; then
dont_escape+=$mark
fi
dont_escape+="]"
# Implemented to use a single printf call and avoid subshells in the loop,
# for performance (primarily on Windows).
local url_str=""
for (( i = 1; i <= ${#str}; ++i )); do
byte="$str[i]"
if [[ "$byte" =~ "$dont_escape" ]]; then
url_str+="$byte"
else
if [[ "$byte" == " " && -n $spaces_as_plus ]]; then
url_str+="+"
else
ord=$(( [##16] #byte ))
url_str+="%$ord"
fi
fi
done
echo -E "$url_str"
}
# URL-decode a string
#
# Decodes a RFC 2396 URL-encoded (%-escaped) string.
# This decodes the '+' and '%' escapes in the input string, and leaves
# other characters unchanged. Does not enforce that the input is a
# valid URL-encoded string. This is a convenience to allow callers to
# pass in a full URL or similar strings and decode them for human
# presentation.
#
# Outputs the encoded string on stdout.
# Returns nonzero if encoding failed.
#
# Usage:
# omz_urldecode <urlstring> - prints decoded string followed by a newline
function omz_urldecode {
emulate -L zsh
local encoded_url=$1
# Work bytewise, since URLs escape UTF-8 octets
local caller_encoding=$langinfo[CODESET]
local LC_ALL=C
export LC_ALL
# Change + back to ' '
local tmp=${encoded_url:gs/+/ /}
# Protect other escapes to pass through the printf unchanged
tmp=${tmp:gs/\\/\\\\/}
# Handle %-escapes by turning them into `\xXX` printf escapes
tmp=${tmp:gs/%/\\x/}
local decoded
eval "decoded=\$'$tmp'"
# Now we have a UTF-8 encoded string in the variable. We need to re-encode
# it if caller is in a non-UTF-8 locale.
local safe_encodings
safe_encodings=(UTF-8 utf8 US-ASCII)
if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then
decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding)
if [[ $? != 0 ]]; then
echo "Error converting string from UTF-8 to $caller_encoding" >&2
return 1
fi
fi
echo -E "$decoded"
}
##################################
# PSK Functions
##################################
# PSK List directories only
lsd() {
l | grep -E "^d"
}
# ls grep
lsg() {
l | grep -iE "$1"
}
# the ol' gfind. Doesn't take a file pattern.
function gfind-all() {
# fd -H -t f . -x grep --color=always -Hi ${1}
# Gah. Bye-bye gfind, here's an off-the-shelf improvement upon it https://github.com/burntsushi/ripgrep
# $1 is search term, $2 is path
# rg --no-ignore --hidden "$@"
# even better is ag / silver searcher https://github.com/ggreer/the_silver_searcher
ag -a --pager less "$@"
}
# the ol' gfind. Doesn't take a file pattern.
function gfind() {
# fd -t f . -x grep --color=always -Hi ${1}
ag --pager less "$@"
}
# Print out the matches only
function gfindf() {
# TODO make this a lot less shit e.g. don't search .git . Surely rg has
# the ability to do this.
find . -type f -exec grep --color=always -Hil $1 {} \;
}
function heroic-repo-configure() {
cp ${HOME}/src/spotify/prism-tools/heroic-test.yml ./heroic-guc.yml
cp ${HOME}/src/spotify/prism-tools/heroic-api-gae.yml ./heroic-gae.yml
ls -l | grep -E 'heroic.*yml|heroic.*yaml'
mkdir logs
}
# function h() {
# NUM_LINES = ${1:-1000}
# history | tail -n $NUM_LINES
# }
# function h() {
# set -x
# NUM_LINES = ${1:-25}
# \history -${NUM_LINES}
# }
function agl() {
ag --pager less "$@"
}
function kill-em-all() {
NAME=$1
echo "Attempting to kill $NAME by arg match..."
pkill -fli $1
echo "Attempting to kill $NAME by binary match..."
pkill -li $1
echo "...the killing... is done"
}
function dateline() {
echo ""
date
echo ""
}
function clean-slate() {
clear
dateline
}
alias clr=clean-slate
alias cls=clean-slate
function psgr() {
ps auwwwwx | grep -v 'grep ' | grep -E "%CPU|$1"
}
function edit() {
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code $1
}
function zshrc() {
pushd ~/.oh-my-zsh
edit .
popd
}
function dir-sizes() {
du -sh ./* | sort -h
}
function ssh-ds718() {
ssh -p 658 pskadmin@192.168.2.7
}
alias git-stash-list-all='gitk `git stash list --pretty=format:%gd`'
function master-show-protection() {
git branch -vv | grep "origin/`git branch --show-current`"
}
function git-show-branch() {
git branch -vv | grep `git branch --show-current`
}
function git-show-all-stashes() {
echo "Hit 'q' to go to next file"
echo ""
git stash list | awk -F: '{ print "\n\n\n\n"; print $0; print "\n\n"; system("git stash show -p " $1); }'
}
# kill most recent container instance
alias docker-kill-latest='docker ps -l --format='{{.Names}}' | xargs docker kill'
# stop all containers
docker-stop-all-containers () {
docker container stop -t 2 $(docker container ls -q) 2>/dev/null
}
function find-gig-files() {
find . -size +1G -ls | sort -k7n # Find files larger than 1GB and then order the list by the file size
}
function _start-cloud-storage() {
bgnotify "Booting cloud sync apps..."
cd /Applications
open Dropbox.app 2>/dev/null &
open Google\ Drive.app 2>/dev/null &
# Don't do this cos it downloads my backed up photos
# open "Google Drive File Stream.app" 2>/dev/null &
cd -
}
function start-cloud-storage() {
(
bgnotify "Waiting for local unison sync..."
/Users/peter/dotfiles_psk/bin/unison-cron-job.sh
sleep 7
_start-cloud-storage
) &
}
# Out of action - needs work
# function tree() {
# DIR=$1 ;
# shift # pops $1 off
# /usr/local/homebrew/bin/tree -a $DIR | colorize_less "$@"
# }
function _open-all-chrome-apps() {
for APP in "${1}"/*.app; do
echo "Opening $APP ..."
nohup open -a "$APP" &
done
}
function open-all-chrome-apps() {
CHROME_APP_DIR='/Users/peter/Dropbox (Personal)/_Settings/Chrome Apps/Chrome Apps.localized/'
_open-all-chrome-apps "$CHROME_APP_DIR"
CHROME_APP_DIR='/Users/peter/Dropbox (Personal)/_Settings/Chrome/Chrome Apps/Chrome Apps.localized/'
_open-all-chrome-apps "$CHROME_APP_DIR"
}
function post-boot-tasks() {
open-all-chrome-apps
docker-stop-all
}
function kill-cloud-storage() {
# TODO investigate pkill as alternative
# Don't do this cos it downloads my backed up photos
# killall "Google Drive File Stream" 2>/dev/null &
killall Dropbox 2>/dev/null &
killall "Google Drive" 2>/dev/null &
killall -v "FinderSyncExtension" -SIGKILL &
}
# For photos, pictures, DS718
function organise-into-dated-dirs() {
if [ $# -eq 0 ]
then
echo "Please supply an extension e.g. mov or mp4"
return
fi
for x in *.${1}; do
d=$(date -r "$x" +%Y-%m-%d)
mkdir -p "$d"
mv -- "$x" "$d/"
done
}
### peco functions ###
function peco-directories() {
local current_lbuffer="$LBUFFER"
local current_rbuffer="$RBUFFER"
if command -v fd >/dev/null 2>&1; then
local dir="$(command \fd --type directory --hidden --no-ignore --exclude .git/ --color never 2>/dev/null | peco )"
else
local dir="$(
command find \( -path '*/\.*' -o -fstype dev -o -fstype proc \) -type d -print 2>/dev/null \
| sed 1d \
| cut -b3- \
| awk '{a[length($0)" "NR]=$0}END{PROCINFO["sorted_in"]="@ind_num_asc"; for(i in a) print a[i]}' - \
| peco
)"
fi
if [ -n "$dir" ]; then
dir=$(echo "$dir" | tr -d '\n')
dir=$(printf %q "$dir")
# echo "PSK ${dir}"
BUFFER="${current_lbuffer}${file}${current_rbuffer}"
CURSOR=$#BUFFER
fi
}
function peco-files() {
local current_lbuffer="$LBUFFER"
local current_rbuffer="$RBUFFER"
if command -v fd >/dev/null 2>&1; then
local file="$(command \fd --type file --hidden --no-ignore --exclude .git/ --color never 2>/dev/null | peco)"
elif command -v rg >/dev/null 2>&1; then
local file="$(rg --glob "" --files --hidden --no-ignore-vcs --iglob !.git/ --color never 2>/dev/null | peco)"
elif command -v ag >/dev/null 2>&1; then
local file="$(ag --files-with-matches --unrestricted --skip-vcs-ignores --ignore .git/ --nocolor -g "" 2>/dev/null | peco)"
else
local file="$(
command find \( -path '*/\.*' -o -fstype dev -o -fstype proc \) -type f -print 2> /dev/null \
| sed 1d \
| cut -b3- \
| awk '{a[length($0)" "NR]=$0}END{PROCINFO["sorted_in"]="@ind_num_asc"; for(i in a) print a[i]}' - \
| peco
)"
fi
if [ -n "$file" ]; then
file=$(echo "$file" | tr -d '\n')
file=$(printf %q "$file")
BUFFER="${current_lbuffer}${file}${current_rbuffer}"
CURSOR=$#BUFFER
fi
}
zle -N peco-directories
bindkey '^Xf' peco-directories
zle -N peco-files
bindkey '^X^f' peco-files
### peco functions ###

1
.hyper.js Symbolic link
View file

@ -0,0 +1 @@
~/Library/Application Support/Hyper/.hyper.js

1
.p10k.zsh Symbolic link
View file

@ -0,0 +1 @@
/Users/peter/.p10k.zsh

1641
.p10k.zsh.bak Normal file

File diff suppressed because it is too large Load diff

1
.profile Symbolic link
View file

@ -0,0 +1 @@
../.profile

226
.tmux copy.conf Normal file
View file

@ -0,0 +1,226 @@
##########################
### from internets
##########################
# From https://github.com/eduncan911/dotfiles/blob/master/.tmux.conf
bind-key -n M-0 select-window -t 0
bind-key -n M-1 select-window -t 1
bind-key -n M-2 select-window -t 2
bind-key -n M-3 select-window -t 3
# macOS fix for clipboard, vim/nvim, tmux and iterm2 (yikes)
if-shell "uname | grep -q Darwin" "set -g default-shell $SHELL"
if-shell "uname | grep -q Darwin" "set -g default-command \"reattach-to-user-namespace -l ${SHELL}\""
# From https://superuser.com/a/552493/393361
bind-key -n C-S-Left swap-window -t -1\; select-window -t -1
bind-key -n C-S-Right swap-window -t +1\; select-window -t +1
# From https://superuser.com/questions/813661/how-to-configure-tmux-iterm-to-display-session-name-as-title-in-terminal-tab
set-option -g set-titles on
# from https://github.com/tmux-plugins/tmux-continuum/issues/30
set -g set-titles-string '#h ❐ #S ● #I #W'
set -g display-panes-time 800 # slightly longer pane indicators display time
set -g display-time 1000 # slightly longer status messages display time
# disable status bar - PSK - it's handy actually to tell if you're in tmux
# or not.
# set -g status off
# nifty way to hide pane and bring it back
bind-key ! break-pane -d -n _hidden_pane
bind-key @ join-pane -s $.1
##########################
### from https://github.com/thoughtbot/dotfiles/blob/master/tmux.conf
##########################
set -g default-terminal 'screen-256color'
# renumber windows sequentially after closing any of them
set -g renumber-windows on
# soften status bar color from harsh green to light gray
set -g status-style bg='#262626',fg='#a1cfd1'
# set status bg to grey from https://protechnotes.com/comprehensive-tmux-tutorial-for-beginners-with-a-cheat-sheet/
set -g status-bg colour236
# remove administrative debris (session name, hostname, time) in status bar
#set -g status-left ''
#set -g status-right ''
# increase scrollback lines
set -g history-limit 10000
# Local config
if-shell "[ -f ~/.tmux.conf.local ]" 'source ~/.tmux.conf.local'
##########################
# From https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/zsh-navigation-tools
##########################
bind h run-shell -b "~/.oh-my-zsh/plugins/zsh-navigation-tools/znt-tmux.zsh"
##########################
### From https://pragprog.com/titles/bhtmux2/tmux-2/
##########################
# Our .tmux.conf file
# Setting the prefix from C-b to C-s
set -g prefix C-s
# Free the original Ctrl-b prefix keybinding
unbind C-b
#setting the delay between prefix and command
set -s escape-time 1
# Ensure that we can send Ctrl-S to other apps
bind C-s send-prefix
set-option -g prefix2 C-b
# Set the base index for windows to 1 instead of 0
set -g base-index 1
# Set the base index for panes to 1 instead of 0
setw -g pane-base-index 1
##########################
# From https://www.hamvocke.com/blog/a-guide-to-customizing-your-tmux-conf/
##########################
# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# moving between panes with Prefix h,j,k,l
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Set the default terminal mode to 256color mode
set -g default-terminal "screen-256color"
# trying to stop tmux (tmux) being overwritten/corrupted
# commented out cos gives 'no current session'.
# set allow-rename off
# https://tmuxcheatsheet.com/tmux-plugins-tools/?full_name=tmux-plugins%2Ftmux-prefix-highlight
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_copy_mode_attr 'fg=black,bg=yellow,bold' # default is 'fg=default,bg=yellow'
set -g @prefix_highlight_show_sync_mode 'on'
set -g @prefix_highlight_sync_mode_attr 'fg=black,bg=green' # default is 'fg=default,bg=yellow'
# Center the window list in the status line
set -g status-justify centre
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf
# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
set-option -g mouse on
setw -g automatic-rename on # rename window to reflect current program
# renumber windows when a window is closed
set -g renumber-windows on
######################
### DESIGN CHANGES ###
######################
# loud or quiet?
set -g visual-activity off
set -g visual-bell off
set -g visual-silence off
setw -g monitor-activity off
set -g bell-action none
# modes
setw -g clock-mode-colour colour5
setw -g mode-style 'fg=colour1 bg=colour18 bold'
# panes
set -g pane-border-style 'fg=colour19 bg=colour0'
set -g pane-active-border-style 'bg=colour0 fg=colour9'
# ——————— Continuum ———————
# https://github.com/tmux-plugins/tmux-continuum
set -g @continuum-restore 'on'
set -g @continuum-boot 'on'
set -g @continuum-boot-options 'iterm'
# From https://github.com/tmux-plugins/tmux-continuum/issues/30
set -g @continuum-save-interval '1'
set -g @continuum-boot-options 'iterm,fullscreen'
run-shell ~/.tmux/plugins/tmux-continuum/continuum.tmux
# https://github.com/tmux-plugins/tmux-resurrect
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
# From https://github.com/tmux-plugins/tmux-continuum/blob/master/docs/automatic_start.md
set -g @plugin 'tmux-plugins/tmux-sidebar'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-open'
# ——————— Continuum ———————
# statusbar
set -g status-position bottom
set -g status-justify left
# Status line right side - 31-Oct 13:37
#set -g status-right "#[fg=cyan]%d %b %R"
setw -g window-status-current-style 'fg=colour1 bg=colour19 bold'
setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F '
#setw -g window-status-style 'fg=colour9 bg=colour18'
#setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
# setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold'
# Status line left side to show Session:window:pane
set -g status-left-length 40
set -g status-left "#{prefix_highlight} #[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
# Update the status line every sixty seconds
set -g status-interval 5
# messages
#set -g message-style 'fg=colour232 bg=colour16 bold'
# https://github.com/jonmosco/kube-tmux.git
# set -g status-right-length 80 # long enough for our long cluster names
# set -g status-right "#(/bin/bash $HOME/.tmux/kube-tmux/kube.tmux 250 red cyan)"
##########################
# PLUGINS
# From https://github.com/tmux-plugins/tpm
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'jimeh/tmux-themepack'
set -g @themepack 'powerline/block/blue'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
##########################

1
.zprofile Symbolic link
View file

@ -0,0 +1 @@
../.zprofile

View file

@ -47,7 +47,7 @@ It should include the data gathered as indicated above, along with:
2. What the correct behavior should be 2. What the correct behavior should be
3. What the actual behavior is 3. What the actual behavior is
Please copy to anyone relevant (_eg_ plugin maintainers) by mentioning their GitHub handle Please copy to anyone relevant (e.g. plugin maintainers) by mentioning their GitHub handle
(starting with `@`) in your message. (starting with `@`) in your message.
We will do our very best to help you. We will do our very best to help you.
@ -59,7 +59,7 @@ your suggestion.
If you find one, comment on it so we can know there are more people supporting it. If you find one, comment on it so we can know there are more people supporting it.
If not, you can go ahead and create an issue. Please copy to anyone relevant (_eg_ plugin If not, you can go ahead and create an issue. Please copy to anyone relevant (e.g. plugin
maintainers) by mentioning their GitHub handle (starting with `@`) in your message. maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
## Submitting Pull Requests ## Submitting Pull Requests
@ -99,10 +99,10 @@ covering or related to what you want to add.
If you find one, try it out and work with the author on a common solution. If you find one, try it out and work with the author on a common solution.
If not, then go ahead and submit a PR. Please copy to anyone relevant (_eg_ plugin If not, then go ahead and submit a PR. Please copy to anyone relevant (e.g. plugin
maintainers) by mentioning their GitHub handle (starting with `@`) in your message. maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
For any extensive change, _eg_ a new plugin, you will have to find testers to +1 your PR. For any extensive change, such as a new plugin, you will have to find testers to +1 your PR.
---- ----
@ -202,7 +202,7 @@ type(scope)!: subject
feat(archlinux): add support for aura AUR helper (#9467) feat(archlinux): add support for aura AUR helper (#9467)
``` ```
- Formatted inline code by using backticks: the text inbetween backticks will also be highlighted by - Formatted inline code by using backticks: the text between backticks will also be highlighted by
the changelog tool: the changelog tool:
``` ```
feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774) feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774)

View file

@ -1 +0,0 @@
../../IntelliJ-Shortcuts.md

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2009-2021 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors) Copyright (c) 2009-2022 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -0,0 +1,37 @@
# Path update for arm64 homebrew
/opt/homebrew/bin:
/Users/peter/perl5/bin:
/Users/peter/.jenv/bin:
/usr/local/homebrew/opt/python@3.9/bin:
/Users/peter/.autojump/bin:
/Users/peter/perl5/bin:
/Users/peter/.jenv/bin:
/usr/local/go1.17.1.darwin-amd64/bin:
/opt/homebrew/bin/:
/opt/local/bin:
/opt/local/sbin:
/Users/peter/.jenv/shims:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/usr/local/go/bin:
/opt/puppetlabs/bin:
/Users/peter/perl5/bin:
/Users/peter/.jenv/bin:
/Users/peter/bin:
/usr/libexec/:
/Users/peter/.krew/bin:
/usr/local/homebrew/opt/fzf/bin:
/Users/peter/.kube/plugins/jordanwilson230:
/Users/peter/bin/leetcode-cli:
/Users/peter/bin:
/opt/puppetlabs/bin:
# Removed the following amd64 homebrew paths:
/usr/local/homebrew/bin:
/usr/local/homebrew/opt/fzf/bin:
/usr/local/homebrew/opt/python@3.9/bin:
/usr/local/homebrew/opt/ruby/bin:
/usr/local/homebrew/sbin:

137
README.md
View file

@ -1,4 +1,4 @@
<p align="center"><img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"></p> <p align="center"><img src="https://ohmyzsh.s3.amazonaws.com/omz-ansi-github.png" alt="Oh My Zsh"></p>
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration. Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.
@ -16,6 +16,42 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh) [![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
[![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/ohmyzsh) [![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/ohmyzsh)
[![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh) [![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh)
[![huntr.dev](https://cdn.huntr.dev/huntr_security_badge_mono.svg)](https://huntr.dev/bounties/disclose/?utm_campaign=ohmyzsh%2Fohmyzsh&utm_medium=social&utm_source=github&target=https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh)
<details>
<summary>Table of Contents</summary>
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Basic Installation](#basic-installation)
- [Manual inspection](#manual-inspection)
- [Using Oh My Zsh](#using-oh-my-zsh)
- [Plugins](#plugins)
- [Enabling Plugins](#enabling-plugins)
- [Using Plugins](#using-plugins)
- [Themes](#themes)
- [Selecting a Theme](#selecting-a-theme)
- [FAQ](#faq)
- [Advanced Topics](#advanced-topics)
- [Advanced Installation](#advanced-installation)
- [Custom Directory](#custom-directory)
- [Unattended install](#unattended-install)
- [Installing from a forked repository](#installing-from-a-forked-repository)
- [Manual Installation](#manual-installation)
- [Installation Problems](#installation-problems)
- [Custom Plugins and Themes](#custom-plugins-and-themes)
- [Getting Updates](#getting-updates)
- [Manual Updates](#manual-updates)
- [Uninstalling Oh My Zsh](#uninstalling-oh-my-zsh)
- [How do I contribute to Oh My Zsh?](#how-do-i-contribute-to-oh-my-zsh)
- [Do NOT send us themes](#do-not-send-us-themes)
- [Contributors](#contributors)
- [Follow Us](#follow-us)
- [Merchandise](#merchandise)
- [License](#license)
- [About Planet Argon](#about-planet-argon)
</details>
## Getting Started ## Getting Started
@ -31,18 +67,20 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool. Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool.
| Method | Command | | Method | Command |
|:----------|:--------------------------------------------------------------------------------------------------| | :-------- | :------------------------------------------------------------------------------------------------ |
| **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | | **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
| **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | | **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
| **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | | **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
_Note that any previous `.zshrc` will be renamed to `.zshrc.pre-oh-my-zsh`. After installation, you can move the configuration you want to preserve into the new `.zshrc`._
#### Manual inspection #### Manual inspection
It's a good idea to inspect the install script from projects you don't yet know. You can do It's a good idea to inspect the install script from projects you don't yet know. You can do
that by downloading the install script first, looking through it so everything looks normal, that by downloading the install script first, looking through it so everything looks normal,
then running it: then running it:
```shell ```sh
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh sh install.sh
``` ```
@ -57,18 +95,18 @@ Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can
Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the `.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load. Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the `.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load.
```shell ```sh
vi ~/.zshrc vi ~/.zshrc
``` ```
For example, this might begin to look like this: For example, this might begin to look like this:
```shell ```sh
plugins=( plugins=(
git git
bundler bundler
dotenv dotenv
osx macos
rake rake
rbenv rbenv
ruby ruby
@ -79,7 +117,7 @@ _Note that the plugins are separated by whitespace (spaces, tabs, new lines...).
#### Using Plugins #### Using Plugins
Each plugin includes a __README__, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin. Each built-in plugin includes a **README**, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin.
### Themes ### Themes
@ -91,18 +129,18 @@ _Robby's theme is the default one. It's not the fanciest one. It's not the simpl
Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like: Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like:
```shell ```sh
ZSH_THEME="robbyrussell" ZSH_THEME="robbyrussell"
``` ```
To use a different theme, simply change the value to match the name of your desired theme. For example: To use a different theme, simply change the value to match the name of your desired theme. For example:
```shell ```sh
ZSH_THEME="agnoster" # (this is one of the fancy ones) ZSH_THEME="agnoster" # (this is one of the fancy ones)
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster # see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
``` ```
_Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._ _Note: many themes require installing a [Powerline Font](https://github.com/powerline/fonts) or a [Nerd Font](https://github.com/ryanoasis/nerd-fonts) in order to render properly. Without them, these themes will render [weird prompt symbols](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-have-a-weird-character-in-my-prompt)_
Open up a new terminal window and your prompt should look something like this: Open up a new terminal window and your prompt should look something like this:
@ -112,13 +150,13 @@ In case you did not find a suitable theme for your needs, please have a look at
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window. If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
```shell ```sh
ZSH_THEME="random" # (...please let it be pie... please be some pie..) ZSH_THEME="random" # (...please let it be pie... please be some pie..)
``` ```
And if you want to pick random theme from a list of your favorite themes: And if you want to pick random theme from a list of your favorite themes:
```shell ```sh
ZSH_THEME_RANDOM_CANDIDATES=( ZSH_THEME_RANDOM_CANDIDATES=(
"robbyrussell" "robbyrussell"
"agnoster" "agnoster"
@ -127,7 +165,7 @@ ZSH_THEME_RANDOM_CANDIDATES=(
If you only know which themes you don't like, you can add them similarly to an ignored list: If you only know which themes you don't like, you can add them similarly to an ignored list:
```shell ```sh
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod) ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
``` ```
@ -152,17 +190,17 @@ If you'd like to change the install directory with the `ZSH` environment variabl
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
like this: like this:
```shell ```sh
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
``` ```
#### Unattended install #### Unattended install
If you're running the Oh My Zsh install script as part of an automated install, you can pass the If you're running the Oh My Zsh install script as part of an automated install, you can pass the `--unattended`
flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change flag to the `install.sh` script. This will have the effect of not trying to change
the default shell, and also won't run `zsh` when the installation has finished. the default shell, and it also won't run `zsh` when the installation has finished.
```shell ```sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
``` ```
@ -185,41 +223,41 @@ The install script also accepts these variables to allow installation of a diffe
For example: For example:
```shell ```sh
REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
``` ```
#### Manual Installation #### Manual Installation
##### 1. Clone the repository ##### 1. Clone the repository <!-- omit in toc -->
```shell ```sh
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
``` ```
##### 2. *Optionally*, backup your existing `~/.zshrc` file ##### 2. _Optionally_, backup your existing `~/.zshrc` file <!-- omit in toc -->
```shell ```sh
cp ~/.zshrc ~/.zshrc.orig cp ~/.zshrc ~/.zshrc.orig
``` ```
##### 3. Create a new zsh configuration file ##### 3. Create a new zsh configuration file <!-- omit in toc -->
You can create a new zsh config file by copying the template that we have included for you. You can create a new zsh config file by copying the template that we have included for you.
```shell ```sh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
``` ```
##### 4. Change your default shell ##### 4. Change your default shell <!-- omit in toc -->
```shell ```sh
chsh -s $(which zsh) chsh -s $(which zsh)
``` ```
You must log out from your user session and log back in to see this change. You must log out from your user session and log back in to see this change.
##### 5. Initialize your new zsh configuration ##### 5. Initialize your new zsh configuration <!-- omit in toc -->
Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration. Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
@ -227,10 +265,8 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
If you have any hiccups installing, here are a few common fixes. If you have any hiccups installing, here are a few common fixes.
- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after - You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
switching to `oh-my-zsh`. - If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
- If you installed manually or changed the install location, check the `ZSH` environment variable in
`~/.zshrc`.
### Custom Plugins and Themes ### Custom Plugins and Themes
@ -242,23 +278,40 @@ If you would like to override the functionality of a plugin distributed with Oh
## Getting Updates ## Getting Updates
By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`: By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**:
```shell 1. Automatic update without confirmation prompt:
DISABLE_UPDATE_PROMPT=true
```
To disable automatic upgrades, set the following in your `~/.zshrc`: ```sh
zstyle ':omz:update' mode auto
```
```shell 2. Just offer a reminder every few days, if there are updates available:
DISABLE_AUTO_UPDATE=true
```sh
zstyle ':omz:update' mode reminder
```
3. To disable automatic updates entirely:
```sh
zstyle ':omz:update' mode disabled
```
NOTE: you can control how often Oh My Zsh checks for updates with the following setting:
```sh
# This will check for updates every 7 days
zstyle ':omz:update' frequency 7
# This will check for updates every time you open the terminal (not recommended)
zstyle ':omz:update' frequency 0
``` ```
### Manual Updates ### Manual Updates
If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run: If you'd like to update at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
```shell ```sh
omz update omz update
``` ```
@ -276,7 +329,7 @@ Before you participate in our delightful community, please read the [code of con
I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can. We also need people to test out pull requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can.
See [Contributing](CONTRIBUTING.md) for more details. See [Contributing](CONTRIBUTING.md) for more details.

24
SECURITY.md Normal file
View file

@ -0,0 +1,24 @@
# Security Policy
## Supported Versions
At the moment Oh My Zsh only considers the very latest commit to be supported.
We combine that with our fast response to incidents and the automated updates
to minimize the time between vulnerability publication and patch release.
| Version | Supported |
|:-------------- |:------------------ |
| master | :white_check_mark: |
| other commits | :x: |
In the near future we will introduce versioning, so expect this section to change.
## Reporting a Vulnerability
**Do not submit an issue or pull request**: this might reveal the vulnerability.
Instead, you should email the maintainers directly at: [**security@ohmyz.sh**](mailto:security@ohmyz.sh).
We will deal with the vulnerability privately and submit a patch as soon as possible.
You can also submit your vulnerability report to [huntr.dev](https://huntr.dev/bounties/disclose/?utm_campaign=ohmyzsh%2Fohmyzsh&utm_medium=social&utm_source=github&target=https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh) and see if you can get a bounty reward.

22
aliases.sh Normal file
View file

@ -0,0 +1,22 @@
##############################################################################
# PSK's aliases. Better late than never...
##############################################################################
alias "lhx"="ls ~"
alias "go-go-mono"="cd ~\/src\/rune\/go-mono"
alias "go-tortilla"="cd ~\/src\/rune\/go-mono\/tortilla"
alias "go-omz"="cd ~\/.oh-my-zsh"
alias "ggm"="cd ~\/src\/rune\/go-mono"
alias "gtor"="cd ~\/src\/rune\/go-mono\/tortilla"
alias "gtx"="cd ~\/src\/rune\/go-mono\/tortilla"
alias "gpm"="cd ~\/src\/rune\/python-mono"
alias "grad"="cd ~\/src\/rune\/python-mono\/radish"
alias "gomz"="cd ~\/.oh-my-zsh"
alias "goomz"="cd ~\/.oh-my-zsh"
alias "mtil"="make-big-break&& make test-integration-local 2>&1 | tee .\/make-local.log ; docker-stop-all-containers >\/dev\/null &"
alias "maketil"="make-big-break&& make test-integration-local 2>&1 | tee .\/make-local.log ; docker-stop-all-containers >\/dev\/null &"
alias "mti"="today-time&& make test-integration 2>&1 | tee .\/make-local.log ; docker-stop-all-containers >\/dev\/null &"
alias "maketi"="today-time&& make test-integration 2>&1 | tee .\/make-local.log ; docker-stop-all-containers >\/dev\/null &"
alias "errorsx"="^FATA|^ERR|^WAR|^FAIL"
alias "errx"="^FATA|^ERR|^WAR|^FAIL"
alias "RegEx Error Search"="^FATA|^ERR|^WAR|^FAIL"

1
bin Symbolic link
View file

@ -0,0 +1 @@
/Users/peter/bin

34
docker-util.sh Normal file
View file

@ -0,0 +1,34 @@
###
### DOCKER UTIL
###
alias dk="docker"
alias docker-killall="killall com.docker.hyperkit"
alias killall-docker="killall com.docker.hyperkit"
alias dps="docker ps"
alias dl="docker logs "
alias dlf="docker logs -f "
# stop all containers
function docker-stop-all-containers () {
echo "Stopping all containers..." ; docker container stop -t 2 $(docker container ls -q) 2>/dev/null ; echo ""
}
function docker-lsg () {
docker image ls | grep -Ei "'IMAGE ID'|$1"
}
# kill most recent container instance
alias docker-kill-latest='docker ps -l --format="{{.Names}}" | xargs docker kill'
alias kill-docker-latest=docker-kill-latest
# Params: container ID or name
function dlc() {
docker logs $1 | pbcopy
}
# Params: container ID/name, human date or relative period
function dls() {
docker logs $1 --since $2
}

View file

@ -1,43 +0,0 @@
alias ts-resolve-host="tsunami variables resolve --unit-type host "
function ts-variables-show() {
tsunami variables show $1 $2
}
function ts-variables-show-version() {
tsunami variables history $1 $2
}
alias tsunami-resolve-host="ts-resolve-host"
alias tsunami-variables-show="ts-variables-show"
alias tsunami-variables-show-version="ts-variables-show-version"
# to avoid slow shells, we do it manually
function kubectl() {
if ! type __start_kubectl >/dev/null 2>&1; then
source <(command kubectl completion zsh)
fi
command kubectl "$@"
}
function kube-ctx-show() {
echo "`kube ctx -c` • `kc ns -c`"
}
alias show-kube-ctx="kube-ctx-show"
alias kc-current-ctx="kube-ctx-show"
function kube-list-local-contexts() {
grep '^- name: ' ~/.kube/config | awk '{print $3}'
}
alias kc-list-local-contexts="kube-list-local-contexts"
function kube-list-prod-contexts() {
gcloud container clusters list --project=gke-xpn-1 --filter="resourceLabels[env]=production" --format="value(name)"
}
alias kc-list-prod-contexts="kube-list-prod-contexts"
alias kc="kubectl"
alias mk="minikube"
alias kube-list-contexts="kubectl config get-contexts"

View file

@ -1,16 +1,3 @@
alias ts-resolve-host="tsunami variables resolve --unit-type host "
function ts-variables-show() {
tsunami variables show $1 $2
}
function ts-variables-show-version() {
tsunami variables history $1 $2
}
alias tsunami-resolve-host="ts-resolve-host"
alias tsunami-variables-show="ts-variables-show"
alias tsunami-variables-show-version="ts-variables-show-version"
# to avoid slow shells, we do it manually # to avoid slow shells, we do it manually
function kubectl() { function kubectl() {
if ! type __start_kubectl >/dev/null 2>&1; then if ! type __start_kubectl >/dev/null 2>&1; then
@ -33,10 +20,6 @@ function kube-list-local-contexts() {
alias kc-list-local-contexts="kube-list-local-contexts" alias kc-list-local-contexts="kube-list-local-contexts"
function kube-list-prod-contexts() {
gcloud container clusters list --project=gke-xpn-1 --filter="resourceLabels[env]=production" --format="value(name)"
}
alias kc-list-prod-contexts="kube-list-prod-contexts" alias kc-list-prod-contexts="kube-list-prod-contexts"
alias kc="kubectl" alias kc="kubectl"
@ -45,72 +28,3 @@ alias mk="minikube"
alias kube-list-contexts="kubectl config get-contexts" alias kube-list-contexts="kubectl config get-contexts"
alias kc-site="kubectl-site" alias kc-site="kubectl-site"
# Record all pods belonging to a given namespace across all clusters that are
# configured
function list-all-pods-multi-cluster () {
mv all-pods.txt all-pods.txt~ 2>&1 > /dev/null
KC_NS=$1
echo
echo "Finding all pods for namespace $KC_NS across all configured clusters hello-k8s-replicaset.yaml# hello-k8s-replicaset.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: hello-k8s-<username>
namespace: tech-learning
spec:
replicas: 3
selector:
matchLabels:
app: hello-k8s-<username>
template:
metadata:
annotations:
podpreset.admission.spotify.com/exclude: 'ffwd-java-shim-container, spotify-envs'
labels:
app: hello-k8s-<username>
spec:
containers:
- name: hello-k8s
image: gcr.io/tech-learning-2321/hello-k8s:0.0.1
env:
- name: USER_OVERRIDE
value: "<username>"
ports:
- name: http
containerPort: 8080
resources:
requests:
cpu: 200m
memory: 1G
limits:
cpu: 800m
memory: 4Gand dumping them into ./all-pods.txt..."
echo
for CLUSTER in `kubectl ctx`; do
case $CLUSTER in
kind )
echo "Skipping ${CLUSTER}."
continue
;;
docker )
echo "Skipping ${CLUSTER}."
continue
;;
minikube )
echo "Skipping ${CLUSTER}."
continue
;;
* )
;;
esac
echo "Processing cluster $CLUSTER..."
kubectl ctx $CLUSTER
kubectl ns $KC_NS
kubectl get pods -o wide >> all-pods.txt
done
}

View file

@ -26,8 +26,10 @@ function _omz {
'help:Usage information' 'help:Usage information'
'plugin:Manage plugins' 'plugin:Manage plugins'
'pr:Manage Oh My Zsh Pull Requests' 'pr:Manage Oh My Zsh Pull Requests'
'reload:Reload the current zsh session'
'theme:Manage themes' 'theme:Manage themes'
'update:Update Oh My Zsh' 'update:Update Oh My Zsh'
'version:Show the version'
) )
if (( CURRENT == 2 )); then if (( CURRENT == 2 )); then
@ -35,28 +37,78 @@ function _omz {
elif (( CURRENT == 3 )); then elif (( CURRENT == 3 )); then
case "$words[2]" in case "$words[2]" in
changelog) local -a refs changelog) local -a refs
refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}") refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
_describe 'command' refs ;; _describe 'command' refs ;;
plugin) subcmds=('info:Get plugin information' 'list:List plugins') plugin) subcmds=(
'disable:Disable plugin(s)'
'enable:Enable plugin(s)'
'info:Get plugin information'
'list:List plugins'
'load:Load plugin(s)'
)
_describe 'command' subcmds ;; _describe 'command' subcmds ;;
pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches') pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request')
_describe 'command' subcmds ;; _describe 'command' subcmds ;;
theme) subcmds=('use:Load a theme' 'list:List themes') theme) subcmds=('list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme')
_describe 'command' subcmds ;; _describe 'command' subcmds ;;
esac esac
elif (( CURRENT == 4 )); then elif (( CURRENT == 4 )); then
case "$words[2]::$words[3]" in case "${words[2]}::${words[3]}" in
plugin::info) compadd "$ZSH"/plugins/*/README.md(.N:h:t) \ plugin::(disable|enable|load))
"$ZSH_CUSTOM"/plugins/*/README.md(.N:h:t) ;; local -aU valid_plugins
theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \
"$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;; if [[ "${words[3]}" = disable ]]; then
# if command is "disable", only offer already enabled plugins
valid_plugins=($plugins)
else
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
# if command is "enable", remove already enabled plugins
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
fi
_describe 'plugin' valid_plugins ;;
plugin::info)
local -aU plugins
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
_describe 'plugin' plugins ;;
theme::(set|use))
local -aU themes
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
_describe 'theme' themes ;;
esac
elif (( CURRENT > 4 )); then
case "${words[2]}::${words[3]}" in
plugin::(enable|disable|load))
local -aU valid_plugins
if [[ "${words[3]}" = disable ]]; then
# if command is "disable", only offer already enabled plugins
valid_plugins=($plugins)
else
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
# if command is "enable", remove already enabled plugins
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
fi
# Remove plugins already passed as arguments
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
# has a space after them. This is to avoid removing plugins partially passed, which makes
# the completion not add a space after the completed plugin.
local -a args
args=(${words[4,$(( CURRENT - 1))]})
valid_plugins=(${valid_plugins:|args})
_describe 'plugin' valid_plugins ;;
esac esac
fi fi
return 0 return 0
} }
compdef _omz omz # If run from a script, do not set the completion function
if (( ${+functions[compdef]} )); then
compdef _omz omz
fi
## Utility functions ## Utility functions
@ -106,7 +158,7 @@ function _omz::log {
## User-facing commands ## User-facing commands
function _omz::help { function _omz::help {
cat <<EOF cat >&2 <<EOF
Usage: omz <command> [options] Usage: omz <command> [options]
Available commands: Available commands:
@ -115,8 +167,10 @@ Available commands:
changelog Print the changelog changelog Print the changelog
plugin <command> Manage plugins plugin <command> Manage plugins
pr <command> Manage Oh My Zsh Pull Requests pr <command> Manage Oh My Zsh Pull Requests
reload Reload the current zsh session
theme <command> Manage themes theme <command> Manage themes
update Update Oh My Zsh update Update Oh My Zsh
version Show the version
EOF EOF
} }
@ -124,11 +178,14 @@ EOF
function _omz::changelog { function _omz::changelog {
local version=${1:-HEAD} format=${3:-"--text"} local version=${1:-HEAD} format=${3:-"--text"}
if ! command git -C "$ZSH" show-ref --verify refs/heads/$version &>/dev/null && \ if (
! command git -C "$ZSH" show-ref --verify refs/tags/$version &>/dev/null && \ builtin cd -q "$ZSH"
! command git -C "$ZSH" rev-parse --verify "${version}^{commit}" &>/dev/null; then ! command git show-ref --verify refs/heads/$version && \
cat <<EOF ! command git show-ref --verify refs/tags/$version && \
Usage: omz changelog [version] ! command git rev-parse --verify "${version}^{commit}"
) &>/dev/null; then
cat >&2 <<EOF
Usage: ${(j: :)${(s.::.)0#_}} [version]
NOTE: <version> must be a valid branch, tag or commit. NOTE: <version> must be a valid branch, tag or commit.
EOF EOF
@ -139,14 +196,17 @@ EOF
} }
function _omz::plugin { function _omz::plugin {
(( $# > 0 && $+functions[_omz::plugin::$1] )) || { (( $# > 0 && $+functions[$0::$1] )) || {
cat <<EOF cat >&2 <<EOF
Usage: omz plugin <command> [options] Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands: Available commands:
info <plugin> Get information of a plugin disable <plugin> Disable plugin(s)
list List all available Oh My Zsh plugins enable <plugin> Enable plugin(s)
info <plugin> Get information of a plugin
list List all available Oh My Zsh plugins
load <plugin> Load plugin(s)
EOF EOF
return 1 return 1
@ -155,12 +215,174 @@ EOF
local command="$1" local command="$1"
shift shift
_omz::plugin::$command "$@" $0::$command "$@"
}
function _omz::plugin::disable {
if [[ -z "$1" ]]; then
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi
# Check that plugin is in $plugins
local -a dis_plugins
for plugin in "$@"; do
if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then
_omz::log warn "plugin '$plugin' is not enabled."
continue
fi
dis_plugins+=("$plugin")
done
# Exit if there are no enabled plugins to disable
if [[ ${#dis_plugins} -eq 0 ]]; then
return 1
fi
# Remove plugins substitution awk script
local awk_subst_plugins="\
gsub(/\s+(${(j:|:)dis_plugins})/, \"\") # with spaces before
gsub(/(${(j:|:)dis_plugins})\s+/, \"\") # with spaces after
gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin)
"
# Disable plugins awk script
local awk_script="
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
/^\s*plugins=\([^#]+\).*\$/ {
$awk_subst_plugins
print \$0
next
}
# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there
/^\s*plugins=\(/ {
multi=1
$awk_subst_plugins
print \$0
next
}
# if multi flag is enabled and we find a valid closing parenthesis, remove plugins and disable multi flag
multi == 1 && /^[^#]*\)/ {
multi=0
$awk_subst_plugins
print \$0
next
}
multi == 1 && length(\$0) > 0 {
$awk_subst_plugins
if (length(\$0) > 0) print \$0
next
}
{ print \$0 }
"
local zdot="${ZDOTDIR:-$HOME}"
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
&& command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
# Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || {
local ret=$?
_omz::log error "error disabling plugins."
return $ret
}
# Exit if the new .zshrc file has syntax errors
if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1
fi
# Restart the zsh session if there were no errors
_omz::log info "plugins disabled: ${(j:, :)dis_plugins}."
# Only reload zsh if run in an interactive session
[[ ! -o interactive ]] || _omz::reload
}
function _omz::plugin::enable {
if [[ -z "$1" ]]; then
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi
# Check that plugin is not in $plugins
local -a add_plugins
for plugin in "$@"; do
if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then
_omz::log warn "plugin '$plugin' is already enabled."
continue
fi
add_plugins+=("$plugin")
done
# Exit if there are no plugins to enable
if [[ ${#add_plugins} -eq 0 ]]; then
return 1
fi
# Enable plugins awk script
local awk_script="
# if plugins=() is in oneline form, substitute ) with new plugins and go to the next line
/^\s*plugins=\([^#]+\).*\$/ {
sub(/\)/, \" $add_plugins&\")
print \$0
next
}
# if plugins=() is in multiline form, enable multi flag
/^\s*plugins=\(/ {
multi=1
}
# if multi flag is enabled and we find a valid closing parenthesis,
# add new plugins and disable multi flag
multi == 1 && /^[^#]*\)/ {
multi=0
sub(/\)/, \" $add_plugins&\")
print \$0
next
}
{ print \$0 }
"
local zdot="${ZDOTDIR:-$HOME}"
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
&& command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
# Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || {
local ret=$?
_omz::log error "error enabling plugins."
return $ret
}
# Exit if the new .zshrc file has syntax errors
if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1
fi
# Restart the zsh session if there were no errors
_omz::log info "plugins enabled: ${(j:, :)add_plugins}."
# Only reload zsh if run in an interactive session
[[ ! -o interactive ]] || _omz::reload
} }
function _omz::plugin::info { function _omz::plugin::info {
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin info <plugin>" echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin>"
return 1 return 1
fi fi
@ -194,21 +416,69 @@ function _omz::plugin::list {
if (( ${#custom_plugins} )); then if (( ${#custom_plugins} )); then
print -P "%U%BCustom plugins%b%u:" print -P "%U%BCustom plugins%b%u:"
print -l ${(q-)custom_plugins} | column print -l ${(q-)custom_plugins} | column -x
fi fi
if (( ${#builtin_plugins} )); then if (( ${#builtin_plugins} )); then
(( ${#custom_plugins} )) && echo # add a line of separation (( ${#custom_plugins} )) && echo # add a line of separation
print -P "%U%BBuilt-in plugins%b%u:" print -P "%U%BBuilt-in plugins%b%u:"
print -l ${(q-)builtin_plugins} | column print -l ${(q-)builtin_plugins} | column -x
fi
}
function _omz::plugin::load {
if [[ -z "$1" ]]; then
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi
local plugin base has_completion=0
for plugin in "$@"; do
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
base="$ZSH_CUSTOM/plugins/$plugin"
elif [[ -d "$ZSH/plugins/$plugin" ]]; then
base="$ZSH/plugins/$plugin"
else
_omz::log warn "plugin '$plugin' not found"
continue
fi
# Check if its a valid plugin
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
_omz::log warn "'$plugin' is not a valid plugin"
continue
# It it is a valid plugin, add its directory to $fpath unless it is already there
elif (( ! ${fpath[(Ie)$base]} )); then
fpath=("$base" $fpath)
fi
# Check if it has completion to reload compinit
local -a comp_files
comp_files=($base/_*(N))
has_completion=$(( $#comp_files > 0 ))
# Load the plugin
if [[ -f "$base/$plugin.plugin.zsh" ]]; then
source "$base/$plugin.plugin.zsh"
fi
done
# If we have completion, we need to reload the completion
# We pass -D to avoid generating a new dump file, which would overwrite our
# current one for the next session (and we don't want that because we're not
# actually enabling the plugins for the next session).
# Note that we still have to pass -d "$_comp_dumpfile", so that compinit
# doesn't use the default zcompdump location (${ZDOTDIR:-$HOME}/.zcompdump).
if (( has_completion )); then
compinit -D -d "$_comp_dumpfile"
fi fi
} }
function _omz::pr { function _omz::pr {
(( $# > 0 && $+functions[_omz::pr::$1] )) || { (( $# > 0 && $+functions[$0::$1] )) || {
cat <<EOF cat >&2 <<EOF
Usage: omz pr <command> [options] Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands: Available commands:
@ -222,7 +492,7 @@ EOF
local command="$1" local command="$1"
shift shift
_omz::pr::$command "$@" $0::$command "$@"
} }
function _omz::pr::clean { function _omz::pr::clean {
@ -263,7 +533,7 @@ function _omz::pr::test {
# Check the input # Check the input
if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then
echo >&2 "Usage: omz pr test <PR_NUMBER_or_URL>" echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <PR_NUMBER_or_URL>"
return 1 return 1
fi fi
@ -303,12 +573,27 @@ function _omz::pr::test {
# Rebase pull request branch against the current master # Rebase pull request branch against the current master
_omz::log info "rebasing PR #$1..." _omz::log info "rebasing PR #$1..."
command git rebase master ohmyzsh/pull-$1 || { local ret gpgsign
command git rebase --abort &>/dev/null {
_omz::log warn "could not rebase PR #$1 on top of master." # Back up commit.gpgsign setting: use --local to get the current repository
_omz::log warn "you might not see the latest stable changes." # setting, not the global one. If --local is not a known option, it will
_omz::log info "run \`zsh\` to test the changes." # exit with a 129 status code.
return 1 gpgsign=$(command git config --local commit.gpgsign 2>/dev/null) || ret=$?
[[ $ret -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null)
command git config commit.gpgsign false
command git rebase master ohmyzsh/pull-$1 || {
command git rebase --abort &>/dev/null
_omz::log warn "could not rebase PR #$1 on top of master."
_omz::log warn "you might not see the latest stable changes."
_omz::log info "run \`zsh\` to test the changes."
return 1
}
} always {
case "$gpgsign" in
"") command git config --unset commit.gpgsign ;;
*) command git config commit.gpgsign "$gpgsign" ;;
esac
} }
_omz::log info "fetch of PR #${1} successful." _omz::log info "fetch of PR #${1} successful."
@ -337,15 +622,26 @@ function _omz::pr::test {
) )
} }
function _omz::reload {
# Delete current completion cache
command rm -f $_comp_dumpfile $ZSH_COMPDUMP
# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
}
function _omz::theme { function _omz::theme {
(( $# > 0 && $+functions[_omz::theme::$1] )) || { (( $# > 0 && $+functions[$0::$1] )) || {
cat <<EOF cat >&2 <<EOF
Usage: omz theme <command> [options] Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands: Available commands:
list List all available Oh My Zsh themes list List all available Oh My Zsh themes
use <theme> Load an Oh My Zsh theme set <theme> Set a theme in your .zshrc file
use <theme> Load a theme
EOF EOF
return 1 return 1
@ -354,7 +650,7 @@ EOF
local command="$1" local command="$1"
shift shift
_omz::theme::$command "$@" $0::$command "$@"
} }
function _omz::theme::list { function _omz::theme::list {
@ -368,22 +664,94 @@ function _omz::theme::list {
return return
fi fi
# Print theme in use
if [[ -n "$ZSH_THEME" ]]; then
print -Pn "%U%BCurrent theme%b%u: "
[[ $ZSH_THEME = random ]] && echo "$RANDOM_THEME (via random)" || echo "$ZSH_THEME"
echo
fi
# Print custom themes if there are any
if (( ${#custom_themes} )); then if (( ${#custom_themes} )); then
print -P "%U%BCustom themes%b%u:" print -P "%U%BCustom themes%b%u:"
print -l ${(q-)custom_themes} | column print -l ${(q-)custom_themes} | column -x
echo
fi fi
if (( ${#builtin_themes} )); then # Print built-in themes
(( ${#custom_themes} )) && echo # add a line of separation print -P "%U%BBuilt-in themes%b%u:"
print -l ${(q-)builtin_themes} | column -x
}
print -P "%U%BBuilt-in themes%b%u:" function _omz::theme::set {
print -l ${(q-)builtin_themes} | column if [[ -z "$1" ]]; then
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
return 1
fi fi
# Check that theme exists
if [[ ! -f "$ZSH_CUSTOM/$1.zsh-theme" ]] \
&& [[ ! -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]] \
&& [[ ! -f "$ZSH/themes/$1.zsh-theme" ]]; then
_omz::log error "%B$1%b theme not found"
return 1
fi
# Enable theme in .zshrc
local awk_script='
!set && /^\s*ZSH_THEME=[^#]+.*$/ {
set=1
sub(/^\s*ZSH_THEME=[^#]+.*$/, "ZSH_THEME=\"'$1'\" # set by `omz`")
print $0
next
}
{ print $0 }
END {
# If no ZSH_THEME= line was found, return an error
if (!set) exit 1
}
'
local zdot="${ZDOTDIR:-$HOME}"
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
|| {
# Prepend ZSH_THEME= line to .zshrc if it doesn't exist
cat <<EOF
ZSH_THEME="$1" # set by \`omz\`
EOF
cat "$zdot/.zshrc"
} > "$zdot/.zshrc.new" \
&& command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
# Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || {
local ret=$?
_omz::log error "error setting theme."
return $ret
}
# Exit if the new .zshrc file has syntax errors
if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1
fi
# Restart the zsh session if there were no errors
_omz::log info "'$1' theme set correctly."
# Only reload zsh if run in an interactive session
[[ ! -o interactive ]] || _omz::reload
} }
function _omz::theme::use { function _omz::theme::use {
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme use <theme>" echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
return 1 return 1
fi fi
@ -395,19 +763,23 @@ function _omz::theme::use {
elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
source "$ZSH/themes/$1.zsh-theme" source "$ZSH/themes/$1.zsh-theme"
else else
_omz::log error "theme '$1' not found" _omz::log error "%B$1%b theme not found"
return 1 return 1
fi fi
# Update theme settings
ZSH_THEME="$1"
[[ $1 = random ]] || unset RANDOM_THEME
} }
function _omz::update { function _omz::update {
local last_commit=$(cd "$ZSH"; git rev-parse HEAD) local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
# Run update script # Run update script
if [[ "$1" != --unattended ]]; then if [[ "$1" != --unattended ]]; then
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" --interactive || return $?
else else
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" || return $?
fi fi
# Update last updated file # Update last updated file
@ -417,10 +789,32 @@ function _omz::update {
command rm -rf "$ZSH/log/update.lock" command rm -rf "$ZSH/log/update.lock"
# Restart the zsh session if there were changes # Restart the zsh session if there were changes
if [[ "$1" != --unattended && "$(cd "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then if [[ "$1" != --unattended && "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
# Old zsh versions don't have ZSH_ARGZERO # Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell # Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh" [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
fi fi
} }
function _omz::version {
(
builtin cd -q "$ZSH"
# Get the version name:
# 1) try tag-like version
# 2) try branch name
# 3) try name-rev (tag~<rev> or branch~<rev>)
local version
version=$(command git describe --tags HEAD 2>/dev/null) \
|| version=$(command git symbolic-ref --quiet --short HEAD 2>/dev/null) \
|| version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" HEAD 2>/dev/null) \
|| version="<detached>"
# Get short hash for the current HEAD
local commit=$(command git rev-parse --short HEAD 2>/dev/null)
# Show version and commit hash
printf "%s (%s)\n" "$version" "$commit"
)
}

View file

@ -76,7 +76,7 @@ function detect-clipboard() {
function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; } function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; }
function clippaste() { win32yank -o; } function clippaste() { win32yank -o; }
elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then
function clipcopy() { termux-clipboard-set "${1:-/dev/stdin}"; } function clipcopy() { termux-clipboard-set < "${1:-/dev/stdin}"; }
function clippaste() { termux-clipboard-get; } function clippaste() { termux-clipboard-get; }
elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then
function clipcopy() { tmux load-buffer "${1:--}"; } function clipcopy() { tmux load-buffer "${1:--}"; }

View file

@ -58,9 +58,12 @@ zstyle ':completion:*:*:*:users' ignored-patterns \
# ... unless we really want to. # ... unless we really want to.
zstyle '*' single-ignored show zstyle '*' single-ignored show
if [[ $COMPLETION_WAITING_DOTS = true ]]; then if [[ ${COMPLETION_WAITING_DOTS:-false} != false ]]; then
expand-or-complete-with-dots() { expand-or-complete-with-dots() {
print -Pn "%F{red}…%f" # use $COMPLETION_WAITING_DOTS either as toggle or as the sequence to show
[[ $COMPLETION_WAITING_DOTS = true ]] && COMPLETION_WAITING_DOTS="%F{red}…%f"
# turn off line wrapping and print prompt-expanded "dot" sequence
printf '\e[?7l%s\e[?7h' "${(%)COMPLETION_WAITING_DOTS}"
zle expand-or-complete zle expand-or-complete
zle redisplay zle redisplay
} }

View file

@ -9,6 +9,7 @@ if [[ "$ENABLE_CORRECTION" == "true" ]]; then
alias mv='nocorrect mv' alias mv='nocorrect mv'
alias mysql='nocorrect mysql' alias mysql='nocorrect mysql'
alias sudo='nocorrect sudo' alias sudo='nocorrect sudo'
alias su='nocorrect su'
setopt correct_all setopt correct_all
fi fi

View file

@ -335,7 +335,7 @@ function _omz_diag_dump_os_specific_version() {
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)" builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
;; ;;
cygwin) cygwin)
command systeminfo | command head -4 | command tail -2 command systeminfo | command head -n 4 | command tail -n 2
;; ;;
esac esac

View file

@ -9,7 +9,7 @@ alias -g .....='../../../..'
alias -g ......='../../../../..' alias -g ......='../../../../..'
alias -- -='cd -' alias -- -='cd -'
alias 1='cd -' alias 1='cd -1'
alias 2='cd -2' alias 2='cd -2'
alias 3='cd -3' alias 3='cd -3'
alias 4='cd -4' alias 4='cd -4'
@ -26,7 +26,7 @@ function d () {
if [[ -n $1 ]]; then if [[ -n $1 ]]; then
dirs "$@" dirs "$@"
else else
dirs -v | head -10 dirs -v | head -n 10
fi fi
} }
compdef _dirs d compdef _dirs d

View file

@ -1,7 +1,7 @@
function zsh_stats() { function zsh_stats() {
fc -l 1 \ fc -l 1 \
| awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \ | awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
| grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl | grep -v "./" | sort -nr | head -n 20 | column -c3 -s " " -t | nl
} }
function uninstall_oh_my_zsh() { function uninstall_oh_my_zsh() {
@ -13,10 +13,6 @@ function upgrade_oh_my_zsh() {
omz update omz update
} }
function takedir() {
mkdir -p $@ && cd ${@:$#}
}
function open_command() { function open_command() {
local open_cmd local open_cmd
@ -37,30 +33,46 @@ function open_command() {
${=open_cmd} "$@" &>/dev/null ${=open_cmd} "$@" &>/dev/null
} }
# take functions
# mkcd is equivalent to takedir
function mkcd takedir() {
mkdir -p $@ && cd ${@:$#}
}
function takeurl() { function takeurl() {
data=$(mktemp) local data thedir
curl -L $1 > $data data="$(mktemp)"
tar xf $data curl -L "$1" > "$data"
thedir=$(tar tf $data | head -1) tar xf "$data"
rm $data thedir="$(tar tf "$data" | head -n 1)"
cd $thedir rm "$data"
cd "$thedir"
} }
function takegit() { function takegit() {
git clone $1 git clone "$1"
cd $(basename ${1%%.git}) cd "$(basename ${1%%.git})"
} }
function take() { function take() {
if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then if [[ $1 =~ ^(https?|ftp).*\.tar\.(gz|bz2|xz)$ ]]; then
takeurl $1 takeurl "$1"
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
takegit $1 takegit "$1"
else else
takedir $1 takedir "$@"
fi fi
} }
alias gdi="git diff --cached "
alias gdc="git diff --cached "
# Params: branch A and branch B to be diffed
function gdb() {
git diff $1..$2
}
# #
# Get the value of an alias. # Get the value of an alias.
# #
@ -233,12 +245,11 @@ function omz_urldecode {
tmp=${tmp:gs/\\/\\\\/} tmp=${tmp:gs/\\/\\\\/}
# Handle %-escapes by turning them into `\xXX` printf escapes # Handle %-escapes by turning them into `\xXX` printf escapes
tmp=${tmp:gs/%/\\x/} tmp=${tmp:gs/%/\\x/}
local decoded local decoded="$(printf -- "$tmp")"
eval "decoded=\$'$tmp'"
# Now we have a UTF-8 encoded string in the variable. We need to re-encode # Now we have a UTF-8 encoded string in the variable. We need to re-encode
# it if caller is in a non-UTF-8 locale. # it if caller is in a non-UTF-8 locale.
local safe_encodings local -a safe_encodings
safe_encodings=(UTF-8 utf8 US-ASCII) safe_encodings=(UTF-8 utf8 US-ASCII)
if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then
decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding) decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding)
@ -264,11 +275,45 @@ lsg() {
l | grep -iE "$1" l | grep -iE "$1"
} }
function alg() {
FN=/tmp/alg.$$
echo -e "\nAliases ———————" > $FN
alias | grep -i $1 >> $FN
echo -e "\nFunctions ———————" >> $FN
functions | grep -i $1 >> $FN
bat $FN
rm -f $FN
}
alias agr="alg"
alias alias-grep="alg"
# These need to be here since they're required by gfind* # These need to be here since they're required by gfind*
alias ag="/usr/local/homebrew/bin/ag --ignore '*.svg' --ignore '*.xlt' --ignore '*.tsx' --ignore '*.js' --ignore '*.snap' --ignore '*.json' --ignore '*.dat' --ignore '*.builds' --ignore '*.tsv' --ignore '*.csv' --ignore '*.lock' --ignore '*.patch' --ignore '*.sum' --pager=bat" alias ag="/usr/local/homebrew/bin/ag --ignore '*.svg' --ignore '*.xlt' --ignore '*.tsx' --ignore '*.js' --ignore '*.snap' --ignore '*.json' --ignore '*.dat' --ignore '*.builds' --ignore '*.tsv' --ignore '*.csv' --ignore '*.lock' --ignore '*.patch' --ignore '*.sum' --pager=bat"
alias ag-no-pager="/usr/local/homebrew/bin/ag --ignore '*.svg' --ignore '*.xlt' --ignore '*.tsx' --ignore '*.js' --ignore '*.snap' --ignore '*.json' --ignore '*.dat' --ignore '*.builds' --ignore '*.tsv' --ignore '*.csv' --ignore '*.lock' --ignore '*.patch' --ignore '*.sum'" alias ag-no-pager="/usr/local/homebrew/bin/ag --ignore '*.svg' --ignore '*.xlt' --ignore '*.tsx' --ignore '*.js' --ignore '*.snap' --ignore '*.json' --ignore '*.dat' --ignore '*.builds' --ignore '*.tsv' --ignore '*.csv' --ignore '*.lock' --ignore '*.patch' --ignore '*.sum'"
alias "git-grep"="git \grep" alias "git-grep"="git \grep"
function make-break() {
echo -e "—————————————————————————————————————————— \
\n\n——————————————————————————————————————————\n"
}
# Spits out a page of alternating white lines (hypens or thereabouts)
function page-break() {
for i in {1..9}; do;
make-break
done
today-time
}
function today-time() {
echo "————————————\n"
date +"%a %l:%M%p"
echo "\n————————————"
}
alias make-big-break=page-break
# the ol' gfind. Doesn't take a file pattern. # the ol' gfind. Doesn't take a file pattern.
function gfind-all() { function gfind-all() {
# fd -H -t f . -x grep --color=always -Hi ${1} # fd -H -t f . -x grep --color=always -Hi ${1}
@ -276,13 +321,13 @@ function gfind-all() {
# $1 is search term, $2 is path # $1 is search term, $2 is path
# rg --no-ignore --hidden "$@" # rg --no-ignore --hidden "$@"
# even better is ag / silver searcher https://github.com/ggreer/the_silver_searcher # even better is ag / silver searcher https://github.com/ggreer/the_silver_searcher
ag-no-pager -a --pager bat "$@" ag-no-pager --ignore-case -a --pager bat "$@"
} }
# the ol' gfind. Doesn't take a file pattern. # the ol' gfind. Doesn't take a file pattern.
function gfind() { function gfind() {
# fd -t f . -x grep --color=always -Hi ${1} # fd -t f . -x grep --color=always -Hi ${1}
ag-no-pager --pager bat "$@" ag-no-pager --ignore-case --pager bat "$@"
} }
# Print out the matches only # Print out the matches only
@ -305,6 +350,10 @@ function agl() {
ag --pager less "$@" ag --pager less "$@"
} }
function lsofgr() {
sudo lsof -i -P | grep -E "$1|LISTEN" | grep -E "$1|:"
}
function kill-em-all() { function kill-em-all() {
NAME=$1 NAME=$1
@ -316,9 +365,9 @@ function kill-em-all() {
} }
function dateline() { function dateline() {
echo "" echo -e "\n"
date date
echo "" echo -e "\n"
} }
function clean-slate() { function clean-slate() {
@ -329,10 +378,32 @@ function clean-slate() {
alias clr=clean-slate alias clr=clean-slate
alias cls=clean-slate alias cls=clean-slate
function psgr() { function h() {
ps auwwwwx | grep -v 'grep ' | grep -E "%CPU|$1" NUM_LINES=$1
if [ -z "$NUM_LINES" ]; then
NUM_LINES=35
fi
\history -$NUM_LINES
} }
function psgr() {
ps -e | grep -v 'grep ' | grep -iE "TIME CMD|$1"
}
# Sort on the command
function psgr-sorted() {
echo " PID TTY TIME CMD"
ps -e | grep -v 'grep ' | grep -iE "$1" | sort -k 4
}
function lsofgr-listen() {
echo "Searching for processes listening on port $1..."
#echo " lsof can take up to 2 minutes to complete"
# --stdin Write the prompt to the standard error and read the password from the standard input instead of using the terminal device.
sudo --stdin < <(echo "11anfair") lsof -i -P | grep -E "COMMAND|.*:$1.*LISTEN"
}
alias port-grep=lsofgr
function edit() { function edit() {
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code $1 /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code $1
} }
@ -556,4 +627,31 @@ bindkey '^Xf' peco-directories
zle -N peco-files zle -N peco-files
bindkey '^X^f' peco-files bindkey '^X^f' peco-files
### peco functions ### ###########################
# Percol https://github.com/mooz/percol
###########################
function ppgrep() {
if [[ $1 == "" ]]; then
PERCOL=percol
else
PERCOL="percol --query $1"
fi
ps aux | eval $PERCOL | awk '{ print $2 }'
}
function ppkill() {
if [[ $1 =~ "^-" ]]; then
QUERY="" # options only
else
QUERY=$1 # with a query
[[ $# > 0 ]] && shift
fi
ppgrep $QUERY | xargs kill $*
}
alias interactive-ps-grep="ppgrep"
alias grep-ps-percol="ppgrep"
alias grep-ps-interactive="ppgrep"
alias interactive-kill="ppkill"
alias kill-interactive="ppkill"
alias kill-percol="ppkill"

View file

@ -29,7 +29,7 @@ function git_prompt_info() {
&& upstream=" -> ${upstream}" && upstream=" -> ${upstream}"
fi fi
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref}${upstream}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
} }
# Checks if working tree is dirty # Checks if working tree is dirty
@ -51,7 +51,7 @@ function parse_git_dirty() {
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
;; ;;
esac esac
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -1) STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
fi fi
if [[ -n $STATUS ]]; then if [[ -n $STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY" echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
@ -82,7 +82,7 @@ function git_remote_status() {
fi fi
if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX" git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX${remote:gs/%/%%}$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
fi fi
echo $git_remote_status echo $git_remote_status
@ -206,7 +206,8 @@ function git_prompt_status() {
STASHED UNMERGED AHEAD BEHIND DIVERGED STASHED UNMERGED AHEAD BEHIND DIVERGED
) )
local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)" local status_text
status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
# Don't continue on a catastrophic failure # Don't continue on a catastrophic failure
if [[ $? -eq 128 ]]; then if [[ $? -eq 128 ]]; then

View file

@ -2,5 +2,5 @@
function nvm_prompt_info() { function nvm_prompt_info() {
which nvm &>/dev/null || return which nvm &>/dev/null || return
local nvm_prompt=${$(nvm current)#v} local nvm_prompt=${$(nvm current)#v}
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}" echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt:gs/%/%%}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
} }

View file

@ -30,7 +30,7 @@ function rvm_prompt_info() {
local rvm_prompt local rvm_prompt
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
[[ -z "${rvm_prompt}" ]] && return 1 [[ -z "${rvm_prompt}" ]] && return 1
echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt}${ZSH_THEME_RUBY_PROMPT_SUFFIX}" echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt:gs/%/%%}${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
} }
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g" ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"

View file

@ -20,16 +20,18 @@ done
# Show all 256 colors with color number # Show all 256 colors with color number
function spectrum_ls() { function spectrum_ls() {
setopt localoptions nopromptsubst
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris} local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
for code in {000..255}; do for code in {000..255}; do
print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}" print -P -- "$code: ${FG[$code]}${ZSH_SPECTRUM_TEXT}%{$reset_color%}"
done done
} }
# Show all 256 colors where the background is set to specific color # Show all 256 colors where the background is set to specific color
function spectrum_bls() { function spectrum_bls() {
setopt localoptions nopromptsubst
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris} local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
for code in {000..255}; do for code in {000..255}; do
print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}" print -P -- "$code: ${BG[$code]}${ZSH_SPECTRUM_TEXT}%{$reset_color%}"
done done
} }

View file

@ -7,17 +7,17 @@
# (In screen, only short_tab_title is used) # (In screen, only short_tab_title is used)
# Limited support for Apple Terminal (Terminal can't set window and tab separately) # Limited support for Apple Terminal (Terminal can't set window and tab separately)
function title { function title {
emulate -L zsh setopt localoptions nopromptsubst
setopt prompt_subst
[[ "$INSIDE_EMACS" == *term* ]] && return # Don't set the title if inside emacs, unless using vterm
[[ -n "${INSIDE_EMACS:-}" && "$INSIDE_EMACS" != vterm ]] && return
# if $2 is unset use $1 as default # if $2 is unset use $1 as default
# if it is set and empty, leave it as is # if it is set and empty, leave it as is
: ${2=$1} : ${2=$1}
case "$TERM" in case "$TERM" in
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*) cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot)
print -Pn "\e]2;${2:q}\a" # set window name print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name print -Pn "\e]1;${1:q}\a" # set tab name
;; ;;
@ -29,12 +29,9 @@ function title {
print -Pn "\e]2;${2:q}\a" # set window name print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name print -Pn "\e]1;${1:q}\a" # set tab name
else else
# Try to use terminfo to set the title # Try to use terminfo to set the title if the feature is available
# If the feature is available set title if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then print -Pn "${terminfo[tsl]}$1${terminfo[fsl]}"
echoti tsl
print -Pn "$1"
echoti fsl
fi fi
fi fi
;; ;;
@ -50,13 +47,13 @@ fi
# Runs before showing the prompt # Runs before showing the prompt
function omz_termsupport_precmd { function omz_termsupport_precmd {
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
} }
# Runs before executing the command # Runs before executing the command
function omz_termsupport_preexec { function omz_termsupport_preexec {
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
emulate -L zsh emulate -L zsh
setopt extended_glob setopt extended_glob
@ -99,16 +96,18 @@ function omz_termsupport_preexec {
fi fi
# cmd name only, or if this is sudo or ssh, the next cmd # cmd name only, or if this is sudo or ssh, the next cmd
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%} local CMD="${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}"
local LINE="${2:gs/%/%%}" local LINE="${2:gs/%/%%}"
title '$CMD' '%100>...>$LINE%<<' title "$CMD" "%100>...>${LINE}%<<"
} }
autoload -U add-zsh-hook autoload -Uz add-zsh-hook
add-zsh-hook precmd omz_termsupport_precmd
add-zsh-hook preexec omz_termsupport_preexec
if [[ -z "$INSIDE_EMACS" || "$INSIDE_EMACS" = vterm ]]; then
add-zsh-hook precmd omz_termsupport_precmd
add-zsh-hook preexec omz_termsupport_preexec
fi
# Keep Apple Terminal.app's current working directory updated # Keep Apple Terminal.app's current working directory updated
# Based on this answer: https://superuser.com/a/315029 # Based on this answer: https://superuser.com/a/315029

View file

@ -40,7 +40,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
fi fi
# enable diff color if possible. # enable diff color if possible.
if command diff --color . . &>/dev/null; then if command diff --color /dev/null /dev/null &>/dev/null; then
alias diff='diff --color' alias diff='diff --color'
fi fi

53
lib/vcs_info.zsh Normal file
View file

@ -0,0 +1,53 @@
# Don't skip this file until a Zsh release does the necessary quoting.
# This is because even though 5.8.1 undid recursive prompt_subst inside
# prompt sequences, % characters in relevant fields will still be rendered
# incorrectly in vcs_info, on all Zsh releases up to writing this.
#
# There is no release yet that does this right, since it requires changing
# how what vcs_info hooks expect to receive. Even so, I'd rather be correct
# and break custom vcs_info hooks than have a broken prompt.
# Quote necessary $hook_com[<field>] items just before they are used
# in the line "VCS_INFO_hook 'post-backend'" of the VCS_INFO_formats
# function, where <field> is:
#
# base: the full path of the repository's root directory.
# base-name: the name of the repository's root directory.
# branch: the name of the currently checked out branch.
# misc: a string that may contain anything the vcs_info backend wants.
# revision: an identifier of the currently checked out revision.
# subdir: the path of the current directory relative to the
# repository's root directory.
#
# This patch %-quotes these fields previous to their use in vcs_info hooks and
# the zformat call and, eventually, when they get expanded in the prompt.
# It's important to quote these here, and not later after hooks have modified the
# fields, because then we could be quoting % characters from valid prompt sequences,
# like %F{color}, %B, etc.
#
# 32 │ hook_com[subdir]="$(VCS_INFO_reposub ${hook_com[base]})"
# 33 │ hook_com[subdir_orig]="${hook_com[subdir]}"
# 34 │
# 35 + │ for tmp in base base-name branch misc revision subdir; do
# 36 + │ hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"
# 37 + │ done
# 38 + │
# 39 │ VCS_INFO_hook 'post-backend'
#
# This is especially important so that no command substitution is performed
# due to malicious input as a consequence of CVE-2021-45444, which affects
# zsh versions from 5.0.3 to 5.8.
#
autoload -Uz +X regexp-replace VCS_INFO_formats 2>/dev/null || return
# We use $tmp here because it's already a local variable in VCS_INFO_formats
typeset PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'
# Unique string to avoid reapplying the patch if this code gets called twice
typeset PATCH_ID=vcs_info-patch-9b9840f2-91e5-4471-af84-9e9a0dc68c1b
# Only patch the VCS_INFO_formats function if not already patched
if [[ "$functions[VCS_INFO_formats]" != *$PATCH_ID* ]]; then
regexp-replace 'functions[VCS_INFO_formats]' \
"VCS_INFO_hook 'post-backend'" \
': ${PATCH_ID}; ${PATCH}; ${MATCH}'
fi
unset PATCH PATCH_ID

View file

@ -1,3 +1,43 @@
# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
[ -n "$ZSH_VERSION" ] || {
# ANSI formatting function (\033[<code>m)
# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
omz_f() {
[ $# -gt 0 ] || return
IFS=";" printf "\033[%sm" $*
}
# If stdout is not a terminal ignore all formatting
[ -t 1 ] || omz_f() { :; }
omz_ptree() {
# Get process tree of the current process
pid=$$; pids="$pid"
while [ ${pid-0} -ne 1 ] && ppid=$(ps -e -o pid,ppid | awk "\$1 == $pid { print \$2 }"); do
pids="$pids $pid"; pid=$ppid
done
# Show process tree
case "$(uname)" in
Linux) ps -o ppid,pid,command -f -p $pids 2>/dev/null ;;
Darwin|*) ps -o ppid,pid,command -p $pids 2>/dev/null ;;
esac
# If ps command failed, try Busybox ps
[ $? -eq 0 ] || ps -o ppid,pid,comm | awk "NR == 1 || index(\"$pids\", \$2) != 0"
}
{
shell=$(ps -o pid,comm | awk "\$1 == $$ { print \$2 }")
printf "$(omz_f 1 31)Error:$(omz_f 22) Oh My Zsh can't be loaded from: $(omz_f 1)${shell}$(omz_f 22). "
printf "You need to run $(omz_f 1)zsh$(omz_f 22) instead.$(omz_f 0)\n"
printf "$(omz_f 33)Here's the process tree:$(omz_f 22)\n\n"
omz_ptree
printf "$(omz_f 0)\n"
} >&2
return 1
}
# If ZSH is not defined, use the current script's directory. # If ZSH is not defined, use the current script's directory.
[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}" [[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"
@ -7,22 +47,27 @@ if [[ -z "$ZSH_CACHE_DIR" ]]; then
ZSH_CACHE_DIR="$ZSH/cache" ZSH_CACHE_DIR="$ZSH/cache"
fi fi
# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"
fi
# Create cache and completions dir and add to $fpath
mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# Check for updates on initial load... # Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then if [[ "$DISABLE_AUTO_UPDATE" != true ]]; then
source $ZSH/tools/check_for_upgrade.sh source "$ZSH/tools/check_for_upgrade.sh"
fi fi
# Homebrew mentioned this so I'm doing it # Homebrew mentioned this so I'm doing it
export SCALA_HOME=/usr/local/homebrew/opt/scala/idea export SCALA_HOME=/usr/local/homebrew/opt/scala/idea
# From Helios user guide https://github.com/spotify/helios/blob/master/docs/user_manual.md#using-the-helios-cli
alias helios='helios -z http://localhost:5801'
# Initializes Oh My Zsh # Initializes Oh My Zsh
# add a function path # add a function path
fpath=($ZSH/functions $ZSH/completions $fpath) fpath=("$ZSH/functions" "$ZSH/completions" $fpath)
# Load all stock functions (from $fpath files) called below. # Load all stock functions (from $fpath files) called below.
# Only check daily from https://carlosbecker.com/posts/speeding-up-zsh/ # Only check daily from https://carlosbecker.com/posts/speeding-up-zsh/
@ -41,7 +86,6 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
ZSH_CUSTOM="$ZSH/custom" ZSH_CUSTOM="$ZSH/custom"
fi fi
is_plugin() { is_plugin() {
local base_dir=$1 local base_dir=$1
local name=$2 local name=$2
@ -52,10 +96,10 @@ is_plugin() {
# Add all defined plugins to fpath. This must be done # Add all defined plugins to fpath. This must be done
# before running compinit. # before running compinit.
for plugin ($plugins); do for plugin ($plugins); do
if is_plugin $ZSH_CUSTOM $plugin; then if is_plugin "$ZSH_CUSTOM" "$plugin"; then
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath) fpath=("$ZSH_CUSTOM/plugins/$plugin" $fpath)
elif is_plugin $ZSH $plugin; then elif is_plugin "$ZSH" "$plugin"; then
fpath=($ZSH/plugins/$plugin $fpath) fpath=("$ZSH/plugins/$plugin" $fpath)
else else
echo "[oh-my-zsh] plugin '$plugin' not found" echo "[oh-my-zsh] plugin '$plugin' not found"
fi fi
@ -64,14 +108,14 @@ done
# Figure out the SHORT hostname # Figure out the SHORT hostname
if [[ "$OSTYPE" = darwin* ]]; then if [[ "$OSTYPE" = darwin* ]]; then
# macOS's $HOST changes with dhcp, etc. Use ComputerName if possible. # macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/} SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
else else
SHORT_HOST=${HOST/.*/} SHORT_HOST="${HOST/.*/}"
fi fi
# Save the location of the current completion dump file. # Save the location of the current completion dump file.
if [ -z "$ZSH_COMPDUMP" ]; then if [[ -z "$ZSH_COMPDUMP" ]]; then
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi fi
# Construct zcompdump OMZ metadata # Construct zcompdump OMZ metadata
@ -85,19 +129,20 @@ if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
zcompdump_refresh=1 zcompdump_refresh=1
fi fi
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then if [[ "$ZSH_DISABLE_COMPFIX" != true ]]; then
source $ZSH/lib/compfix.zsh source "$ZSH/lib/compfix.zsh"
# If completion insecurities exist, warn the user
handle_completion_insecurities
# Load only from secure directories # Load only from secure directories
compinit -i -C -d "${ZSH_COMPDUMP}" compinit -i -d "$ZSH_COMPDUMP"
# If completion insecurities exist, warn the user
handle_completion_insecurities &|
else else
# If the user wants it, load from all found directories # If the user wants it, load from all found directories
compinit -u -C -d "${ZSH_COMPDUMP}" compinit -u -d "$ZSH_COMPDUMP"
fi fi
# Append zcompdump metadata if missing # Append zcompdump metadata if missing
if (( $zcompdump_refresh )); then if (( $zcompdump_refresh )) \
|| ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null; then
# Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error # Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error
# See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489 # See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489
tee -a "$ZSH_COMPDUMP" &>/dev/null <<EOF tee -a "$ZSH_COMPDUMP" &>/dev/null <<EOF
@ -106,40 +151,48 @@ $zcompdump_revision
$zcompdump_fpath $zcompdump_fpath
EOF EOF
fi fi
unset zcompdump_revision zcompdump_fpath zcompdump_refresh unset zcompdump_revision zcompdump_fpath zcompdump_refresh
# Load all of the config files in ~/oh-my-zsh that end in .zsh # Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore # TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh); do for config_file ("$ZSH"/lib/*.zsh); do
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}" custom_config_file="$ZSH_CUSTOM/lib/${config_file:t}"
[ -f "${custom_config_file}" ] && config_file=${custom_config_file} [[ -f "$custom_config_file" ]] && config_file="$custom_config_file"
source $config_file source "$config_file"
done done
unset custom_config_file
# Load all of the plugins that were defined in ~/.zshrc # Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do for plugin ($plugins); do
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then if [[ -f "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh" ]]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh source "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh"
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then elif [[ -f "$ZSH/plugins/$plugin/$plugin.plugin.zsh" ]]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh source "$ZSH/plugins/$plugin/$plugin.plugin.zsh"
fi fi
done done
unset plugin
# Load all of your custom configurations from custom/ # Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh(N)); do for config_file ("$ZSH_CUSTOM"/*.zsh(N)); do
source $config_file source "$config_file"
done done
unset config_file unset config_file
# Load the theme # Load the theme
if [ ! "$ZSH_THEME" = "" ]; then is_theme() {
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then local base_dir=$1
local name=$2
builtin test -f $base_dir/$name.zsh-theme
}
if [[ -n "$ZSH_THEME" ]]; then
if is_theme "$ZSH_CUSTOM" "$ZSH_THEME"; then
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then elif is_theme "$ZSH_CUSTOM/themes" "$ZSH_THEME"; then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else elif is_theme "$ZSH/themes" "$ZSH_THEME"; then
source "$ZSH/themes/$ZSH_THEME.zsh-theme" source "$ZSH/themes/$ZSH_THEME.zsh-theme"
else
echo "[oh-my-zsh] theme '$ZSH_THEME' not found"
fi fi
fi fi

View file

@ -0,0 +1,9 @@
# Do nothing if op is not installed
(( ${+commands[op]} )) || return
# Load op completion
eval "$(op completion zsh)"
compdef _op op
# Load opswd function
autoload -Uz opswd

View file

@ -0,0 +1,38 @@
# 1Password
This plugin adds 1Password functionality to oh-my-zsh.
To use, add `1password` to the list of plugins in your `.zshrc` file:
```zsh
plugins=(... 1password)
```
Then, you can use the command `opswd` to copy passwords for services into your
clipboard.
## `opswd`
The `opswd` command is a wrapper around the `op` command. It takes a service
name as an argument and copies the password for that service to the clipboard.
If the service also contains a TOTP, it is copied to the clipboard after 10 seconds.
Finally, after 20 seconds, the clipboard is cleared.
The function has completion support, so you can use tab completion to select
which service you want to get.
For example, `opswd github.com` will put your GitHub password into your clipboard, and if
a TOTP is available, it will be copied to the clipboard after 10 seconds.
> NOTE: you need to be signed in for `opswd` to work. If you are using biometric unlock,
> 1Password CLI will automatically prompt you to sign in. See:
>
> - [Get started with 1Password CLI 2: Sign in](https://developer.1password.com/docs/cli/get-started#sign-in)
> - [Sign in to your 1Password account manually](https://developer.1password.com/docs/cli/sign-in-manually)
## Requirements
- [1Password CLI 2](https://developer.1password.com/docs/cli/get-started#install)
> NOTE: if you're using 1Password CLI 1, [see how to upgrade to CLI 2](https://developer.1password.com/docs/cli/upgrade).

19
plugins/1password/_opswd Normal file
View file

@ -0,0 +1,19 @@
#compdef opswd
function _opswd() {
local -a services
services=("${(@f)$(op item list --categories Login --cache 2>/dev/null | awk 'NR != 1 { print $2 }')}")
[[ -z "$services" ]] || compadd -a -- services
}
# TODO: 2022-03-26: Remove support for op CLI 1
autoload -Uz is-at-least
is-at-least 2.0.0 $(op --version) || {
function _opswd() {
local -a services
services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
[[ -z "$services" ]] || compadd -a -- services
}
}
_opswd "$@"

78
plugins/1password/opswd Normal file
View file

@ -0,0 +1,78 @@
#autoload
# opswd puts the password of the named service into the clipboard. If there's a
# one time password, it will be copied into the clipboard after 10 seconds. The
# clipboard is cleared after another 20 seconds.
function opswd() {
if [[ $# -lt 1 ]]; then
echo "Usage: opswd <service>"
return 1
fi
local service=$1
# If not logged in, print error and return
op user list > /dev/null || return
local password
# Copy the password to the clipboard
if ! password=$(op item get "$service" --fields password 2>/dev/null); then
echo "error: could not obtain password for $service"
return 1
fi
echo -n "$password" | clipcopy
echo "✔ password for $service copied to clipboard"
# If there's a one time password, copy it to the clipboard after 10 seconds
local totp
if totp=$(op item get --otp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
sleep 10 && echo -n "$totp" | clipcopy
echo "✔ TOTP for $service copied to clipboard"
fi
(sleep 20 && clipcopy </dev/null 2>/dev/null) &!
}
# TODO: 2022-03-26: Remove support for op CLI 1
autoload -Uz is-at-least
is-at-least 2.0.0 $(op --version) || {
print -ru2 ${(%):-"%F{yellow}opswd: usage with op version $(op --version) is deprecated. Upgrade to CLI 2 and reload zsh.
For instructions, see https://developer.1password.com/docs/cli/upgrade.%f"}
# opswd puts the password of the named service into the clipboard. If there's a
# one time password, it will be copied into the clipboard after 10 seconds. The
# clipboard is cleared after another 20 seconds.
function opswd() {
if [[ $# -lt 1 ]]; then
echo "Usage: opswd <service>"
return 1
fi
local service=$1
# If not logged in, print error and return
op list users > /dev/null || return
local password
# Copy the password to the clipboard
if ! password=$(op get item "$service" --fields password 2>/dev/null); then
echo "error: could not obtain password for $service"
return 1
fi
echo -n "$password" | clipcopy
echo "✔ password for $service copied to clipboard"
# If there's a one time password, copy it to the clipboard after 5 seconds
local totp
if totp=$(op get totp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
sleep 10 && echo -n "$totp" | clipcopy
echo "✔ TOTP for $service copied to clipboard"
fi
(sleep 20 && clipcopy </dev/null 2>/dev/null) &!
}
}
opswd "$@"

View file

@ -5,7 +5,7 @@ This plugin provides completion support for [`ag`](https://github.com/ggreer/the
To use it, add ag to the plugins array in your zshrc file. To use it, add ag to the plugins array in your zshrc file.
```zsh ```zsh
plugins=(... aws) plugins=(... ag)
``` ```
## INSTALLATION NOTES ## INSTALLATION NOTES

1
plugins/aliases/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
__pycache__

View file

@ -1,21 +1,22 @@
## Aliases Cheatsheet # Aliases cheatsheet
**Maintainer:** [@hqingyi](https://github.com/hqingyi) **Maintainer:** [@hqingyi](https://github.com/hqingyi)
With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts
that are currently available based on the plugins you have enabled. that are currently available based on the plugins you have enabled.
Enable this plugin by adding it to your `plugins` definition in `~/.zshrc`. To use it, add `aliases` to the plugins array in your zshrc file:
``` ```zsh
plugins=(aliases) plugins=(aliases)
``` ```
Requirements: Python needs to be installed. Requirements: Python needs to be installed.
### Usage ## Usage
``` - `acs`: show all aliases by group.
acs: group all alias
acs $keywordquickly filter alias & highlight - `acs <keyword>`: filter aliases by `<keyword>` and highlight.
```
![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png)

View file

@ -2,9 +2,10 @@
# #
# - acs: alias cheatsheet # - acs: alias cheatsheet
# group alias by command, pass addition argv to grep. # group alias by command, pass addition argv to grep.
ALIASES_PLUGIN_ROOT=$(cd `dirname $0` && pwd)
function acs(){ function acs(){
which python >>/dev/null (( $+commands[python3] )) || {
[[ $? -eq 1 ]] && echo "[error]no python executable detected!" && return echo "[error] No python executable detected"
alias | python $ALIASES_PLUGIN_ROOT/cheatsheet.py $@ return
}
alias | python3 ${functions_source[$0]:h}/cheatsheet.py $@
} }

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
import sys import sys
import itertools import itertools
import termcolor import termcolor
@ -26,16 +26,16 @@ def cheatsheet(lines):
target_aliases.extend(group_list) target_aliases.extend(group_list)
return cheatsheet return cheatsheet
def pretty_print_group(key, aliases, hightlight=None): def pretty_print_group(key, aliases, highlight=None):
if len(aliases) == 0: if len(aliases) == 0:
return return
group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)]) group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)])
alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)]) alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)])
group_formatter = lambda g: termcolor.colored('[%s]' % g, 'red') group_formatter = lambda g: termcolor.colored('[%s]' % g, 'red')
alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green') alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green')
if hightlight and len(hightlight)>0: if highlight and len(highlight)>0:
print (group_hl_formatter(key, hightlight)) print (group_hl_formatter(key, highlight))
print ('\n'.join([alias_hl_formatter(alias, hightlight) for alias in aliases])) print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases]))
else: else:
print (group_formatter(key)) print (group_formatter(key))
print ('\n'.join([alias_formatter(alias) for alias in aliases])) print ('\n'.join([alias_formatter(alias) for alias in aliases]))

View file

@ -21,7 +21,7 @@
# #
# Author: Konstantin Lepa <konstantin.lepa@gmail.com> # Author: Konstantin Lepa <konstantin.lepa@gmail.com>
"""ANSII Color formatting for output in terminal.""" """ANSI Color formatting for output in terminal."""
from __future__ import print_function from __future__ import print_function
import os import os

View file

@ -2,9 +2,9 @@
This plugin provides completion for [Ant](https://ant.apache.org/). This plugin provides completion for [Ant](https://ant.apache.org/).
To use it add ant to the plugins array in your zshrc file. To use it, add `ant` to the plugins array in your zshrc file:
```bash ```zsh
plugins=(... ant) plugins=(... ant)
``` ```

22
plugins/ant/_ant Normal file
View file

@ -0,0 +1,22 @@
#compdef ant
_ant_does_target_list_need_generating () {
[[ ! -f .ant_targets ]] && return 0
[[ build.xml -nt .ant_targets ]] && return 0
return 1
}
_ant () {
if [[ ! -f build.xml ]]; then
return
fi
if ! _ant_does_target_list_need_generating; then
return
fi
ant -p | awk -F " " 'NR > 5 { print lastTarget } { lastTarget = $1 }' >| .ant_targets
compadd -- "$(cat .ant_targets)"
}
_ant "$@"

View file

@ -1,16 +1,2 @@
_ant_does_target_list_need_generating () { # Default to colored output
[ ! -f .ant_targets ] && return 0; export ANT_ARGS='-logger org.apache.tools.ant.listener.AnsiColorLogger'
[ build.xml -nt .ant_targets ] && return 0;
return 1;
}
_ant () {
if [ -f build.xml ]; then
if _ant_does_target_list_need_generating; then
ant -p | awk -F " " 'NR > 5 { print lastTarget }{lastTarget = $1}' > .ant_targets
fi
compadd -- `cat .ant_targets`
fi
}
compdef _ant ant

View file

@ -14,6 +14,7 @@ plugins=(... arcanist)
| ------- | ---------------------------------- | | ------- | ---------------------------------- |
| ara | `arc amend` | | ara | `arc amend` |
| arb | `arc branch` | | arb | `arc branch` |
| arbl | `arc bland` |
| arco | `arc cover` | | arco | `arc cover` |
| arci | `arc commit` | | arci | `arc commit` |
| ard | `arc diff` | | ard | `arc diff` |
@ -24,6 +25,7 @@ plugins=(... arcanist)
| ardpc | `arc diff --plan-changes` | | ardpc | `arc diff --plan-changes` |
| are | `arc export` | | are | `arc export` |
| arh | `arc help` | | arh | `arc help` |
| arho | `arc hotfix` |
| arl | `arc land` | | arl | `arc land` |
| arli | `arc lint` | | arli | `arc lint` |
| arls | `arc list` | | arls | `arc list` |

View file

@ -5,6 +5,7 @@
alias ara='arc amend' alias ara='arc amend'
alias arb='arc branch' alias arb='arc branch'
alias arbl='arc bland'
alias arco='arc cover' alias arco='arc cover'
alias arci='arc commit' alias arci='arc commit'
@ -17,6 +18,7 @@ alias ardp='arc diff --preview' # creates a new diff in the phab interface
alias are='arc export' alias are='arc export'
alias arh='arc help' alias arh='arc help'
alias arho='arc hotfix'
alias arl='arc land' alias arl='arc land'
alias arli='arc lint' alias arli='arc lint'
alias arls='arc list' alias arls='arc list'

View file

@ -17,8 +17,10 @@ plugins=(... archlinux)
| pacin | `sudo pacman -S` | Install packages from the repositories | | pacin | `sudo pacman -S` | Install packages from the repositories |
| pacins | `sudo pacman -U` | Install a package from a local file | | pacins | `sudo pacman -U` | Install a package from a local file |
| pacinsd | `sudo pacman -S --asdeps` | Install packages as dependencies of another package | | pacinsd | `sudo pacman -S --asdeps` | Install packages as dependencies of another package |
| paclean | `sudo pacman -Sc` | Clean out old and unused caches and packages |
| pacloc | `pacman -Qi` | Display information about a package in the local database | | pacloc | `pacman -Qi` | Display information about a package in the local database |
| paclocs | `pacman -Qs` | Search for packages in the local database | | paclocs | `pacman -Qs` | Search for packages in the local database |
| paclr | `sudo pacman -Scc` | Remove all files from the cache |
| paclsorphans | `sudo pacman -Qdt` | List all orphaned packages | | paclsorphans | `sudo pacman -Qdt` | List all orphaned packages |
| pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist | | pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist |
| pacre | `sudo pacman -R` | Remove packages, keeping its settings and dependencies | | pacre | `sudo pacman -R` | Remove packages, keeping its settings and dependencies |
@ -32,7 +34,7 @@ plugins=(... archlinux)
| pacfiles | `pacman -F` | Search package file names for matching strings | | pacfiles | `pacman -F` | Search package file names for matching strings |
| pacls | `pacman -Ql` | List files in a package | | pacls | `pacman -Ql` | List files in a package |
| pacown | `pacman -Qo` | Show which package owns a file | | pacown | `pacman -Qo` | Show which package owns a file |
| upgrade[²](#f2) | `sudo pacman -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
| Function | Description | | Function | Description |
|----------------|-----------------------------------------------------------| |----------------|-----------------------------------------------------------|
@ -52,6 +54,8 @@ upgrades were available. Use `pacman -Que` instead.
| Alias | Command | Description | | Alias | Command | Description |
|---------|-------------------------------------------------|-------------------------------------------------------------------------| |---------|-------------------------------------------------|-------------------------------------------------------------------------|
| auclean | `sudo aura -Sc` | Clean out old and unused caches and packages |
| auclr | `sudo aura -Scc` | Remove all files from the cache |
| auin | `sudo aura -S` | Install packages from the repositories | | auin | `sudo aura -S` | Install packages from the repositories |
| aurin | `sudo aura -A` | Install packages from the repositories | | aurin | `sudo aura -A` | Install packages from the repositories |
| auins | `sudo aura -U` | Install a package from a local file | | auins | `sudo aura -U` | Install a package from a local file |
@ -73,7 +77,7 @@ upgrades were available. Use `pacman -Que` instead.
| auupd | `sudo aura -Sy` | Update and refresh local package, ABS and AUR databases | | auupd | `sudo aura -Sy` | Update and refresh local package, ABS and AUR databases |
| auupg | `sudo sh -c "aura -Syu && aura -Au"` | Sync with repositories before upgrading all packages (from AUR too) | | auupg | `sudo sh -c "aura -Syu && aura -Au"` | Sync with repositories before upgrading all packages (from AUR too) |
| ausu | `sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"` | Same as `auupg`, but without confirmation | | ausu | `sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"` | Same as `auupg`, but without confirmation |
| upgrade[²](#f2) | `sudo aura -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
| Function | Description | | Function | Description |
|-----------------|---------------------------------------------------------------------| |-----------------|---------------------------------------------------------------------|
@ -84,6 +88,8 @@ upgrades were available. Use `pacman -Que` instead.
| Alias | Command | Description | | Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------| |---------|-----------------------------------|---------------------------------------------------------------------|
| pacclean| `pacaur -Sc` | Clean out old and unused caches and packages |
| pacclr | `pacaur -Scc` | Remove all files from the cache |
| pain | `pacaur -S` | Install packages from the repositories | | pain | `pacaur -S` | Install packages from the repositories |
| pains | `pacaur -U` | Install a package from a local file | | pains | `pacaur -U` | Install a package from a local file |
| painsd | `pacaur -S --asdeps` | Install packages as dependencies of another package | | painsd | `pacaur -S --asdeps` | Install packages as dependencies of another package |
@ -99,13 +105,15 @@ upgrades were available. Use `pacman -Que` instead.
| paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases | | paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
| paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) | | paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation | | pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
| upgrade[²](#f2) | `pacaur -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
#### Trizen #### Trizen
| Alias | Command | Description | | Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------| |---------|-----------------------------------|---------------------------------------------------------------------|
| trconf | `trizen -C` | Fix all configuration files with vimdiff | | trconf | `trizen -C` | Fix all configuration files with vimdiff |
| trclean | `trizen -Sc` | Clean out old and unused caches and packages |
| trclr | `trizen -Scc` | Remove all files from the cache |
| trin | `trizen -S` | Install packages from the repositories | | trin | `trizen -S` | Install packages from the repositories |
| trins | `trizen -U` | Install a package from a local file | | trins | `trizen -U` | Install a package from a local file |
| trinsd | `trizen -S --asdeps` | Install packages as dependencies of another package | | trinsd | `trizen -S --asdeps` | Install packages as dependencies of another package |
@ -121,35 +129,15 @@ upgrades were available. Use `pacman -Que` instead.
| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases | | trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) | | trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation | | trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation |
| upgrade[²](#f2) | `trizen -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages |
#### Yaourt[¹](#f1) #### Yay
| Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------|
| yaconf | `yaourt -C` | Fix all configuration files with vimdiff |
| yain | `yaourt -S` | Install packages from the repositories |
| yains | `yaourt -U` | Install a package from a local file |
| yainsd | `yaourt -S --asdeps` | Install packages as dependencies of another package |
| yaloc | `yaourt -Qi` | Display information about a package in the local database |
| yalocs | `yaourt -Qs` | Search for packages in the local database |
| yalst | `yaourt -Qe` | List installed packages including from AUR (tagged as "local") |
| yamir | `yaourt -Syy` | Force refresh of all package lists after updating mirrorlist |
| yaorph | `yaourt -Qtd` | Remove orphans using yaourt |
| yare | `yaourt -R` | Remove packages, keeping its settings and dependencies |
| yarem | `yaourt -Rns` | Remove packages, including its settings and unneeded dependencies |
| yarep | `yaourt -Si` | Display information about a package in the repositories |
| yareps | `yaourt -Ss` | Search for packages in the repositories |
| yaupd | `yaourt -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yaourt -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| yasu | `yaourt -Syua --no-confirm` | Same as `yaupg`, but without confirmation |
| upgrade[²](#f2) | `yaourt -Syu` | Sync with repositories before upgrading packages |
#### Yay[¹](#f1)
| Alias | Command | Description | | Alias | Command | Description |
|---------|--------------------------------|-------------------------------------------------------------------| |---------|--------------------------------|-------------------------------------------------------------------|
| yaconf | `yay -Pg` | Print current configuration | | yaconf | `yay -Pg` | Print current configuration |
| yaclean | `yay -Sc` | Clean out old and unused caches and packages |
| yaclr | `yay -Scc` | Remove all files from the cache |
| yain | `yay -S` | Install packages from the repositories | | yain | `yay -S` | Install packages from the repositories |
| yains | `yay -U` | Install a package from a local file | | yains | `yay -U` | Install a package from a local file |
| yainsd | `yay -S --asdeps` | Install packages as dependencies of another package | | yainsd | `yay -S --asdeps` | Install packages as dependencies of another package |
@ -165,23 +153,19 @@ upgrades were available. Use `pacman -Que` instead.
| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases | | yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages | | yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
| yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation | | yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation |
| upgrade[²](#f2) | `yay -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages |
--- ---
<span id="f1">¹</span> <span id="f1">¹</span>
Yay and Yaourt aliases overlap. If both are installed, yay will take precedence.
<span id="f2">²</span>
The `upgrade` alias is set for all package managers. Its value will depend on The `upgrade` alias is set for all package managers. Its value will depend on
whether the package manager is installed, checked in the following order: whether the package manager is installed, checked in the following order:
1. `yay` 1. `yay`
2. `yaourt` 2. `trizen`
3. `trizen` 3. `pacaur`
4. `pacaur` 4. `aura`
5. `aura` 5. `pacman`
6. `pacman`
## Contributors ## Contributors
@ -196,3 +180,4 @@ whether the package manager is installed, checked in the following order:
- ornicar - thibault.duplessis@gmail.com - ornicar - thibault.duplessis@gmail.com
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info - Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
- Jeff M. Hubbard - jeffmhubbard@gmail.com - Jeff M. Hubbard - jeffmhubbard@gmail.com
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com

View file

@ -5,7 +5,9 @@
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu' alias pacupg='sudo pacman -Syu'
alias pacin='sudo pacman -S' alias pacin='sudo pacman -S'
alias paclean='sudo pacman -Sc'
alias pacins='sudo pacman -U' alias pacins='sudo pacman -U'
alias paclr='sudo pacman -Scc'
alias pacre='sudo pacman -R' alias pacre='sudo pacman -R'
alias pacrem='sudo pacman -Rns' alias pacrem='sudo pacman -Rns'
alias pacrep='pacman -Si' alias pacrep='pacman -Si'
@ -88,6 +90,8 @@ fi
if (( $+commands[aura] )); then if (( $+commands[aura] )); then
alias auin='sudo aura -S' alias auin='sudo aura -S'
alias aurin='sudo aura -A' alias aurin='sudo aura -A'
alias auclean='sudo aura -Sc'
alias auclr='sudo aura -Scc'
alias auins='sudo aura -U' alias auins='sudo aura -U'
alias auinsd='sudo aura -S --asdeps' alias auinsd='sudo aura -S --asdeps'
alias aurinsd='sudo aura -A --asdeps' alias aurinsd='sudo aura -A --asdeps'
@ -104,7 +108,7 @@ if (( $+commands[aura] )); then
alias auras='aura -As --both' alias auras='aura -As --both'
alias auupd="sudo aura -Sy" alias auupd="sudo aura -Sy"
alias auupg='sudo sh -c "aura -Syu && aura -Au"' alias auupg='sudo sh -c "aura -Syu && aura -Au"'
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"' alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
alias upgrade='sudo aura -Syu' alias upgrade='sudo aura -Syu'
# extra bonus specially for aura # extra bonus specially for aura
@ -115,6 +119,8 @@ if (( $+commands[aura] )); then
fi fi
if (( $+commands[pacaur] )); then if (( $+commands[pacaur] )); then
alias pacclean='pacaur -Sc'
alias pacclr='pacaur -Scc'
alias paupg='pacaur -Syu' alias paupg='pacaur -Syu'
alias pasu='pacaur -Syu --noconfirm' alias pasu='pacaur -Syu --noconfirm'
alias pain='pacaur -S' alias pain='pacaur -S'
@ -138,6 +144,8 @@ if (( $+commands[trizen] )); then
alias trupg='trizen -Syua' alias trupg='trizen -Syua'
alias trsu='trizen -Syua --noconfirm' alias trsu='trizen -Syua --noconfirm'
alias trin='trizen -S' alias trin='trizen -S'
alias trclean='trizen -Sc'
alias trclr='trizen -Scc'
alias trins='trizen -U' alias trins='trizen -U'
alias trre='trizen -R' alias trre='trizen -R'
alias trrem='trizen -Rns' alias trrem='trizen -Rns'
@ -153,28 +161,10 @@ if (( $+commands[trizen] )); then
alias upgrade='trizen -Syu' alias upgrade='trizen -Syu'
fi fi
if (( $+commands[yaourt] )); then
alias yaconf='yaourt -C'
alias yaupg='yaourt -Syua'
alias yasu='yaourt -Syua --noconfirm'
alias yain='yaourt -S'
alias yains='yaourt -U'
alias yare='yaourt -R'
alias yarem='yaourt -Rns'
alias yarep='yaourt -Si'
alias yareps='yaourt -Ss'
alias yaloc='yaourt -Qi'
alias yalocs='yaourt -Qs'
alias yalst='yaourt -Qe'
alias yaorph='yaourt -Qtd'
alias yainsd='yaourt -S --asdeps'
alias yamir='yaourt -Syy'
alias yaupd="yaourt -Sy"
alias upgrade='yaourt -Syu'
fi
if (( $+commands[yay] )); then if (( $+commands[yay] )); then
alias yaconf='yay -Pg' alias yaconf='yay -Pg'
alias yaclean='yay -Sc'
alias yaclr='yay -Scc'
alias yaupg='yay -Syu' alias yaupg='yay -Syu'
alias yasu='yay -Syu --noconfirm' alias yasu='yay -Syu --noconfirm'
alias yain='yay -S' alias yain='yay -S'
@ -192,4 +182,3 @@ if (( $+commands[yay] )); then
alias yaupd="yay -Sy" alias yaupd="yay -Sy"
alias upgrade='yay -Syu' alias upgrade='yay -Syu'
fi fi

View file

@ -2,18 +2,26 @@
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}" ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
ASDF_COMPLETIONS="$ASDF_DIR/completions" ASDF_COMPLETIONS="$ASDF_DIR/completions"
# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
ASDF_DIR="/opt/asdf-vm"
ASDF_COMPLETIONS="$ASDF_DIR"
fi
# If not found, check for Homebrew package # If not found, check for Homebrew package
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
ASDF_DIR="$(brew --prefix asdf)" brew_prefix="$(brew --prefix asdf)"
ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d" ASDF_DIR="${brew_prefix}/libexec"
ASDF_COMPLETIONS="${brew_prefix}/etc/bash_completion.d"
unset brew_prefix
fi fi
# Load command # Load command
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
. "$ASDF_DIR/asdf.sh" . "$ASDF_DIR/asdf.sh"
# Load completions # Load completions
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
. "$ASDF_COMPLETIONS/asdf.bash" . "$ASDF_COMPLETIONS/asdf.bash"
fi fi
fi fi

View file

@ -13,6 +13,7 @@ if ! type autoenv_init >/dev/null; then
~/.autoenv ~/.autoenv
~/.local/bin ~/.local/bin
/usr/local/opt/autoenv /usr/local/opt/autoenv
/opt/homebrew/opt/autoenv
/usr/local/bin /usr/local/bin
/usr/share/autoenv-git /usr/share/autoenv-git
~/Library/Python/bin ~/Library/Python/bin

View file

@ -8,8 +8,10 @@ autojump_paths=(
/etc/profile.d/autojump.zsh # manual installation /etc/profile.d/autojump.zsh # manual installation
/etc/profile.d/autojump.sh # Gentoo installation /etc/profile.d/autojump.sh # Gentoo installation
/usr/local/share/autojump/autojump.zsh # FreeBSD installation /usr/local/share/autojump/autojump.zsh # FreeBSD installation
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default) /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
) )
for file in $autojump_paths; do for file in $autojump_paths; do

View file

@ -14,11 +14,12 @@ plugins=(... aws)
* `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`. * `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
Run `asp` without arguments to clear the profile. Run `asp` without arguments to clear the profile.
* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
* `acp [<profile>]`: in addition to `asp` functionality, it actually changes the profile by * `acp [<profile>] [<mfa_token>]`: in addition to `asp` functionality, it actually changes
assuming the role specified in the `<profile>` configuration. It supports MFA and sets the profile by assuming the role specified in the `<profile>` configuration. It supports
`$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if
requires the roles to be configured as per the obtained. It requires the roles to be configured as per the
[official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html). [official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
Run `acp` without arguments to clear the profile. Run `acp` without arguments to clear the profile.

View file

@ -21,6 +21,10 @@ function asp() {
export AWS_DEFAULT_PROFILE=$1 export AWS_DEFAULT_PROFILE=$1
export AWS_PROFILE=$1 export AWS_PROFILE=$1
export AWS_EB_PROFILE=$1 export AWS_EB_PROFILE=$1
if [[ "$2" == "login" ]]; then
aws sso login
fi
} }
# AWS profile switch # AWS profile switch
@ -41,6 +45,7 @@ function acp() {
fi fi
local profile="$1" local profile="$1"
local mfa_token="$2"
# Get fallback credentials for if the aws command fails or no command is run # Get fallback credentials for if the aws command fails or no command is run
local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)" local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
@ -54,9 +59,10 @@ function acp() {
if [[ -n "$mfa_serial" ]]; then if [[ -n "$mfa_serial" ]]; then
local -a mfa_opt local -a mfa_opt
local mfa_token if [[ -z "$mfa_token" ]]; then
echo -n "Please enter your MFA token for $mfa_serial: " echo -n "Please enter your MFA token for $mfa_serial: "
read -r mfa_token read -r mfa_token
fi
if [[ -z "$sess_duration" ]]; then if [[ -z "$sess_duration" ]]; then
echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): " echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
read -r sess_duration read -r sess_duration
@ -151,8 +157,8 @@ compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt # AWS prompt
function aws_prompt_info() { function aws_prompt_info() {
[[ -z $AWS_PROFILE ]] && return [[ -n "$AWS_PROFILE" ]] || return
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}" echo "${ZSH_THEME_AWS_PREFIX=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX=>}"
} }
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then

View file

@ -8,15 +8,22 @@ To use, add `battery` to the list of plugins in your `.zshrc` file:
Then, add the `battery_pct_prompt` function to your custom theme. For example: Then, add the `battery_pct_prompt` function to your custom theme. For example:
``` ```zsh
RPROMPT='$(battery_pct_prompt) ...' RPROMPT='$(battery_pct_prompt) ...'
``` ```
## Requirements ## Requirements
On Linux, you must have the `acpi` tool installed on your operating system. - On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.
On Debian/Ubuntu, you can do that with `sudo apt install acpi` or `sudo apt install acpitool`.
Here's an example of how to install with apt: - On Android (via [Termux](https://play.google.com/store/apps/details?id=com.termux)), you must have:
```
sudo apt-get install acpi 1. The `Termux:API` addon app installed:
``` [Google Play](https://play.google.com/store/apps/details?id=com.termux.api) | [F-Droid](https://f-droid.org/packages/com.termux.api/)
2. The `termux-api` package installed within termux:
```sh
pkg install termux-api
```

View file

@ -10,17 +10,17 @@
# Author: J (927589452) # # Author: J (927589452) #
# Modified to add support for FreeBSD # # Modified to add support for FreeBSD #
########################################### ###########################################
# Author: Avneet Singh (kalsi-avneet) #
# Modified to add support for Android #
###########################################
if [[ "$OSTYPE" = darwin* ]]; then if [[ "$OSTYPE" = darwin* ]]; then
function battery_is_charging() { function battery_is_charging() {
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes' ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
} }
function battery_pct() { function battery_pct() {
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1 pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if battery_is_charging; then if battery_is_charging; then
echo "External Power" echo "External Power"
@ -28,7 +28,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
battery_pct battery_pct
fi fi
} }
function battery_time_remaining() { function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
@ -42,7 +41,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
echo "∞" echo "∞"
fi fi
} }
function battery_pct_prompt () { function battery_pct_prompt () {
local battery_pct color local battery_pct color
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
@ -61,17 +59,14 @@ if [[ "$OSTYPE" = darwin* ]]; then
} }
elif [[ "$OSTYPE" = freebsd* ]]; then elif [[ "$OSTYPE" = freebsd* ]]; then
function battery_is_charging() { function battery_is_charging() {
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]] [[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
} }
function battery_pct() { function battery_pct() {
if (( $+commands[sysctl] )); then if (( $+commands[sysctl] )); then
sysctl -n hw.acpi.battery.life sysctl -n hw.acpi.battery.life
fi fi
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if ! battery_is_charging; then if ! battery_is_charging; then
battery_pct battery_pct
@ -79,7 +74,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo "External Power" echo "External Power"
fi fi
} }
function battery_time_remaining() { function battery_time_remaining() {
local remaining_time local remaining_time
remaining_time=$(sysctl -n hw.acpi.battery.time) remaining_time=$(sysctl -n hw.acpi.battery.time)
@ -89,7 +83,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
printf %02d:%02d $hour $minute printf %02d:%02d $hour $minute
fi fi
} }
function battery_pct_prompt() { function battery_pct_prompt() {
local battery_pct color local battery_pct color
battery_pct=$(battery_pct_remaining) battery_pct=$(battery_pct_remaining)
@ -106,19 +99,22 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}" echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi fi
} }
elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )); then
elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() { function battery_is_charging() {
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging' termux-battery-status 2>/dev/null | command awk '/status/ { exit ($0 ~ /DISCHARGING/) }'
} }
function battery_pct() { function battery_pct() {
if (( $+commands[acpi] )); then # Sample output:
acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Full|(Disc|C)harging)' | cut -f2 -d ',' | tr -cd '[:digit:]' # {
fi # "health": "GOOD",
# "percentage": 93,
# "plugged": "UNPLUGGED",
# "status": "DISCHARGING",
# "temperature": 29.0,
# "current": 361816
# }
termux-battery-status 2>/dev/null | command awk '/percentage/ { gsub(/[,]/,""); print $2}'
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if ! battery_is_charging; then if ! battery_is_charging; then
battery_pct battery_pct
@ -126,13 +122,72 @@ elif [[ "$OSTYPE" = linux* ]]; then
echo "External Power" echo "External Power"
fi fi
} }
function battery_time_remaining() { } # Not available on android
function battery_time_remaining() { function battery_pct_prompt() {
if ! battery_is_charging; then local battery_pct color
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ',' battery_pct=$(battery_pct_remaining)
fi if battery_is_charging; then
} echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() {
if (( $+commands[acpitool] )); then
! acpitool 2>/dev/null | command grep -qE '^\s+Battery.*Discharging'
elif (( $+commands[acpi] )); then
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
fi
}
function battery_pct() {
if (( $+commands[acpitool] )); then
# Sample output:
# Battery #1 : Unknown, 99.55%
# Battery #2 : Discharging, 49.58%, 01:12:05
# All batteries : 62.60%, 02:03:03
local -i pct=$(acpitool 2>/dev/null | command awk -F, '
/^\s+All batteries/ {
gsub(/[^0-9.]/, "", $1)
pct=$1
exit
}
!pct && /^\s+Battery/ {
gsub(/[^0-9.]/, "", $2)
pct=$2
}
END { print pct }
')
echo $pct
elif (( $+commands[acpi] )); then
# Sample output:
# Battery 0: Discharging, 0%, rate information unavailable
# Battery 1: Full, 100%
acpi 2>/dev/null | command awk -F, '
/rate information unavailable/ { next }
/^Battery.*: /{ gsub(/[^0-9]/, "", $2); print $2; exit }
'
fi
}
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else
echo "External Power"
fi
}
function battery_time_remaining() {
if ! battery_is_charging; then
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
fi
}
function battery_pct_prompt() { function battery_pct_prompt() {
local battery_pct color local battery_pct color
battery_pct=$(battery_pct_remaining) battery_pct=$(battery_pct_remaining)
@ -149,7 +204,6 @@ elif [[ "$OSTYPE" = linux* ]]; then
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}" echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi fi
} }
else else
# Empty functions so we don't cause errors in prompts # Empty functions so we don't cause errors in prompts
function battery_is_charging { false } function battery_is_charging { false }
@ -174,7 +228,7 @@ function battery_level_gauge() {
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow} local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'} local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
local battery_remaining_percentage=$(battery_pct) local -i battery_remaining_percentage=$(battery_pct)
local filled empty gauge_color local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then

View file

@ -1,5 +1,14 @@
## Bazel autocomplete plugin # Bazel plugin
A copy of the completion script from the This plugin adds completion for [bazel](https://bazel.build), an open-source build and
[bazelbuild/bazel](https://github.com/bazelbuild/bazel/master/scripts/zsh_completion/_bazel) test tool that scalably supports multi-language and multi-platform projects.
git repo.
To use it, add `bazel` to the plugins array in your zshrc file:
```zsh
plugins=(... bazel)
```
The plugin has a copy of [the completion script from the git repository][1].
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel

View file

@ -164,7 +164,7 @@ _get_build_targets() {
;; ;;
esac esac
completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:}) completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:})
if ( (( ${#completions} > 0 )) && [[ $target_type != run ]] ); then if ( (( ${#completions} > 0 )) && [[ $target_type != bin ]] ); then
completions+=(all) completions+=(all)
fi fi
echo ${completions[*]} echo ${completions[*]}

View file

@ -20,6 +20,12 @@ if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom functi
} }
fi fi
currentAppId () {
if (( $+commands[osascript] )); then
osascript -e 'tell application (path to frontmost application as text) to id' 2>/dev/null
fi
}
currentWindowId () { currentWindowId () {
if hash osascript 2>/dev/null; then #osx if hash osascript 2>/dev/null; then #osx
osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0" osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0"
@ -32,11 +38,20 @@ currentWindowId () {
bgnotify () { ## args: (title, subtitle) bgnotify () { ## args: (title, subtitle)
if hash terminal-notifier 2>/dev/null; then #osx if hash terminal-notifier 2>/dev/null; then #osx
[[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2'; local term_id="$bgnotify_appid"
[[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal'; if [[ -z "$term_id" ]]; then
case "$TERM_PROGRAM" in
iTerm.app) term_id='com.googlecode.iterm2' ;;
Apple_Terminal) term_id='com.apple.terminal' ;;
esac
fi
## now call terminal-notifier, (hopefully with $term_id!) ## now call terminal-notifier, (hopefully with $term_id!)
[ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null || if [[ -z "$term_id" ]]; then
terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null terminal-notifier -message "$2" -title "$1" >/dev/null
else
terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null
fi
elif hash growlnotify 2>/dev/null; then #osx growl elif hash growlnotify 2>/dev/null; then #osx growl
growlnotify -m "$1" "$2" growlnotify -m "$1" "$2"
elif hash notify-send 2>/dev/null; then #ubuntu gnome! elif hash notify-send 2>/dev/null; then #ubuntu gnome!
@ -54,6 +69,7 @@ bgnotify () { ## args: (title, subtitle)
bgnotify_begin() { bgnotify_begin() {
bgnotify_timestamp=$EPOCHSECONDS bgnotify_timestamp=$EPOCHSECONDS
bgnotify_lastcmd="${1:-$2}" bgnotify_lastcmd="${1:-$2}"
bgnotify_appid="$(currentAppId)"
bgnotify_windowid=$(currentWindowId) bgnotify_windowid=$(currentWindowId)
} }
@ -62,7 +78,7 @@ bgnotify_end() {
elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
past_threshold=$(( elapsed >= bgnotify_threshold )) past_threshold=$(( elapsed >= bgnotify_threshold ))
if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then
if [ $(currentWindowId) != "$bgnotify_windowid" ]; then if [[ $(currentAppId) != "$bgnotify_appid" || $(currentWindowId) != "$bgnotify_windowid" ]]; then
print -n "\a" print -n "\a"
bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed"
fi fi

View file

@ -1,6 +0,0 @@
## Boot2docker autocomplete plugin
- Adds autocomplete options for all boot2docker commands.
Maintainer : Manfred Touron ([@moul](https://github.com/moul))

View file

@ -1,73 +0,0 @@
#compdef boot2docker
# Boot2docker autocompletion for oh-my-zsh
# Requires: Boot2docker installed
# Author: Manfred Touron (@moul)
local -a _1st_arguments
_1st_arguments=(
"init":"Create a new Boot2Docker VM."
"up":"Start VM from any states."
"start":"Start VM from any states."
"boot":"Start VM from any states."
"ssh":"[ssh-command] Login to VM via SSH."
"save":"Suspend VM and save state to disk."
"suspend":"Suspend VM and save state to disk."
"down":"Gracefully shutdown the VM."
"stop":"Gracefully shutdown the VM."
"halt":"Gracefully shutdown the VM."
"restart":"Gracefully reboot the VM."
"poweroff":"Forcefully power off the VM (may corrupt disk image)."
"reset":"Forcefully power cycle the VM (may corrupt disk image)."
"delete":"Delete Boot2Docker VM and its disk image."
"destroy":"Delete Boot2Docker VM and its disk image."
"config":"Show selected profile file settings."
"cfg":"Show selected profile file settings."
"info":"Display detailed information of VM."
"ip":"Display the IP address of the VM's Host-only network."
"socket":"Display the DOCKER_HOST socket to connect to."
"shellinit":"Display the shell command to set up the Docker client."
"status":"Display current state of VM."
"download":"Download Boot2Docker ISO image."
"upgrade":"Upgrade the Boot2Docker ISO image (restart if running)."
"version":"Display version information."
)
_arguments \
'(--basevmdk)--basevmdk[Path to VMDK to use as base for persistent partition]' \
'(--cpus)'{-c,--cpus}'[number of CPUs for boot2docker.]' \
'(--clobber)--clobber[overwrite Docker client binary on boot2docker upgrade]' \
'(--dhcp)--dhcp[enable VirtualBox host-only network DHCP.]' \
'(--dhcpip)--dhcpip[VirtualBox host-only network DHCP server address.]' \
'(-s --disksize)'{-s,--disksize}'[boot2docker disk image size (in MB).]' \
'(--dockerport)--dockerport[host Docker port (forward to port 2376 in VM). (deprecated - use with care)]' \
'(--driver)--driver[hypervisor driver.]' \
'(--force-upgrade-download)--force-upgrade-download[always download on boot2docker upgrade, never skip.]' \
'(--hostip)--hostip[VirtualBox host-only network IP address.]' \
'(--iso)--iso[path to boot2docker ISO image.]' \
'(--iso-url)--iso-url[/api.github.com/repos/boot2docker/boot2docker/releases": source URL to provision the boot2docker ISO image.]' \
'(--lowerip)--lowerip[VirtualBox host-only network DHCP lower bound.]' \
'(--memory)'{-m,--memory}'[virtual machine memory size (in MB).]' \
'(--netmask)--netmask[VirtualBox host-only network mask.]' \
'(--no-dummy)--no-dummy[Example parameter for the dummy driver.]' \
'(--retries)--retries[number of port knocking retries during 'start']' \
'(--serial)--serial[try serial console to get IP address (experimental)]' \
'(--serialfile)--serialfile[path to the serial socket/pipe.]' \
'(--ssh)--ssh[path to SSH client utility.]' \
'(--ssh-keygen)--ssh-keygen[path to ssh-keygen utility.]' \
'(--sshkey)--sshkey[path to SSH key to use.]' \
'(--sshport)--sshport[host SSH port (forward to port 22 in VM).]' \
'(--upperip)--upperip[VirtualBox host-only network DHCP upper bound.]' \
'(--vbm)--vbm[path to VirtualBox management utility.]' \
'(--vbox-share)--vbox-share[(defaults to "/Users=Users" if no shares are specified; use "disable" to explicitly prevent any shares from being created) List of directories to share during "up|start|boot" via VirtualBox Guest Additions, with optional labels]' \
'(--verbose)'{-v,--verbose}'[display verbose command invocations.]' \
'(--vm)--vm[virtual machine name.]' \
'(--waittime)--waittime[Time in milliseconds to wait between port knocking retries during 'start']' \
'*:: :->subcmds' && return 0
#_arguments '*:: :->command'
if (( CURRENT == 1 )); then
_describe -t commands "boot2docker command" _1st_arguments
return
fi

View file

@ -9,7 +9,7 @@ _bower_installed_packages () {
} }
_bower () _bower ()
{ {
local -a _1st_arguments _no_color _dopts _save_dev _force_lastest _production local -a _1st_arguments _no_color _dopts _save_dev _force_latest _production
local expl local expl
typeset -A opt_args typeset -A opt_args
@ -22,7 +22,7 @@ _bower ()
_save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]') _save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]')
_force_lastest=('(--force-latest)--force-latest[Force latest version on conflict]') _force_latest=('(--force-latest)--force-latest[Force latest version on conflict]')
_production=('(--production)--production[Do not install project devDependencies]') _production=('(--production)--production[Do not install project devDependencies]')
@ -54,7 +54,7 @@ _bower ()
_arguments \ _arguments \
$_dopts \ $_dopts \
$_save_dev \ $_save_dev \
$_force_lastest \ $_force_latest \
$_no_color \ $_no_color \
$_production $_production
;; ;;
@ -62,7 +62,7 @@ _bower ()
_arguments \ _arguments \
$_dopts \ $_dopts \
$_no_color \ $_no_color \
$_force_lastest $_force_latest
_bower_installed_packages _bower_installed_packages
compadd "$@" $(echo $bower_package_list) compadd "$@" $(echo $bower_package_list)
;; ;;

View file

@ -1,31 +1,47 @@
# Branch # Branch plugin
Displays the current Git or Mercurial branch fast. This plugin displays the current Git or Mercurial branch, fast. If in a Mercurial repository,
also display the current bookmark, if present.
To use it, add `branch` to the plugins array in your zshrc file:
```zsh
plugins=(... branch)
```
## Speed test ## Speed test
### Mercurial - `hg branch`:
```shell ```console
$ time hg branch $ time hg branch
0.11s user 0.14s system 70% cpu 0.355 total 0.11s user 0.14s system 70% cpu 0.355 total
``` ```
### Branch plugin - branch plugin:
```shell ```console
$ time zsh /tmp/branch_prompt_info_test.zsh $ time zsh /tmp/branch_prompt_info_test.zsh
0.00s user 0.01s system 78% cpu 0.014 total 0.00s user 0.01s system 78% cpu 0.014 total
``` ```
## Usage ## Usage
Edit your theme file (eg.: `~/.oh-my-zsh/theme/robbyrussell.zsh-theme`) Copy your theme to `$ZSH_CUSTOM/themes/` and modify it to add `$(branch_prompt_info)` in your prompt.
adding `$(branch_prompt_info)` in your prompt like this: This example is for the `robbyrussell` theme:
```diff ```diff
- PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme
+ PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(branch_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' index 2fd5f2cd..9d89a464 100644
--- a/themes/robbyrussell.zsh-theme
+++ b/themes/robbyrussell.zsh-theme
@@ -1,5 +1,5 @@
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
-PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
+PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(branch_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
``` ```
## Maintainer ## Maintainer

View file

@ -3,29 +3,33 @@
# Oct 2, 2015 # Oct 2, 2015
function branch_prompt_info() { function branch_prompt_info() {
# Defines path as current directory # Start checking in current working directory
local current_dir=$PWD local branch="" dir="$PWD"
# While current path is not root path while [[ "$dir" != '/' ]]; do
while [[ $current_dir != '/' ]] # Found .git directory
do if [[ -d "${dir}/.git" ]]; then
# Git repository branch="${"$(<"${dir}/.git/HEAD")"##*/}"
if [[ -d "${current_dir}/.git" ]] echo '±' "${branch:gs/%/%%}"
then return
echo '±' ${"$(<"$current_dir/.git/HEAD")"##*/}
return;
fi fi
# Mercurial repository
if [[ -d "${current_dir}/.hg" ]] # Found .hg directory
then if [[ -d "${dir}/.hg" ]]; then
if [[ -f "$current_dir/.hg/branch" ]] if [[ -f "${dir}/.hg/branch" ]]; then
then branch="$(<"${dir}/.hg/branch")"
echo '☿' $(<"$current_dir/.hg/branch")
else else
echo '☿ default' branch="default"
fi fi
return;
if [[ -f "${dir}/.hg/bookmarks.current" ]]; then
branch="${branch}/$(<"${dir}/.hg/bookmarks.current")"
fi
echo '☿' "${branch:gs/%/%%}"
return
fi fi
# Defines path as parent directory and keeps looking for :)
current_dir="${current_dir:h}" # Check parent directory
dir="${dir:h}"
done done
} }

View file

@ -1,5 +1,4 @@
alias brewp='brew pin' alias brewp='brew pin'
alias brews='brew list -1'
alias brewsp='brew list --pinned' alias brewsp='brew list --pinned'
alias bubo='brew update && brew outdated' alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup' alias bubc='brew upgrade && brew cleanup'
@ -7,3 +6,16 @@ alias bubu='bubo && bubc'
alias buf='brew upgrade --formula' alias buf='brew upgrade --formula'
alias bcubo='brew update && brew outdated --cask' alias bcubo='brew update && brew outdated --cask'
alias bcubc='brew upgrade --cask && brew cleanup' alias bcubc='brew upgrade --cask && brew cleanup'
function brews() {
local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
local casks="$(brew list --cask)"
local blue="$(tput setaf 4)"
local bold="$(tput bold)"
local off="$(tput sgr0)"
echo "${blue}==>${off} ${bold}Formulae${off}"
echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/"
echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}"
}

View file

@ -18,6 +18,7 @@ case $state in
"check[Determine whether the requirements for your application are installed]" \ "check[Determine whether the requirements for your application are installed]" \
"list[Show all of the gems in the current bundle]" \ "list[Show all of the gems in the current bundle]" \
"show[Show the source location of a particular gem in the bundle]" \ "show[Show the source location of a particular gem in the bundle]" \
"info[Show details of a particular gem in the bundle]" \
"outdated[Show all of the outdated gems in the current bundle]" \ "outdated[Show all of the outdated gems in the current bundle]" \
"console[Start an IRB session in the context of the current bundle]" \ "console[Start an IRB session in the context of the current bundle]" \
"open[Open an installed gem in the editor]" \ "open[Open an installed gem in the editor]" \
@ -84,7 +85,7 @@ case $state in
'(--verbose)--verbose[Enable verbose output mode]' '(--verbose)--verbose[Enable verbose output mode]'
ret=0 ret=0
;; ;;
(open|show) (open|show|info)
_gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') ) _gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') )
if [[ $_gems != "" ]]; then if [[ $_gems != "" ]]; then
_values 'gems' $_gems && ret=0 _values 'gems' $_gems && ret=0

View file

@ -40,7 +40,7 @@ bundle_install() {
else else
local cores_num="$(nproc)" local cores_num="$(nproc)"
fi fi
bundle install --jobs="$cores_num" "$@" BUNDLE_JOBS="$cores_num" bundle install "$@"
} }
## Gem wrapper ## Gem wrapper
@ -81,14 +81,12 @@ bundled_commands=(
) )
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list # Remove $UNBUNDLED_COMMANDS from the bundled_commands list
for cmd in $UNBUNDLED_COMMANDS; do bundled_commands=(${bundled_commands:|UNBUNDLED_COMMANDS})
bundled_commands=(${bundled_commands#$cmd}); unset UNBUNDLED_COMMANDS
done
# Add $BUNDLED_COMMANDS to the bundled_commands list # Add $BUNDLED_COMMANDS to the bundled_commands list
for cmd in $BUNDLED_COMMANDS; do bundled_commands+=($BUNDLED_COMMANDS)
bundled_commands+=($cmd); unset BUNDLED_COMMANDS
done
# Check if in the root or a subdirectory of a bundled project # Check if in the root or a subdirectory of a bundled project
_within-bundled-project() { _within-bundled-project() {
@ -126,5 +124,4 @@ for cmd in $bundled_commands; do
compdef "_$cmd" "bundled_$cmd"="$cmd" compdef "_$cmd" "bundled_$cmd"="$cmd"
fi fi
done done
unset cmd bundled_commands unset cmd bundled_commands

View file

@ -1,11 +1,3 @@
# cargo # cargo
This plugin adds completion for the Rust build tool [`Cargo`](https://github.com/rust-lang/cargo). **Deprecated: use the [`rust`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/rust) plugin instead.**
To use it, add `cargo` to the plugins array in your zshrc file:
```zsh
plugins=(... cargo)
```
Updated on March 3rd, 2019, from [Cargo 0.34.0](https://github.com/rust-lang/cargo/releases/tag/0.34.0).

View file

@ -1,407 +0,0 @@
#compdef cargo
autoload -U regexp-replace
_cargo() {
local curcontext="$curcontext" ret=1
local -a command_scope_spec common parallel features msgfmt triple target registry
local -a state line state_descr # These are set by _arguments
typeset -A opt_args
common=(
'(-q --quiet)*'{-v,--verbose}'[use verbose output]'
'(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
'-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
'--frozen[require that Cargo.lock and cache are up to date]'
'--locked[require that Cargo.lock is up to date]'
'--color=[specify colorization option]:coloring:(auto always never)'
'(- 1 *)'{-h,--help}'[show help message]'
)
# leading items in parentheses are an exclusion list for the arguments following that arg
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
# - => exclude all other options
# 1 => exclude positional arg 1
# * => exclude all other args
# +blah => exclude +blah
_arguments -s -S -C $common \
'(- 1 *)--list[list installed commands]' \
'(- 1 *)--explain=[provide a detailed explanation of an error message]:error code' \
'(- 1 *)'{-V,--version}'[show version information]' \
'(+beta +nightly)+stable[use the stable toolchain]' \
'(+stable +nightly)+beta[use the beta toolchain]' \
'(+stable +beta)+nightly[use the nightly toolchain]' \
'1: :_cargo_cmds' \
'*:: :->args'
# These flags are mutually exclusive specifiers for the scope of a command; as
# they are used in multiple places without change, they are expanded into the
# appropriate command's `_arguments` where appropriate.
command_scope_spec=(
'(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names'
'(--bench --bin --test --lib)--example=[specify example name]:example name'
'(--bench --example --test --lib)--bin=[specify binary name]:binary name'
'(--bench --bin --example --test)--lib=[specify library name]:library name'
'(--bench --bin --example --lib)--test=[specify test name]:test name'
)
parallel=(
'(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]'
)
features=(
'(--all-features)--features=[specify features to activate]:feature'
'(--features)--all-features[activate all available features]'
"--no-default-features[don't build the default features]"
)
msgfmt='--message-format=[specify error format]:error format [human]:(human json short)'
triple='--target=[specify target triple]:target triple'
target='--target-dir=[specify directory for all generated artifacts]:directory:_directories'
manifest='--manifest-path=[specify path to manifest]:path:_directories'
registry='--registry=[specify registry to use]:registry'
case $state in
args)
curcontext="${curcontext%:*}-${words[1]}:"
case ${words[1]} in
bench)
_arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \
"${command_scope_spec[@]}" \
'--all-targets[benchmark all targets]' \
"--no-run[compile but don't run]" \
'(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \
'--exclude=[exclude packages from the benchmark]:spec' \
'--no-fail-fast[run all benchmarks regardless of failure]' \
'1: :_guard "^-*" "bench name"' \
'*:args:_default'
;;
build|b)
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
"${command_scope_spec[@]}" \
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
'--release[build in release mode]' \
'--build-plan[output the build plan in JSON]' \
;;
check|c)
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
"${command_scope_spec[@]}" \
'(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \
'--release[check in release mode]' \
;;
clean)
_arguments -s -S $common $triple $target $manifest \
'(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \
'--release[clean release artifacts]' \
'--doc[clean just the documentation directory]'
;;
doc)
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--no-deps[do not build docs for dependencies]' \
'--document-private-items[include non-public items in the documentation]' \
'--open[open docs in browser after the build]' \
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
'--release[build artifacts in release mode, with optimizations]' \
;;
fetch)
_arguments -s -S $common $triple $manifest
;;
fix)
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
"${command_scope_spec[@]}" \
'--broken-code[fix code even if it already has compiler errors]' \
'--edition[fix in preparation for the next edition]' \
'--edition-idioms[fix warnings to migrate to the idioms of an edition]' \
'--allow-no-vcs[fix code even if a VCS was not detected]' \
'--allow-dirty[fix code even if the working directory is dirty]' \
'--allow-staged[fix code even if the working directory has staged changes]'
;;
generate-lockfile)
_arguments -s -S $common $manifest
;;
git-checkout)
_arguments -s -S $common \
'--reference=:reference' \
'--url=:url:_urls'
;;
help)
_cargo_cmds
;;
init)
_arguments -s -S $common $registry \
'--lib[use library template]' \
'--edition=[specify edition to set for the crate generated]:edition:(2015 2018)' \
'--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \
'--name=[set the resulting package name]:name' \
'1:path:_directories'
;;
install)
_arguments -s -S $common $parallel $features $triple $registry \
'(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \
'--bin=[only install the specified binary]:binary' \
'--branch=[branch to use when installing from git]:branch' \
'--debug[build in debug mode instead of release mode]' \
'--example=[install the specified example instead of binaries]:example' \
'--git=[specify URL from which to install the crate]:url:_urls' \
'--path=[local filesystem path to crate to install]: :_directories' \
'--rev=[specific commit to use when installing from git]:commit' \
'--root=[directory to install packages into]: :_directories' \
'--tag=[tag to use when installing from git]:tag' \
'--vers=[version to install from crates.io]:version' \
'--list[list all installed packages and their versions]' \
'*: :_guard "^-*" "crate"'
;;
locate-project)
_arguments -s -S $common $manifest
;;
login)
_arguments -s -S $common $registry \
'*: :_guard "^-*" "token"'
;;
metadata)
_arguments -s -S $common $features $manifest \
"--no-deps[output information only about the root package and don't fetch dependencies]" \
'--format-version=[specify format version]:version [1]:(1)'
;;
new)
_arguments -s -S $common $registry \
'--lib[use library template]' \
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
'--name=[set the resulting package name]'
;;
owner)
_arguments -s -S $common $registry \
'(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \
'--index=[specify registry index]:index' \
'(-l --list)'{-l,--list}'[list owners of a crate]' \
'(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \
'--token=[specify API token to use when authenticating]:token' \
'*: :_guard "^-*" "crate"'
;;
package)
_arguments -s -S $common $parallel $features $triple $target $manifest \
'(-l --list)'{-l,--list}'[print files included in a package without making one]' \
'--no-metadata[ignore warnings about a lack of human-usable metadata]' \
'--allow-dirty[allow dirty working directories to be packaged]' \
"--no-verify[don't build to verify contents]"
;;
pkgid)
_arguments -s -S $common $manifest \
'(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \
'*: :_guard "^-*" "spec"'
;;
publish)
_arguments -s -S $common $parallel $features $triple $target $manifest $registry \
'--index=[specify registry index]:index' \
'--allow-dirty[allow dirty working directories to be packaged]' \
"--no-verify[don't verify the contents by building them]" \
'--token=[specify token to use when uploading]:token' \
'--dry-run[perform all checks without uploading]'
;;
read-manifest)
_arguments -s -S $common $manifest
;;
run|r)
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--example=[name of the bin target]:name' \
'--bin=[name of the bin target]:name' \
'(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \
'--release[build in release mode]' \
'*: :_default'
;;
rustc)
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
'--profile=[specify profile to build the selected target for]:profile' \
'--release[build artifacts in release mode, with optimizations]' \
"${command_scope_spec[@]}" \
'*: : _dispatch rustc rustc -default-'
;;
rustdoc)
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--document-private-items[include non-public items in the documentation]' \
'--open[open the docs in a browser after the operation]' \
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
'--release[build artifacts in release mode, with optimizations]' \
"${command_scope_spec[@]}" \
'*: : _dispatch rustdoc rustdoc -default-'
;;
search)
_arguments -s -S $common $registry \
'--index=[specify registry index]:index' \
'--limit=[limit the number of results]:results [10]' \
'*: :_guard "^-*" "query"'
;;
test|t)
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--test=[test name]: :_cargo_test_names' \
'--no-fail-fast[run all tests regardless of failure]' \
'--no-run[compile but do not run]' \
'(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \
'--all[test all packages in the workspace]' \
'--release[build artifacts in release mode, with optimizations]' \
'1: :_cargo_test_names' \
'(--doc --bin --example --test --bench)--lib[only test library]' \
'(--lib --bin --example --test --bench)--doc[only test documentation]' \
'(--lib --doc --example --test --bench)--bin=[binary name]' \
'(--lib --doc --bin --test --bench)--example=[example name]' \
'(--lib --doc --bin --example --bench)--test=[test name]' \
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \
'*: :_default'
;;
uninstall)
_arguments -s -S $common \
'(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \
'--bin=[only uninstall the specified binary]:name' \
'--root=[directory to uninstall packages from]: :_files -/' \
'*:crate:_cargo_installed_crates -F line'
;;
update)
_arguments -s -S $common $manifest \
'--aggressive=[force dependency update]' \
"--dry-run[don't actually write the lockfile]" \
'(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \
'--precise=[update single dependency to precise release]:release'
;;
verify-project)
_arguments -s -S $common $manifest
;;
version)
_arguments -s -S $common
;;
yank)
_arguments -s -S $common $registry \
'--vers=[specify yank version]:version' \
'--undo[undo a yank, putting a version back into the index]' \
'--index=[specify registry index to yank from]:registry index' \
'--token=[specify API token to use when authenticating]:token' \
'*: :_guard "^-*" "crate"'
;;
*)
# allow plugins to define their own functions
if ! _call_function ret _cargo-${words[1]}; then
# fallback on default completion for unknown commands
_default && ret=0
fi
(( ! ret ))
;;
esac
;;
esac
}
_cargo_unstable_flags() {
local flags
flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } )
_describe -t flags 'unstable flag' flags
}
_cargo_installed_crates() {
local expl
_description crates expl 'crate'
compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *}
}
_cargo_cmds() {
local -a commands
# This uses Parameter Expansion Flags, which are a built-in Zsh feature.
# See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
# and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion
#
# # How this work?
#
# First it splits the result of `cargo --list` at newline, then it removes the first line.
# Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]).
# Then it replaces those spaces between item and description with a `:`
#
# [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns
commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} )
_describe -t commands 'command' commands
}
#FIXME: Disabled until fixed
#gets package names from the manifest file
_cargo_package_names() {
_message -e packages package
}
# Extracts the values of "name" from the array given in $1 and shows them as
# command line options for completion
_cargo_names_from_array() {
# strip json from the path
local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"}
if [[ -z $manifest ]]; then
return 0
fi
local last_line
local -a names;
local in_block=false
local block_name=$1
names=()
while read -r line; do
if [[ $last_line == "[[$block_name]]" ]]; then
in_block=true
else
if [[ $last_line =~ '\s*\[\[.*' ]]; then
in_block=false
fi
fi
if [[ $in_block == true ]]; then
if [[ $line =~ '\s*name\s*=' ]]; then
regexp-replace line '^\s*name\s*=\s*|"' ''
names+=( "$line" )
fi
fi
last_line=$line
done < "$manifest"
_describe "$block_name" names
}
#Gets the test names from the manifest file
_cargo_test_names() {
_cargo_names_from_array "test"
}
#Gets the bench names from the manifest file
_cargo_benchmark_names() {
_cargo_names_from_array "bench"
}
_cargo

View file

@ -0,0 +1,7 @@
print ${(%):-'%F{yellow}The `cargo` plugin is deprecated and has been moved to the `rust` plugin.'}
print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'}
(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {
fpath=("$ZSH/plugins/rust" $fpath)
source "$ZSH/plugins/rust/rust.plugin.zsh"
}

View file

@ -2,7 +2,7 @@
# catimg script by Eduardo San Martin Morote aka Posva # # catimg script by Eduardo San Martin Morote aka Posva #
# https://posva.net # # https://posva.net #
# # # #
# Ouput the content of an image to the stdout using the 256 colors of the # # Output the content of an image to the stdout using the 256 colors of the #
# terminal. # # terminal. #
# GitHub: https://github.com/posva/catimg # # GitHub: https://github.com/posva/catimg #
################################################################################ ################################################################################

View file

@ -2,7 +2,7 @@
# catimg script by Eduardo San Martin Morote aka Posva # # catimg script by Eduardo San Martin Morote aka Posva #
# https://posva.net # # https://posva.net #
# # # #
# Ouput the content of an image to the stdout using the 256 colors of the # # Output the content of an image to the stdout using the 256 colors of the #
# terminal. # # terminal. #
# GitHub: https://github.com/posva/catimg # # GitHub: https://github.com/posva/catimg #
################################################################################ ################################################################################

9
plugins/charm/README.md Normal file
View file

@ -0,0 +1,9 @@
# Charm plugin
This plugin adds completion for the [charm](https://github.com/charmbracelet/charm) CLI.
To use it, add `charm` to the plugins array in your zshrc file:
```zsh
plugins=(... charm)
```

View file

@ -0,0 +1,14 @@
# Autocompletion for the Charm CLI (charm).
if (( ! $+commands[charm] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `charm`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_charm" ]]; then
typeset -g -A _comps
autoload -Uz _charm
_comps[charm]=_charm
fi
charm completion zsh >| "$ZSH_CACHE_DIR/completions/_charm" &|

View file

@ -5,6 +5,7 @@ current Ruby version, and completion and a prompt function to display the Ruby v
Supports brew and manual installation of chruby. Supports brew and manual installation of chruby.
To use it, add `chruby` to the plugins array in your zshrc file: To use it, add `chruby` to the plugins array in your zshrc file:
```zsh ```zsh
plugins=(... chruby) plugins=(... chruby)
``` ```
@ -14,7 +15,7 @@ plugins=(... chruby)
If you'd prefer to specify an explicit path to load chruby from If you'd prefer to specify an explicit path to load chruby from
you can set variables like so: you can set variables like so:
``` ```zsh
zstyle :omz:plugins:chruby path /local/path/to/chruby.sh zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
zstyle :omz:plugins:chruby auto /local/path/to/auto.sh zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
``` ```

View file

@ -1,121 +1,94 @@
# ## load chruby from different locations
# INSTRUCTIONS
# _source-from-omz-settings() {
# With either a manual or brew installed chruby things should just work. local _chruby_path _chruby_auto
#
# If you'd prefer to specify an explicit path to load chruby from zstyle -s :omz:plugins:chruby path _chruby_path || return 1
# you can set variables like so: zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1
#
# zstyle :omz:plugins:chruby path /local/path/to/chruby.sh if [[ -r ${_chruby_path} ]]; then
# zstyle :omz:plugins:chruby auto /local/path/to/auto.sh source ${_chruby_path}
# fi
# TODO
# - autodetermine correct source path on non OS X systems if [[ -r ${_chruby_auto} ]]; then
# - completion if ruby-install exists source ${_chruby_auto}
fi
}
_source-from-homebrew() {
(( $+commands[brew] )) || return 1
local _brew_prefix
# check default brew prefix
if [[ -h /usr/local/opt/chruby ]];then
_brew_prefix="/usr/local/opt/chruby"
else
# ok , it is not default prefix
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
_brew_prefix=$(brew --prefix chruby)
fi
[[ -r "$_brew_prefix" ]] || return 1
source $_brew_prefix/share/chruby/chruby.sh
source $_brew_prefix/share/chruby/auto.sh
}
_load-chruby-dirs() {
local dir
for dir in "$HOME/.rubies" "$PREFIX/opt/rubies"; do
if [[ -d "$dir" ]]; then
RUBIES+=("$dir")
fi
done
}
# Load chruby
if _source-from-omz-settings; then
_load-chruby-dirs
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
_load-chruby-dirs
elif _source-from-homebrew; then
_load-chruby-dirs
fi
unfunction _source-from-homebrew _source-from-omz-settings _load-chruby-dirs
## chruby utility functions and aliases
# rvm and rbenv plugins also provide this alias # rvm and rbenv plugins also provide this alias
alias rubies='chruby' alias rubies='chruby'
_homebrew-installed() {
whence brew &> /dev/null
_xit=$?
if [ $_xit -eq 0 ];then
# ok , we have brew installed
# speculatively we check default brew prefix
if [ -h /usr/local/opt/chruby ];then
_brew_prefix="/usr/local/opt/chruby"
else
# ok , it is not default prefix
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
_brew_prefix=$(brew --prefix chruby)
fi
return 0
else
return $_xit
fi
}
_chruby-from-homebrew-installed() {
[ -r _brew_prefix ] &> /dev/null
}
_ruby-build_installed() {
whence ruby-build &> /dev/null
}
_ruby-install-installed() {
whence ruby-install &> /dev/null
}
# Simple definition completer for ruby-build
if _ruby-build_installed; then
_ruby-build() { compadd $(ruby-build --definitions) }
compdef _ruby-build ruby-build
fi
_source_from_omz_settings() {
local _chruby_path
local _chruby_auto
zstyle -s :omz:plugins:chruby path _chruby_path
zstyle -s :omz:plugins:chruby auto _chruby_auto
if [[ -r ${_chruby_path} ]]; then
source ${_chruby_path}
fi
if [[ -r ${_chruby_auto} ]]; then
source ${_chruby_auto}
fi
}
_chruby_dirs() {
chrubydirs=($HOME/.rubies/ $PREFIX/opt/rubies)
for dir in chrubydirs; do
if [[ -d $dir ]]; then
RUBIES+=$dir
fi
done
}
if _homebrew-installed && _chruby-from-homebrew-installed ; then
source $_brew_prefix/share/chruby/chruby.sh
source $_brew_prefix/share/chruby/auto.sh
_chruby_dirs
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
_chruby_dirs
else
_source_from_omz_settings
_chruby_dirs
fi
function ensure_chruby() {
$(whence chruby)
}
function current_ruby() { function current_ruby() {
local _ruby local ruby
_ruby="$(chruby |grep \* |tr -d '* ')" ruby="$(chruby | grep \* | tr -d '* ')"
if [[ $(chruby |grep -c \*) -eq 1 ]]; then if [[ $(chruby | grep -c \*) -eq 1 ]]; then
echo ${_ruby} echo ${ruby}
else else
echo "system" echo "system"
fi fi
} }
function chruby_prompt_info() { function chruby_prompt_info() {
echo "$(current_ruby)" echo "${$(current_ruby):gs/%/%%}"
} }
# complete on installed rubies # Complete chruby command with installed rubies
_chruby() { _chruby() {
compadd $(chruby | tr -d '* ') compadd $(chruby | tr -d '* ')
local default_path='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' if PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command ruby &>/dev/null; then
if PATH=${default_path} type ruby &> /dev/null; then compadd system
compadd system fi
fi
} }
compdef _chruby chruby compdef _chruby chruby
# Simple definition completer for ruby-build
if command ruby-build &> /dev/null; then
_ruby-build() { compadd $(ruby-build --definitions) }
compdef _ruby-build ruby-build
fi

View file

@ -1,8 +1,6 @@
# chucknorris # chucknorris
Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD. Chuck Norris fortunes plugin for Oh My Zsh. Perfectly suitable as MOTD.
**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff)
To use it add `chucknorris` to the plugins array in you zshrc file. To use it add `chucknorris` to the plugins array in you zshrc file.

View file

@ -1,28 +1,24 @@
# chucknorris: Chuck Norris fortunes
# Automatically generate or update Chuck's compiled fortune data file
# $0 must be used outside a local function. This variable name is unlikly to collide.
CHUCKNORRIS_PLUGIN_DIR=${0:h}
() { () {
local DIR=$CHUCKNORRIS_PLUGIN_DIR/fortunes # %x: name of file containing code being executed
if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then local fortunes_dir="${${(%):-%x}:h}/fortunes"
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
local strfile=strfile # Aliases
if ! which strfile &>/dev/null && [[ -f /usr/sbin/strfile ]]; then alias chuck="fortune -a $fortunes_dir"
strfile=/usr/sbin/strfile alias chuck_cow="chuck | cowthink"
# Automatically generate or update Chuck's compiled fortune data file
if [[ "$fortunes_dir/chucknorris" -ot "$fortunes_dir/chucknorris.dat" ]]; then
return
fi fi
if which $strfile &> /dev/null; then
$strfile $DIR/chucknorris $DIR/chucknorris.dat >/dev/null # For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
else local strfile="${commands[strfile]:-/usr/sbin/strfile}"
if [[ ! -x "$strfile" ]]; then
echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2 echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2 echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
return
fi fi
fi
# Aliases # Generate the compiled fortune data file
alias chuck="fortune -a $DIR" $strfile "$fortunes_dir/chucknorris" "$fortunes_dir/chucknorris.dat" >/dev/null
alias chuck_cow="chuck | cowthink"
} }
unset CHUCKNORRIS_PLUGIN_DIR

View file

@ -228,7 +228,7 @@ Chuck Norris once punched the ground to stop an earthquake. The resulting afters
% %
Chuck Norris once round-house kicked a salesman. Over the phone. Chuck Norris once round-house kicked a salesman. Over the phone.
% %
Chuck Norris once rounhouse kicked a football. The astronomical society now considers it a planet. Chuck Norris once roundhouse kicked a football. The astronomical society now considers it a planet.
% %
Chuck Norris once thought he was wrong. He was, however, mistaken. Chuck Norris once thought he was wrong. He was, however, mistaken.
% %
@ -342,7 +342,7 @@ Every time there's an earthquake, you know Chuck Norris is hungry. The earthquak
% %
Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris. Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris.
% %
Fear of spiders is arachnaphobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic. Fear of spiders is arachnophobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic.
% %
Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
% %
@ -426,7 +426,7 @@ Some people ask for a Kleenex when they sneeze, Chuck Norris asks for a body bag
% %
Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
% %
Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face. Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindness, and possibly foot sized bruises on the face.
% %
Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS. Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS.
% %
@ -452,7 +452,7 @@ The best part of waking up is not Folgers in your cup. it's knowing that Chuck N
% %
The chief export of Chuck Norris is pain. The chief export of Chuck Norris is pain.
% %
The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship. The dictionary references Chuck Norris several times, he is mentioned under Fear, Law, Order and Chucktatorship.
% %
The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
% %
@ -468,7 +468,7 @@ The only way sharks will come near CN underwater is when CN is inside of a cage.
% %
The only word that rhymes with orange is Chuck Norris. The only word that rhymes with orange is Chuck Norris.
% %
The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequal "The Last Skull Bender". The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequel "The Last Skull Bender".
% %
The quickest way to a man's heart is with Chuck Norris' fist. The quickest way to a man's heart is with Chuck Norris' fist.
% %
@ -558,3 +558,11 @@ You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "God
% %
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one. http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
% %
Chuck Norris made the first Giraffe by uppercutting a horse.
%
Chuck Norris can hear sign language.
%
Chuck Norris make onions cry.
%
Chuck Norris doesn't shake hands, he makes them tremble.
%

View file

@ -1,26 +0,0 @@
# CloudApp plugin
## The CloudApp API is deprecated, so the plugin will be removed shortly
[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line.
To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file:
```zsh
plugins=(... cloudapp)
```
## Requirements
1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation)
2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below:
```
email
password
```
## Usage
- `cloudapp <filename>`: uploads `<filename>` to your CloudApp account, and if you're using
macOS, copies the URL to your clipboard.

View file

@ -1,4 +0,0 @@
print -Pn "%F{yellow}"
print "[oh-my-zsh] The CloudApp API no longer works, so the cloudapp plugin will"
print "[oh-my-zsh] be removed shortly. Please remove it from your plugins list."
print -Pn "%f"

View file

@ -39,14 +39,14 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
local curcontext="$curcontext" state line ret=1 version opts first second third local curcontext="$curcontext" state line ret=1 version
local -a opts
typeset -A opt_args typeset -A opt_args
version=(${(f)"$(_call_program version $words[1] --version)"}) version=(${(f)"$(_call_program version $words[1] --version)"}) || return ret
version=${${(z)${version[1]}}[3]} version=${${(z)${version[1]}}[3]}
first=$(echo $version|cut -d '.' -f 1)
second=$(echo $version|cut -d '.' -f 2) autoload -Uz is-at-least
third=$(echo $version|cut -d '.' -f 3) if ! is-at-least 1.6.3 "$version"; then
if (( $first < 2 )) && (( $second < 7 )) && (( $third < 3 ));then
opts+=('(-l --lint)'{-l,--lint}'[pipe the compiled JavaScript through JavaScript Lint]' opts+=('(-l --lint)'{-l,--lint}'[pipe the compiled JavaScript through JavaScript Lint]'
'(-r --require)'{-r,--require}'[require a library before executing your script]:library') '(-r --require)'{-r,--require}'[require a library before executing your script]:library')
fi fi

1
plugins/colemak/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.less

View file

@ -19,4 +19,20 @@ bindkey -a 'N' vi-join
bindkey -a 'j' vi-forward-word-end bindkey -a 'j' vi-forward-word-end
bindkey -a 'J' vi-forward-blank-word-end bindkey -a 'J' vi-forward-blank-word-end
lesskey $ZSH/plugins/colemak/colemak-less # Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# New less versions will read this file directly
export LESSKEYIN="${0:h:A}/colemak-less"
# Only run lesskey if less version is older than v582
less_ver=$(less --version | awk '{print $2;exit}')
autoload -Uz is-at-least
if ! is-at-least 582 $less_ver; then
# Old less versions will read this transformed file
export LESSKEY="${0:h:A}/.less"
lesskey -o "$LESSKEY" "$LESSKEYIN" 2>/dev/null
fi
unset less_ver

View file

@ -16,8 +16,13 @@ less_termcap[se]="${reset_color}"
less_termcap[us]="${fg_bold[green]}" less_termcap[us]="${fg_bold[green]}"
less_termcap[ue]="${reset_color}" less_termcap[ue]="${reset_color}"
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Absolute path to this file's directory. # Absolute path to this file's directory.
typeset __colored_man_pages_dir="${0:A:h}" typeset -g __colored_man_pages_dir="${0:A:h}"
function colored() { function colored() {
local -a environment local -a environment

View file

@ -82,7 +82,7 @@ colorize_less() {
# This variable tells less to pipe every file through the specified command # This variable tells less to pipe every file through the specified command
# (see the man page of less INPUT PREPROCESSOR). # (see the man page of less INPUT PREPROCESSOR).
# 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like # 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like
# the ~/.zsh_history. For such files the tty of the preprocessor will be supended. # the ~/.zsh_history. For such files the tty of the preprocessor will be suspended.
# Therefore we must source this file to make colorize_cat available in the # Therefore we must source this file to make colorize_cat available in the
# preprocessor without the interactive mode. # preprocessor without the interactive mode.
# `2>/dev/null` will suppress the error for large files 'broken pipe' of the python # `2>/dev/null` will suppress the error for large files 'broken pipe' of the python

View file

@ -29,5 +29,6 @@ It works out of the box with the command-not-found packages for:
- [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound) - [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound)
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found) - [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found)
- [Termux](https://github.com/termux/command-not-found) - [Termux](https://github.com/termux/command-not-found)
- [SUSE](https://www.unix.com/man-page/suse/1/command-not-found/)
You can add support for other platforms by submitting a Pull Request. You can add support for other platforms by submitting a Pull Request.

Some files were not shown because too many files have changed in this diff Show more