mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 03:01:32 +01:00
Merge remote-tracking branch 'upstream/master'
Conflicts: README.textile lib/aliases.zsh plugins/repo/repo.plugin.zsh templates/zshrc.zsh-template themes/ys.zsh-theme
This commit is contained in:
commit
24f2838f0b
54 changed files with 1539 additions and 178 deletions
|
|
@ -79,4 +79,14 @@ elif [[ $(uname) == "Linux" ]] ; then
|
|||
echo "∞"
|
||||
fi
|
||||
}
|
||||
else
|
||||
# Empty functions so we don't cause errors in prompts
|
||||
function battery_pct_remaining() {
|
||||
}
|
||||
|
||||
function battery_time_remaining() {
|
||||
}
|
||||
|
||||
function battery_pct_prompt() {
|
||||
}
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ _1st_arguments=(
|
|||
'list:list files in a formula or not-installed formulae'
|
||||
'log:git commit log for a formula'
|
||||
'missing:check all installed formuale for missing dependencies.'
|
||||
'options:display install options specific to formula.'
|
||||
'outdated:list formulas for which a newer version is available'
|
||||
'prune:remove dead links'
|
||||
'reinstall:reinstall a formula'
|
||||
|
|
|
|||
|
|
@ -4,13 +4,36 @@ alias bp="bundle package"
|
|||
alias bo="bundle open"
|
||||
alias bu="bundle update"
|
||||
|
||||
|
||||
# The following is based on https://github.com/gma/bundler-exec
|
||||
|
||||
bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard jekyll kitchen knife middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails puma)
|
||||
|
||||
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list
|
||||
for cmd in $UNBUNDLED_COMMANDS; do
|
||||
bundled_commands=(${bundled_commands#$cmd});
|
||||
done
|
||||
|
||||
## Functions
|
||||
|
||||
bi() {
|
||||
if _bundler-installed && _within-bundled-project; then
|
||||
local bundler_version=`bundle version | cut -d' ' -f3`
|
||||
if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
|
||||
if [[ "$(uname)" == 'Darwin' ]]
|
||||
then
|
||||
local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
|
||||
else
|
||||
local cores_num="$(nproc)"
|
||||
fi
|
||||
bundle install --jobs=$cores_num $@
|
||||
else
|
||||
bundle install $@
|
||||
fi
|
||||
else
|
||||
echo "Can't 'bundle install' outside a bundled project"
|
||||
fi
|
||||
}
|
||||
|
||||
_bundler-installed() {
|
||||
which bundle > /dev/null 2>&1
|
||||
}
|
||||
|
|
@ -32,28 +55,14 @@ _run-with-bundler() {
|
|||
fi
|
||||
}
|
||||
|
||||
if _bundler-installed; then
|
||||
bundler_version=`bundle version | cut -d' ' -f3`
|
||||
if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
|
||||
if [[ "$(uname)" == 'Darwin' ]]
|
||||
then
|
||||
local cores_num="$(sysctl hw.ncpu | awk '{print $2}')"
|
||||
else
|
||||
local cores_num="$(nproc)"
|
||||
fi
|
||||
eval "alias bi='bundle install --jobs=$cores_num'"
|
||||
else
|
||||
alias bi='bundle install'
|
||||
fi
|
||||
## Main program
|
||||
for cmd in $bundled_commands; do
|
||||
eval "function unbundled_$cmd () { $cmd \$@ }"
|
||||
eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
|
||||
alias $cmd=bundled_$cmd
|
||||
|
||||
## Main program
|
||||
for cmd in $bundled_commands; do
|
||||
eval "function unbundled_$cmd () { $cmd \$@ }"
|
||||
eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
|
||||
alias $cmd=bundled_$cmd
|
||||
if which _$cmd > /dev/null 2>&1; then
|
||||
compdef _$cmd bundled_$cmd=$cmd
|
||||
fi
|
||||
done
|
||||
|
||||
if which _$cmd > /dev/null 2>&1; then
|
||||
compdef _$cmd bundled_$cmd=$cmd
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# Authors:
|
||||
# https://github.com/AlexBio
|
||||
# https://github.com/dbb
|
||||
# https://github.com/Mappleconfusers
|
||||
#
|
||||
# Debian-related zsh aliases and functions for zsh
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ if [[ $use_sudo -eq 1 ]]; then
|
|||
alias ar='sudo $apt_pref remove'
|
||||
|
||||
# apt-get only
|
||||
alias ads='sudo $apt_pref dselect-upgrade'
|
||||
alias ads='sudo apt-get dselect-upgrade'
|
||||
|
||||
# Install all .deb files in the current directory.
|
||||
# Warning: you will need to put the glob in single quotes if you use:
|
||||
|
|
@ -109,6 +110,38 @@ else
|
|||
?not(~n`uname -r`))'\'' root'
|
||||
fi
|
||||
|
||||
# Completion ################################################################
|
||||
|
||||
#
|
||||
# Registers a compdef for $1 that calls $apt_pref with the commands $2
|
||||
# To do that it creates a new completion function called _apt_pref_$2
|
||||
#
|
||||
apt_pref_compdef() {
|
||||
local f fb
|
||||
f="_apt_pref_${2}"
|
||||
|
||||
eval "function ${f}() {
|
||||
shift words;
|
||||
service=\"\$apt_pref\";
|
||||
words=(\"\$apt_pref\" '$2' \$words);
|
||||
((CURRENT++))
|
||||
test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt
|
||||
}"
|
||||
|
||||
compdef "$f" "$1"
|
||||
}
|
||||
|
||||
apt_pref_compdef aac "autoclean"
|
||||
apt_pref_compdef abd "build-dep"
|
||||
apt_pref_compdef ac "clean"
|
||||
apt_pref_compdef ad "update"
|
||||
apt_pref_compdef afu "update"
|
||||
apt_pref_compdef ag "upgrade"
|
||||
apt_pref_compdef ai "install"
|
||||
apt_pref_compdef ail "install"
|
||||
apt_pref_compdef ap "purge"
|
||||
apt_pref_compdef ar "remove"
|
||||
apt_pref_compdef ads "dselect-upgrade"
|
||||
|
||||
# Misc. #####################################################################
|
||||
# print all installed packages
|
||||
|
|
|
|||
138
plugins/fastfile/fastfile.plugin.zsh
Normal file
138
plugins/fastfile/fastfile.plugin.zsh
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
################################################################################
|
||||
# FILE: fastfile.plugin.zsh
|
||||
# DESCRIPTION: oh-my-zsh plugin file.
|
||||
# AUTHOR: Michael Varner (musikmichael@web.de)
|
||||
# VERSION: 1.0.0
|
||||
#
|
||||
# This plugin adds the ability to on the fly generate and access file shortcuts.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
###########################
|
||||
# Settings
|
||||
|
||||
# These can be overwritten any time.
|
||||
# If they are not set yet, they will be
|
||||
# overwritten with their default values
|
||||
|
||||
default fastfile_dir "${HOME}/.fastfile/"
|
||||
default fastfile_var_prefix "§"
|
||||
|
||||
###########################
|
||||
# Impl
|
||||
|
||||
#
|
||||
# Generate a shortcut
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut (default: name of the file)
|
||||
# 2. file - The file or directory to make the shortcut for
|
||||
# STDOUT:
|
||||
# => fastfle_print
|
||||
#
|
||||
function fastfile() {
|
||||
test "$2" || 2="."
|
||||
file=$(readlink -f "$2")
|
||||
|
||||
test "$1" || 1="$(basename "$file")"
|
||||
name=$(echo "$1" | tr " " "_")
|
||||
|
||||
|
||||
mkdir -p "${fastfile_dir}"
|
||||
echo "$file" > "$(fastfile_resolv "$name")"
|
||||
|
||||
fastfile_sync
|
||||
fastfile_print "$name"
|
||||
}
|
||||
|
||||
#
|
||||
# Resolve the location of a shortcut file (the database file, where the value is written!)
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut
|
||||
# STDOUT:
|
||||
# The path
|
||||
#
|
||||
function fastfile_resolv() {
|
||||
echo "${fastfile_dir}${1}"
|
||||
}
|
||||
|
||||
#
|
||||
# Get the real path of a shortcut
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut
|
||||
# STDOUT:
|
||||
# The path
|
||||
#
|
||||
function fastfile_get() {
|
||||
cat "$(fastfile_resolv "$1")"
|
||||
}
|
||||
|
||||
#
|
||||
# Print a shortcut
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut
|
||||
# STDOUT:
|
||||
# Name and value of the shortcut
|
||||
#
|
||||
function fastfile_print() {
|
||||
echo "${fastfile_var_prefix}${1} -> $(fastfile_get "$1")"
|
||||
}
|
||||
|
||||
#
|
||||
# List all shortcuts
|
||||
#
|
||||
# STDOUT:
|
||||
# (=> fastfle_print) for each shortcut
|
||||
#
|
||||
function fastfile_ls() {
|
||||
for f in "${fastfile_dir}"/*; do
|
||||
file=`basename "$f"` # To enable simpler handeling of spaces in file names
|
||||
varkey=`echo "$file" | tr " " "_"`
|
||||
|
||||
# Special format for colums
|
||||
echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
|
||||
done | column -t -s "|"
|
||||
}
|
||||
|
||||
#
|
||||
# Remove a shortcut
|
||||
#
|
||||
# Arguments:
|
||||
# 1. name - The name of the shortcut (default: name of the file)
|
||||
# 2. file - The file or directory to make the shortcut for
|
||||
# STDOUT:
|
||||
# => fastfle_print
|
||||
#
|
||||
function fastfile_rm() {
|
||||
fastfile_print "$1"
|
||||
rm "$(fastfile_resolv "$1")"
|
||||
}
|
||||
|
||||
#
|
||||
# Generate the aliases for the shortcuts
|
||||
#
|
||||
function fastfile_sync() {
|
||||
for f in "${fastfile_dir}"/*; do
|
||||
file=`basename "$f"` # To enable simpler handeling of spaces in file names
|
||||
varkey=`echo "$file" | tr " " "_"`
|
||||
|
||||
alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
|
||||
done
|
||||
}
|
||||
|
||||
##################################
|
||||
# Shortcuts
|
||||
|
||||
alias ff=fastfile
|
||||
alias ffp=fastfile_print
|
||||
alias ffrm=fastfile_rm
|
||||
alias ffls=fastfile_ls
|
||||
alias ffsync=fastfile_sync
|
||||
|
||||
##################################
|
||||
# Init
|
||||
|
||||
fastfile_sync
|
||||
|
|
@ -4,10 +4,11 @@
|
|||
# gem zsh completion, based on homebrew completion
|
||||
|
||||
_gem_installed() {
|
||||
installed_gems=(`gem list --local --no-versions`)
|
||||
installed_gems=(${(f)"$(gem list --local --no-versions)"})
|
||||
}
|
||||
|
||||
local -a _1st_arguments
|
||||
|
||||
_1st_arguments=(
|
||||
'build:Build a gem from a gemspec'
|
||||
'cert:Manage RubyGems certificates and signing settings'
|
||||
|
|
|
|||
60
plugins/git-prompt/git-prompt.plugin.zsh
Normal file
60
plugins/git-prompt/git-prompt.plugin.zsh
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# ZSH Git Prompt Plugin from:
|
||||
# http://github.com/olivierverdier/zsh-git-prompt
|
||||
#
|
||||
export __GIT_PROMPT_DIR=$ZSH/plugins/git-prompt
|
||||
# Initialize colors.
|
||||
autoload -U colors
|
||||
colors
|
||||
|
||||
# Allow for functions in the prompt.
|
||||
setopt PROMPT_SUBST
|
||||
|
||||
## Enable auto-execution of functions.
|
||||
typeset -ga preexec_functions
|
||||
typeset -ga precmd_functions
|
||||
typeset -ga chpwd_functions
|
||||
|
||||
# Append git functions needed for prompt.
|
||||
preexec_functions+='preexec_update_git_vars'
|
||||
precmd_functions+='precmd_update_git_vars'
|
||||
chpwd_functions+='chpwd_update_git_vars'
|
||||
|
||||
## Function definitions
|
||||
function preexec_update_git_vars() {
|
||||
case "$2" in
|
||||
git*)
|
||||
__EXECUTED_GIT_COMMAND=1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function precmd_update_git_vars() {
|
||||
if [ -n "$__EXECUTED_GIT_COMMAND" ]; then
|
||||
update_current_git_vars
|
||||
unset __EXECUTED_GIT_COMMAND
|
||||
fi
|
||||
}
|
||||
|
||||
function chpwd_update_git_vars() {
|
||||
update_current_git_vars
|
||||
}
|
||||
|
||||
function update_current_git_vars() {
|
||||
unset __CURRENT_GIT_STATUS
|
||||
|
||||
local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
|
||||
_GIT_STATUS=`python ${gitstatus}`
|
||||
__CURRENT_GIT_STATUS=("${(f)_GIT_STATUS}")
|
||||
}
|
||||
|
||||
function prompt_git_info() {
|
||||
if [ -n "$__CURRENT_GIT_STATUS" ]; then
|
||||
echo "(%{${fg[red]}%}$__CURRENT_GIT_STATUS[1]%{${fg[default]}%}$__CURRENT_GIT_STATUS[2]%{${fg[magenta]}%}$__CURRENT_GIT_STATUS[3]%{${fg[default]}%})"
|
||||
fi
|
||||
}
|
||||
|
||||
# Set the prompt.
|
||||
#PROMPT='%B%m%~%b$(prompt_git_info) %# '
|
||||
# for a right prompt:
|
||||
#RPROMPT='%b$(prompt_git_info)'
|
||||
RPROMPT='$(prompt_git_info)'
|
||||
68
plugins/git-prompt/gitstatus.py
Normal file
68
plugins/git-prompt/gitstatus.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# change those symbols to whatever you prefer
|
||||
symbols = {'ahead of': '↑', 'behind': '↓', 'staged':'♦', 'changed':'‣', 'untracked':'…', 'clean':'⚡', 'unmerged':'≠', 'sha1':':'}
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
output,error = Popen(['git','status'], stdout=PIPE, stderr=PIPE).communicate()
|
||||
|
||||
if error:
|
||||
import sys
|
||||
sys.exit(0)
|
||||
lines = output.splitlines()
|
||||
|
||||
import re
|
||||
behead_re = re.compile(r"^# Your branch is (ahead of|behind) '(.*)' by (\d+) commit")
|
||||
diverge_re = re.compile(r"^# and have (\d+) and (\d+) different")
|
||||
|
||||
status = ''
|
||||
staged = re.compile(r'^# Changes to be committed:$', re.MULTILINE)
|
||||
changed = re.compile(r'^# Changed but not updated:$', re.MULTILINE)
|
||||
untracked = re.compile(r'^# Untracked files:$', re.MULTILINE)
|
||||
unmerged = re.compile(r'^# Unmerged paths:$', re.MULTILINE)
|
||||
|
||||
def execute(*command):
|
||||
out, err = Popen(stdout=PIPE, stderr=PIPE, *command).communicate()
|
||||
if not err:
|
||||
nb = len(out.splitlines())
|
||||
else:
|
||||
nb = '?'
|
||||
return nb
|
||||
|
||||
if staged.search(output):
|
||||
nb = execute(['git','diff','--staged','--name-only','--diff-filter=ACDMRT'])
|
||||
status += '%s%s' % (symbols['staged'], nb)
|
||||
if unmerged.search(output):
|
||||
nb = execute(['git','diff', '--staged','--name-only', '--diff-filter=U'])
|
||||
status += '%s%s' % (symbols['unmerged'], nb)
|
||||
if changed.search(output):
|
||||
nb = execute(['git','diff','--name-only', '--diff-filter=ACDMRT'])
|
||||
status += '%s%s' % (symbols['changed'], nb)
|
||||
if untracked.search(output):
|
||||
## nb = len(Popen(['git','ls-files','--others','--exclude-standard'],stdout=PIPE).communicate()[0].splitlines())
|
||||
## status += "%s" % (symbols['untracked']*(nb//3 + 1), )
|
||||
status += symbols['untracked']
|
||||
if status == '':
|
||||
status = symbols['clean']
|
||||
|
||||
remote = ''
|
||||
|
||||
bline = lines[0]
|
||||
if bline.find('Not currently on any branch') != -1:
|
||||
branch = symbols['sha1']+ Popen(['git','rev-parse','--short','HEAD'], stdout=PIPE).communicate()[0][:-1]
|
||||
else:
|
||||
branch = bline.split(' ')[3]
|
||||
bstatusline = lines[1]
|
||||
match = behead_re.match(bstatusline)
|
||||
if match:
|
||||
remote = symbols[match.groups()[0]]
|
||||
remote += match.groups()[2]
|
||||
elif lines[2:]:
|
||||
div_match = diverge_re.match(lines[2])
|
||||
if div_match:
|
||||
remote = "{behind}{1}{ahead of}{0}".format(*div_match.groups(), **symbols)
|
||||
|
||||
print '\n'.join([branch,remote,status])
|
||||
|
||||
|
|
@ -219,10 +219,19 @@ compdef _git glp=git-log
|
|||
#
|
||||
# This function return a warning if the current branch is a wip
|
||||
function work_in_progress() {
|
||||
if $(git log -n 1 | grep -q -c wip); then
|
||||
if $(git log -n 1 2>/dev/null | grep -q -c wip); then
|
||||
echo "WIP!!"
|
||||
fi
|
||||
}
|
||||
# these alias commit and uncomit wip branches
|
||||
alias gwip='git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m "wip"'
|
||||
alias gunwip='git log -n 1 | grep -q -c wip && git reset HEAD~1'
|
||||
|
||||
# these alias ignore changes to file
|
||||
alias gignore='git update-index --assume-unchanged'
|
||||
alias gunignore='git update-index --no-assume-unchanged'
|
||||
# list temporarily ignored files
|
||||
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#compdef powify
|
||||
|
||||
_powify_all_servers() {
|
||||
all_servers=(`ls $HOME/.pow/`)
|
||||
all_servers=(`ls $HOME/.pow/ 2>/dev/null`)
|
||||
}
|
||||
|
||||
local -a all_servers
|
||||
|
|
@ -30,7 +30,7 @@ fi
|
|||
|
||||
case "$words[1]" in
|
||||
server)
|
||||
_values \
|
||||
_values , \
|
||||
'install[install pow server]' \
|
||||
'reinstall[reinstall pow server]' \
|
||||
'update[update pow server]' \
|
||||
|
|
@ -45,7 +45,7 @@ case "$words[1]" in
|
|||
'config[print the current server configuration]' \
|
||||
'logs[tails the pow server logs]' ;;
|
||||
utils)
|
||||
_values \
|
||||
_values , \
|
||||
'install[install powify.dev server management tool]' \
|
||||
'reinstall[reinstall powify.dev server management tool]' \
|
||||
'uninstall[uninstall powify.dev server management tool]' ;;
|
||||
|
|
|
|||
|
|
@ -5,13 +5,24 @@
|
|||
# Don't remove this header, thank you
|
||||
# Usage: quote
|
||||
|
||||
WHO_COLOR="\e[0;33m"
|
||||
TEXT_COLOR="\e[0;35m"
|
||||
COLON_COLOR="\e[0;35m"
|
||||
END_COLOR="\e[m"
|
||||
|
||||
if [[ -x `which curl` ]]; then
|
||||
function quote()
|
||||
{
|
||||
Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php3" | grep -m 1 "dt ")
|
||||
Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php3" | iconv -c -f ISO-8859-1 -t UTF-8 | grep -m 1 "dt ")
|
||||
TXT=$(echo "$Q" | sed -e 's/<\/dt>.*//g' -e 's/.*html//g' -e 's/^[^a-zA-Z]*//' -e 's/<\/a..*$//g')
|
||||
W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g')
|
||||
echo "\e[0;33m${W}\e[0;30m: \e[0;35m“${TXT}”\e[m"
|
||||
if [ "$W" -a "$TXT" ]; then
|
||||
echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}“${TXT}”${END_COLOR}"
|
||||
else
|
||||
quote
|
||||
fi
|
||||
}
|
||||
#quote
|
||||
else
|
||||
echo "rand-quote plugin needs curl to work" >&2
|
||||
fi
|
||||
|
|
|
|||
133
plugins/singlechar/singlechar.plugin.zsh
Normal file
133
plugins/singlechar/singlechar.plugin.zsh
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
################################################################################
|
||||
# FILE: singlechar.plugin.zsh
|
||||
# DESCRIPTION: oh-my-zsh plugin file.
|
||||
# AUTHOR: Michael Varner (musikmichael@web.de)
|
||||
# VERSION: 1.0.0
|
||||
#
|
||||
# This plugin adds single char shortcuts (and combinations) for some commands.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
###########################
|
||||
# Settings
|
||||
|
||||
# These can be overwritten any time.
|
||||
# If they are not set yet, they will be
|
||||
# overwritten with their default values
|
||||
|
||||
default GREP grep
|
||||
default ROOT sudo
|
||||
default WGET wget
|
||||
default CURL curl
|
||||
|
||||
env_default PAGER less
|
||||
|
||||
###########################
|
||||
# Alias
|
||||
|
||||
# CAT, GREP, CURL, WGET
|
||||
|
||||
alias y='"$GREP" -Ri'
|
||||
alias n='"$GREP" -Rvi'
|
||||
|
||||
alias f.='find . | "$GREP"'
|
||||
alias f:='find'
|
||||
|
||||
alias f='"$GREP" -Rli'
|
||||
alias fn='"$GREP" -Rlvi'
|
||||
|
||||
alias w='echo >'
|
||||
alias a='echo >>'
|
||||
|
||||
alias c='cat'
|
||||
alias p='"$PAGER"'
|
||||
|
||||
alias m='man'
|
||||
|
||||
alias d='"$WGET"'
|
||||
alias u='"$CURL"'
|
||||
|
||||
# enhanced writing
|
||||
|
||||
alias w:='cat >'
|
||||
alias a:='cat >>'
|
||||
|
||||
# XARGS
|
||||
|
||||
alias x='xargs'
|
||||
|
||||
alias xy='xargs "$GREP" -Ri'
|
||||
alias xn='xargs "$GREP" -Riv'
|
||||
|
||||
alias xf.='xargs find | "$GREP"'
|
||||
alias xf:='xargs find'
|
||||
|
||||
alias xf='xargs "$GREP" -Rli'
|
||||
alias xfn='xargs "$GREP" -Rlvi'
|
||||
|
||||
alias xw='xargs echo >'
|
||||
alias xa='xargs echo >>'
|
||||
|
||||
alias xc='xargs cat'
|
||||
alias xp='xargs "$PAGER"'
|
||||
|
||||
alias xm='xargs man'
|
||||
|
||||
alias xd='xargs "$WGET"'
|
||||
alias xu='xargs "$CURL"'
|
||||
|
||||
alias xw:='xargs cat >'
|
||||
alias xa:='xargs >>'
|
||||
|
||||
# SUDO
|
||||
|
||||
alias s='"$ROOT"'
|
||||
|
||||
alias sy='"$ROOT" "$GREP" -Ri'
|
||||
alias sn='"$ROOT" "$GREP" -Riv'
|
||||
|
||||
alias sf.='"$ROOT" find . | "$GREP"'
|
||||
alias sf:='"$ROOT" find'
|
||||
|
||||
alias sf='"$ROOT" "$GREP" -Rli'
|
||||
alias sfn='"$ROOT" "$GREP" -Rlvi'
|
||||
|
||||
alias sw='"$ROOT" echo >'
|
||||
alias sa='"$ROOT" echo >>'
|
||||
|
||||
alias sc='"$ROOT" cat'
|
||||
alias sp='"$ROOT" "$PAGER"'
|
||||
|
||||
alias sm='"$ROOT" man'
|
||||
|
||||
alias sd='"$ROOT" "$WGET"'
|
||||
|
||||
alias sw:='"$ROOT" cat >'
|
||||
alias sa:='"$ROOT" cat >>'
|
||||
|
||||
# SUDO-XARGS
|
||||
|
||||
alias sx='"$ROOT" xargs'
|
||||
|
||||
alias sxy='"$ROOT" xargs "$GREP" -Ri'
|
||||
alias sxn='"$ROOT" xargs "$GREP" -Riv'
|
||||
|
||||
alias sxf.='"$ROOT" xargs find | "$GREP"'
|
||||
alias sxf:='"$ROOT" xargs find'
|
||||
|
||||
alias sxf='"$ROOT" xargs "$GREP" -li'
|
||||
alias sxfn='"$ROOT" xargs "$GREP" -lvi'
|
||||
|
||||
alias sxw='"$ROOT" xargs echo >'
|
||||
alias sxa='"$ROOT" xargs echo >>'
|
||||
|
||||
alias sxc='"$ROOT" xargs cat'
|
||||
alias sxp='"$ROOT" xargs "$PAGER"'
|
||||
|
||||
alias sxm='"$ROOT" xargs man'
|
||||
|
||||
alias sxd='"$ROOT" xargs "$WGET"'
|
||||
alias sxu='"$ROOT" xargs "$CURL"'
|
||||
|
||||
alias sxw:='"$ROOT" xargs cat >'
|
||||
alias sxa:='"$ROOT" xargs cat >>'
|
||||
22
plugins/sudo/sudo.zsh
Normal file
22
plugins/sudo/sudo.zsh
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# sudo will be inserted before the command
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Dongweiming <ciici123@gmail.com>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
sudo-command-line() {
|
||||
[[ -z $BUFFER ]] && zle up-history
|
||||
[[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"
|
||||
zle end-of-line
|
||||
}
|
||||
zle -N sudo-command-line
|
||||
# Defined shortcut keys: [Esc] [Esc]
|
||||
bindkey "\e\e" sudo-command-line
|
||||
|
|
@ -7,6 +7,7 @@ _arguments \
|
|||
{--configuration,-c}"[configuration file]:FILENAME:_files" \
|
||||
{--nodaemon,-n}"[run in the foreground (same as 'nodaemon true' in config file)]" \
|
||||
{--help,-h}"[print this usage message and exit]:" \
|
||||
{--version,-v}"[print supervisord version number and exit]:" \
|
||||
{--user,-u}"[run supervisord as this user]:USER:_users" \
|
||||
{--umask,-m}"[use this umask for daemon subprocess (default is 022)]" \
|
||||
{--directory,-d}"[directory to chdir to when daemonized]" \
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ alias zpatch='sudo zypper patch' #install patches
|
|||
#Request commands
|
||||
alias zif='sudo zypper if' #display info about packages
|
||||
alias zpa='sudo zypper pa' #list packages
|
||||
alias zpatch-info='sudo zyper patch-info' #display info about patches
|
||||
alias zpattern-info='sudo zyper patch-info' #display info about patterns
|
||||
alias zproduct-info='sudo zyper patch-info' #display info about products
|
||||
alias zpatch-info='sudo zypper patch-info' #display info about patches
|
||||
alias zpattern-info='sudo zypper patch-info' #display info about patterns
|
||||
alias zproduct-info='sudo zypper patch-info' #display info about products
|
||||
alias zpch='sudo zypper pch' #list all patches
|
||||
alias zpd='sudo zypper pd' #list products
|
||||
alias zpt='sudo zypper pt' #list patterns
|
||||
|
|
|
|||
159
plugins/systemadmin/systemadmin.zsh
Normal file
159
plugins/systemadmin/systemadmin.zsh
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# This is one for the system administrator, operation and maintenance.
|
||||
# Some of which come from http://justinlilly.com/dotfiles/zsh.html
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
#
|
||||
# * Dongweiming <ciici123@gmail.com>
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
function retval() {
|
||||
if [[ -z $1 ]];then
|
||||
echo '.'
|
||||
else
|
||||
echo $1
|
||||
fi
|
||||
}
|
||||
|
||||
function retlog() {
|
||||
if [[ -z $1 ]];then
|
||||
echo '/var/log/nginx/access.log'
|
||||
else
|
||||
echo $1
|
||||
fi
|
||||
}
|
||||
|
||||
alias ping='ping -c 5'
|
||||
alias clr='clear;echo "Currently logged in on $(tty), as $(whoami) in directory $(pwd)."'
|
||||
alias path='echo -e ${PATH//:/\\n}'
|
||||
alias mkdir='mkdir -pv'
|
||||
# get top process eating memory
|
||||
alias psmem='ps -e -orss=,args= | sort -b -k1,1n'
|
||||
alias psmem10='ps -e -orss=,args= | sort -b -k1,1n| head -10'
|
||||
# get top process eating cpu if not work try excute : export LC_ALL='C'
|
||||
alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr'
|
||||
alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr | head -10'
|
||||
# top10 of the history
|
||||
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
|
||||
|
||||
# directory LS
|
||||
dls () {
|
||||
ls -l | grep "^d" | awk '{ print $9 }' | tr -d "/"
|
||||
}
|
||||
psgrep() {
|
||||
ps aux | grep "$(retval $1)" | grep -v grep
|
||||
}
|
||||
# Kills any process that matches a regexp passed to it
|
||||
killit() {
|
||||
ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill
|
||||
}
|
||||
|
||||
# list contents of directories in a tree-like format
|
||||
if [ -z "\${which tree}" ]; then
|
||||
tree () {
|
||||
find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
|
||||
}
|
||||
fi
|
||||
|
||||
# Sort connection state
|
||||
sortcons() {
|
||||
netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
|
||||
}
|
||||
|
||||
# View all 80 Port Connections
|
||||
con80() {
|
||||
netstat -nat|grep -i ":80"|wc -l
|
||||
}
|
||||
|
||||
# On the connected IP sorted by the number of connections
|
||||
sortconip() {
|
||||
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
|
||||
}
|
||||
|
||||
# top20 of Find the number of requests on 80 port
|
||||
req20() {
|
||||
netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
|
||||
}
|
||||
|
||||
# top20 of Using tcpdump port 80 access to view
|
||||
http20() {
|
||||
sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -20
|
||||
}
|
||||
|
||||
# top20 of Find time_wait connection
|
||||
timewait20() {
|
||||
netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
|
||||
}
|
||||
|
||||
# top20 of Find SYN connection
|
||||
syn20() {
|
||||
netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr|head -n20
|
||||
}
|
||||
|
||||
# Printing process according to the port number
|
||||
port_pro() {
|
||||
netstat -ntlp | grep "$(retval $1)" | awk '{print $7}' | cut -d/ -f1
|
||||
}
|
||||
|
||||
# top10 of gain access to the ip address
|
||||
accessip10() {
|
||||
awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)"
|
||||
}
|
||||
|
||||
# top20 of Most Visited file or page
|
||||
visitpage20() {
|
||||
awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -20
|
||||
}
|
||||
|
||||
# top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
|
||||
consume100() {
|
||||
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -100
|
||||
# if django website or other webiste make by no suffix language
|
||||
# awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -100
|
||||
}
|
||||
|
||||
# Website traffic statistics (G)
|
||||
webtraffic() {
|
||||
awk "{sum+=$10} END {print sum/1024/1024/1024}" "$(retlog)"
|
||||
}
|
||||
|
||||
# Statistical connections 404
|
||||
c404() {
|
||||
awk '($9 ~/404/)' "$(retlog)" | awk '{print $9,$7}' | sort
|
||||
}
|
||||
|
||||
# Statistical http status.
|
||||
httpstatus() {
|
||||
awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog)"
|
||||
}
|
||||
|
||||
# Delete 0 byte file
|
||||
d0() {
|
||||
find "$(retval $1)" -type f -size 0 -exec rm -rf {} \;
|
||||
}
|
||||
|
||||
# gather external ip address
|
||||
geteip() {
|
||||
curl http://ifconfig.me
|
||||
}
|
||||
|
||||
# determine local IP address
|
||||
getip() {
|
||||
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
|
||||
}
|
||||
|
||||
# Clear zombie processes
|
||||
clrz() {
|
||||
ps -eal | awk '{ if ($2 == "Z") {print $4}}' | kill -9
|
||||
}
|
||||
|
||||
# Second concurrent
|
||||
conssec() {
|
||||
awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog)"|sort -k 2 -nr|head -n10
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
function theme
|
||||
{
|
||||
if [ "$1" = "random" ]; then
|
||||
if [ -z "$1" ] || [ "$1" = "random" ]; then
|
||||
themes=($ZSH/themes/*zsh-theme)
|
||||
N=${#themes[@]}
|
||||
((N=(RANDOM%N)+1))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#compdef tmuxinator
|
||||
#compdef tmuxinator mux
|
||||
#autoload
|
||||
|
||||
local curcontext="$curcontext" state line ret=1
|
||||
|
|
@ -25,7 +25,7 @@ case $state in
|
|||
args)
|
||||
case $line[1] in
|
||||
start|open|copy|delete)
|
||||
_configs=(`tmuxinator list | sed -n 's/^[ \t]\+//p'`)
|
||||
_configs=(`find ~/.tmuxinator/ -name \*.yml | cut -d/ -f5 | sed s:.yml::g`)
|
||||
_values 'configs' $_configs
|
||||
ret=0
|
||||
;;
|
||||
|
|
@ -33,4 +33,4 @@ case $state in
|
|||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD
|
|||
elif [[ $(whence python) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
|
||||
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"'
|
||||
alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"'
|
||||
elif [[ $(whence xxd) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xshell" ) ]]; then
|
||||
function urlencode() {echo $@ | tr -d "\n" | xxd -plain | sed "s/\(..\)/%\1/g"}
|
||||
function urldecode() {printf $(echo -n $@ | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n"}
|
||||
elif [[ $(whence ruby) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xruby" ) ]]; then
|
||||
alias urlencode='ruby -r cgi -e "puts CGI.escape(ARGV[0])"'
|
||||
alias urldecode='ruby -r cgi -e "puts CGI.unescape(ARGV[0])"'
|
||||
|
|
@ -33,4 +36,4 @@ elif [[ $(whence perl) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHO
|
|||
fi
|
||||
fi
|
||||
|
||||
unset URLTOOLS_METHOD
|
||||
unset URLTOOLS_METHOD
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ if (( $+commands[$virtualenvwrapper] )); then
|
|||
# Check for virtualenv name override
|
||||
if [[ -f "$PROJECT_ROOT/.venv" ]]; then
|
||||
ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
|
||||
elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then
|
||||
ENV_NAME="$PROJECT_ROOT/.venv"
|
||||
elif [[ "$PROJECT_ROOT" != "." ]]; then
|
||||
ENV_NAME=`basename "$PROJECT_ROOT"`
|
||||
else
|
||||
|
|
@ -27,6 +29,8 @@ if (( $+commands[$virtualenvwrapper] )); then
|
|||
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
|
||||
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
|
||||
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
|
||||
elif [[ -e "$ENV_NAME/bin/activate" ]]; then
|
||||
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
|
||||
fi
|
||||
fi
|
||||
elif [ $CD_VIRTUAL_ENV ]; then
|
||||
|
|
|
|||
38
plugins/wd/README.md
Normal file
38
plugins/wd/README.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
## wd
|
||||
|
||||
**Maintainer:** [mfaerevaag](https://github.com/mfaerevaag)
|
||||
|
||||
`wd` (warp directory) lets you jump to custom directories in zsh, without using cd. Why? Because cd seems ineffecient when the folder is frequently visited or has a long path. [Source](https://github.com/mfaerevaag/wd)
|
||||
|
||||
### Usage
|
||||
|
||||
* Add warp point to current working directory:
|
||||
|
||||
wd add test
|
||||
|
||||
If a warp point with the same name exists, use `add!` to overwrite it.
|
||||
|
||||
* From an other directory, warp to test with:
|
||||
|
||||
wd test
|
||||
|
||||
* You can warp back to previous directory, and so on, with the puncticulation syntax:
|
||||
|
||||
wd ..
|
||||
wd ...
|
||||
|
||||
This is a wrapper for the zsh `dirs` function.
|
||||
|
||||
* Remove warp point test point:
|
||||
|
||||
wd rm test
|
||||
|
||||
* List warp points to current directory (stored in `~/.warprc`):
|
||||
|
||||
wd show
|
||||
|
||||
* List all warp points (stored in `~/.warprc`):
|
||||
|
||||
wd ls
|
||||
|
||||
* Print usage with no opts or the `help` argument.
|
||||
48
plugins/wd/_wd.sh
Normal file
48
plugins/wd/_wd.sh
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#compdef wd.sh
|
||||
|
||||
zstyle ":completion:*:descriptions" format "%B%d%b"
|
||||
|
||||
CONFIG=$HOME/.warprc
|
||||
|
||||
local -a main_commands
|
||||
main_commands=(
|
||||
add:'Adds the current working directory to your warp points'
|
||||
#add'\!':'Overwrites existing warp point' # TODO: Fix
|
||||
rm:'Removes the given warp point'
|
||||
ls:'Outputs all stored warp points'
|
||||
show:'Outputs warp points to current directory'
|
||||
)
|
||||
|
||||
local -a points
|
||||
while read line
|
||||
do
|
||||
points+=$(awk "{ gsub(/\/Users\/$USER|\/home\/$USER/,\"~\"); print }" <<< $line)
|
||||
done < $CONFIG
|
||||
|
||||
_wd()
|
||||
{
|
||||
# init variables
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
|
||||
# init state
|
||||
_arguments \
|
||||
'1: :->command' \
|
||||
'2: :->argument'
|
||||
|
||||
case $state in
|
||||
command)
|
||||
compadd "$@" add rm ls show
|
||||
_describe -t warp-points 'Warp points:' points && ret=0
|
||||
;;
|
||||
argument)
|
||||
case $words[2] in
|
||||
rm|add!)
|
||||
_describe -t warp-points 'warp points' points && ret=0
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
esac
|
||||
}
|
||||
|
||||
_wd "$@"
|
||||
|
|
@ -6,4 +6,4 @@
|
|||
#
|
||||
# @github.com/mfaerevaag/wd
|
||||
|
||||
alias wd='. ~/.oh-my-zsh/plugins/wd/wd.sh'
|
||||
alias wd='. $ZSH/plugins/wd/wd.sh'
|
||||
|
|
@ -19,6 +19,13 @@ RED="\033[91m"
|
|||
NOC="\033[m"
|
||||
|
||||
|
||||
# check if config file exists
|
||||
if [[ ! -a $CONFIG ]]
|
||||
then
|
||||
# if not: create config file
|
||||
touch $CONFIG
|
||||
fi
|
||||
|
||||
## load warp points
|
||||
typeset -A points
|
||||
while read line
|
||||
|
|
@ -120,11 +127,12 @@ wd_print_msg()
|
|||
|
||||
wd_print_usage()
|
||||
{
|
||||
print "Usage: wd [add|-a|--add] [rm|-r|--remove] [ls|-l|--list] <point>"
|
||||
print "Usage: wd [add|-a|--add] [rm|-r|--remove] [ls|-l|--list] <point>"
|
||||
print "\nCommands:"
|
||||
print "\t add \t Adds the current working directory to your warp points"
|
||||
print "\t add! \t Overwrites existing warp point"
|
||||
print "\t remove Removes the given warp point"
|
||||
print "\t show \t Outputs warp points to current directory"
|
||||
print "\t list \t Outputs all stored warp points"
|
||||
print "\t help \t Show this extremely helpful text"
|
||||
}
|
||||
|
|
@ -135,13 +143,20 @@ wd_print_usage()
|
|||
# get opts
|
||||
args=`getopt -o a:r:lhs -l add:,remove:,list,help,show -- $*`
|
||||
|
||||
# check if no arguments were given
|
||||
if [[ $? -ne 0 || $#* -eq 0 ]]
|
||||
then
|
||||
wd_print_usage
|
||||
else
|
||||
# can't exit, as this would exit the excecuting shell
|
||||
# e.i. your terminal
|
||||
|
||||
# check if config file is writeable
|
||||
elif [[ ! -w $CONFIG ]]
|
||||
then
|
||||
wd_print_msg $RED "\'$CONFIG\' is not writeable."
|
||||
# do nothing => exit
|
||||
# can't run `exit`, as this would exit the executing shell
|
||||
# i.e. your terminal
|
||||
|
||||
else
|
||||
#set -- $args # WTF
|
||||
|
||||
for i
|
||||
18
plugins/xcode/xcode.plugin.zsh
Normal file
18
plugins/xcode/xcode.plugin.zsh
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#xc function courtesy of http://gist.github.com/subdigital/5420709
|
||||
function xc {
|
||||
xcode_proj=`find . -name "*.xc*" -d 1 | sort -r | head -1`
|
||||
if [[ `echo -n $xcode_proj | wc -m` == 0 ]]
|
||||
then
|
||||
echo "No xcworkspace/xcodeproj file found in the current directory."
|
||||
else
|
||||
echo "Found $xcode_proj"
|
||||
open "$xcode_proj"
|
||||
fi
|
||||
}
|
||||
|
||||
function xcsel {
|
||||
sudo xcode-select --switch "$*"
|
||||
}
|
||||
|
||||
alias xcb='xcodebuild'
|
||||
alias xcp='xcode-select --print-path'
|
||||
Loading…
Add table
Add a link
Reference in a new issue