mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-06 03:10:35 +01:00
Added Composer bin to path
This commit is contained in:
parent
60e357f71d
commit
586f235bc6
3 changed files with 313 additions and 3 deletions
|
|
@ -1 +0,0 @@
|
||||||
../golang/golang.plugin.zsh
|
|
||||||
163
plugins/go/go.plugin.zsh
Normal file
163
plugins/go/go.plugin.zsh
Normal file
|
|
@ -0,0 +1,163 @@
|
||||||
|
# install in /etc/zsh/zshrc or your personal .zshrc
|
||||||
|
|
||||||
|
# gc
|
||||||
|
prefixes=(5 6 8)
|
||||||
|
for p in $prefixes; do
|
||||||
|
compctl -g "*.${p}" ${p}l
|
||||||
|
compctl -g "*.go" ${p}g
|
||||||
|
done
|
||||||
|
|
||||||
|
# standard go tools
|
||||||
|
compctl -g "*.go" gofmt
|
||||||
|
|
||||||
|
# gccgo
|
||||||
|
compctl -g "*.go" gccgo
|
||||||
|
|
||||||
|
# go tool
|
||||||
|
__go_tool_complete() {
|
||||||
|
typeset -a commands build_flags
|
||||||
|
commands+=(
|
||||||
|
'build[compile packages and dependencies]'
|
||||||
|
'clean[remove object files]'
|
||||||
|
'doc[run godoc on package sources]'
|
||||||
|
'env[print Go environment information]'
|
||||||
|
'fix[run go tool fix on packages]'
|
||||||
|
'fmt[run gofmt on package sources]'
|
||||||
|
'get[download and install packages and dependencies]'
|
||||||
|
'help[display help]'
|
||||||
|
'install[compile and install packages and dependencies]'
|
||||||
|
'list[list packages]'
|
||||||
|
'run[compile and run Go program]'
|
||||||
|
'test[test packages]'
|
||||||
|
'tool[run specified go tool]'
|
||||||
|
'version[print Go version]'
|
||||||
|
'vet[run go tool vet on packages]'
|
||||||
|
)
|
||||||
|
if (( CURRENT == 2 )); then
|
||||||
|
# explain go commands
|
||||||
|
_values 'go tool commands' ${commands[@]}
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
build_flags=(
|
||||||
|
'-a[force reinstallation of packages that are already up-to-date]'
|
||||||
|
'-n[print the commands but do not run them]'
|
||||||
|
'-p[number of parallel builds]:number'
|
||||||
|
'-race[enable data race detection]'
|
||||||
|
'-x[print the commands]'
|
||||||
|
'-work[print temporary directory name and keep it]'
|
||||||
|
'-ccflags[flags for 5c/6c/8c]:flags'
|
||||||
|
'-gcflags[flags for 5g/6g/8g]:flags'
|
||||||
|
'-ldflags[flags for 5l/6l/8l]:flags'
|
||||||
|
'-gccgoflags[flags for gccgo]:flags'
|
||||||
|
'-compiler[name of compiler to use]:name'
|
||||||
|
'-installsuffix[suffix to add to package directory]:suffix'
|
||||||
|
'-tags[list of build tags to consider satisfied]:tags'
|
||||||
|
)
|
||||||
|
__go_list() {
|
||||||
|
local expl importpaths
|
||||||
|
declare -a importpaths
|
||||||
|
importpaths=($(go list ${words[$CURRENT]}... 2>/dev/null))
|
||||||
|
_wanted importpaths expl 'import paths' compadd "$@" - "${importpaths[@]}"
|
||||||
|
}
|
||||||
|
case ${words[2]} in
|
||||||
|
clean|doc)
|
||||||
|
_arguments -s -w : '*:importpaths:__go_list'
|
||||||
|
;;
|
||||||
|
fix|fmt|list|vet)
|
||||||
|
_alternative ':importpaths:__go_list' ':files:_path_files -g "*.go"'
|
||||||
|
;;
|
||||||
|
install)
|
||||||
|
_arguments -s -w : ${build_flags[@]} \
|
||||||
|
"-v[show package names]" \
|
||||||
|
'*:importpaths:__go_list'
|
||||||
|
;;
|
||||||
|
get)
|
||||||
|
_arguments -s -w : \
|
||||||
|
${build_flags[@]}
|
||||||
|
;;
|
||||||
|
build)
|
||||||
|
_arguments -s -w : \
|
||||||
|
${build_flags[@]} \
|
||||||
|
"-v[show package names]" \
|
||||||
|
"-o[output file]:file:_files" \
|
||||||
|
"*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }"
|
||||||
|
;;
|
||||||
|
test)
|
||||||
|
_arguments -s -w : \
|
||||||
|
${build_flags[@]} \
|
||||||
|
"-c[do not run, compile the test binary]" \
|
||||||
|
"-i[do not run, install dependencies]" \
|
||||||
|
"-v[print test output]" \
|
||||||
|
"-x[print the commands]" \
|
||||||
|
"-short[use short mode]" \
|
||||||
|
"-parallel[number of parallel tests]:number" \
|
||||||
|
"-cpu[values of GOMAXPROCS to use]:number list" \
|
||||||
|
"-run[run tests and examples matching regexp]:regexp" \
|
||||||
|
"-bench[run benchmarks matching regexp]:regexp" \
|
||||||
|
"-benchmem[print memory allocation stats]" \
|
||||||
|
"-benchtime[run each benchmark until taking this long]:duration" \
|
||||||
|
"-blockprofile[write goroutine blocking profile to file]:file" \
|
||||||
|
"-blockprofilerate[set sampling rate of goroutine blocking profile]:number" \
|
||||||
|
"-timeout[kill test after that duration]:duration" \
|
||||||
|
"-cpuprofile[write CPU profile to file]:file:_files" \
|
||||||
|
"-memprofile[write heap profile to file]:file:_files" \
|
||||||
|
"-memprofilerate[set heap profiling rate]:number" \
|
||||||
|
"*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }"
|
||||||
|
;;
|
||||||
|
help)
|
||||||
|
_values "${commands[@]}" \
|
||||||
|
'gopath[GOPATH environment variable]' \
|
||||||
|
'packages[description of package lists]' \
|
||||||
|
'remote[remote import path syntax]' \
|
||||||
|
'testflag[description of testing flags]' \
|
||||||
|
'testfunc[description of testing functions]'
|
||||||
|
;;
|
||||||
|
run)
|
||||||
|
_arguments -s -w : \
|
||||||
|
${build_flags[@]} \
|
||||||
|
'*:file:_path_files -g "*.go"'
|
||||||
|
;;
|
||||||
|
tool)
|
||||||
|
if (( CURRENT == 3 )); then
|
||||||
|
_values "go tool" $(go tool)
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
case ${words[3]} in
|
||||||
|
[568]g)
|
||||||
|
_arguments -s -w : \
|
||||||
|
'-I[search for packages in DIR]:includes:_path_files -/' \
|
||||||
|
'-L[show full path in file:line prints]' \
|
||||||
|
'-S[print the assembly language]' \
|
||||||
|
'-V[print the compiler version]' \
|
||||||
|
'-e[no limit on number of errors printed]' \
|
||||||
|
'-h[panic on an error]' \
|
||||||
|
'-l[disable inlining]' \
|
||||||
|
'-m[print optimization decisions]' \
|
||||||
|
'-o[file specify output file]:file' \
|
||||||
|
'-p[assumed import path for this code]:importpath' \
|
||||||
|
'-u[disable package unsafe]' \
|
||||||
|
"*:file:_files -g '*.go'"
|
||||||
|
;;
|
||||||
|
[568]l)
|
||||||
|
local O=${words[3]%l}
|
||||||
|
_arguments -s -w : \
|
||||||
|
'-o[file specify output file]:file' \
|
||||||
|
'-L[search for packages in DIR]:includes:_path_files -/' \
|
||||||
|
"*:file:_files -g '*.[ao$O]'"
|
||||||
|
;;
|
||||||
|
dist)
|
||||||
|
_values "dist tool" banner bootstrap clean env install version
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# use files by default
|
||||||
|
_files
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef __go_tool_complete go
|
||||||
|
|
||||||
|
# aliases
|
||||||
|
alias gfa='go fmt . ./...'
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
per-directory-history.zsh
|
|
||||||
149
plugins/per-directory-history/per-directory-history.plugin.zsh
Normal file
149
plugins/per-directory-history/per-directory-history.plugin.zsh
Normal file
|
|
@ -0,0 +1,149 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
#
|
||||||
|
# This is a implementation of per directory history for zsh, some
|
||||||
|
# implementations of which exist in bash[1,2]. It also implements
|
||||||
|
# a per-directory-history-toggle-history function to change from using the
|
||||||
|
# directory history to using the global history. In both cases the history is
|
||||||
|
# always saved to both the global history and the directory history, so the
|
||||||
|
# toggle state will not effect the saved histories. Being able to switch
|
||||||
|
# between global and directory histories on the fly is a novel feature as far
|
||||||
|
# as I am aware.
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Configuration
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# HISTORY_BASE a global variable that defines the base directory in which the
|
||||||
|
# directory histories are stored
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# History
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# The idea/inspiration for a per directory history is from Stewart MacArthur[1]
|
||||||
|
# and Dieter[2], the implementation idea is from Bart Schaefer on the the zsh
|
||||||
|
# mailing list[3]. The implementation is by Jim Hester in September 2012.
|
||||||
|
#
|
||||||
|
# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
|
||||||
|
# [2]: http://dieter.plaetinck.be/per_directory_bash
|
||||||
|
# [3]: http://www.zsh.org/mla/users/1997/msg00226.html
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Copyright (c) 2012 Jim Hester
|
||||||
|
#
|
||||||
|
# This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
# In no event will the authors be held liable for any damages arising from the
|
||||||
|
# use of this software.
|
||||||
|
#
|
||||||
|
# Permission is granted to anyone to use this software for any purpose,
|
||||||
|
# including commercial applications, and to alter it and redistribute it
|
||||||
|
# freely, subject to the following restrictions:
|
||||||
|
#
|
||||||
|
# 1. The origin of this software must not be misrepresented; you must not claim
|
||||||
|
# that you wrote the original software. If you use this software in a product,
|
||||||
|
# an acknowledgment in the product documentation would be appreciated but is
|
||||||
|
# not required.
|
||||||
|
#
|
||||||
|
# 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
# misrepresented as being the original software.
|
||||||
|
#
|
||||||
|
# 3. This notice may not be removed or altered from any source distribution..
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# configuration, the base under which the directory histories are stored
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# toggle global/directory history used for searching - ctrl-G by default
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function per-directory-history-toggle-history() {
|
||||||
|
if [[ $_per_directory_history_is_global == true ]]; then
|
||||||
|
_per-directory-history-set-directory-history
|
||||||
|
print -n "\nusing local history"
|
||||||
|
else
|
||||||
|
_per-directory-history-set-global-history
|
||||||
|
print -n "\nusing global history"
|
||||||
|
fi
|
||||||
|
zle .push-line
|
||||||
|
zle .accept-line
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload per-directory-history-toggle-history
|
||||||
|
zle -N per-directory-history-toggle-history
|
||||||
|
bindkey '^G' per-directory-history-toggle-history
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# implementation details
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
||||||
|
|
||||||
|
function _per-directory-history-change-directory() {
|
||||||
|
_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history"
|
||||||
|
mkdir -p ${_per_directory_history_directory:h}
|
||||||
|
if [[ $_per_directory_history_is_global == false ]]; then
|
||||||
|
#save to the global history
|
||||||
|
fc -AI $HISTFILE
|
||||||
|
#save history to previous file
|
||||||
|
local prev="$HISTORY_BASE${OLDPWD:A}/history"
|
||||||
|
mkdir -p ${prev:h}
|
||||||
|
fc -AI $prev
|
||||||
|
|
||||||
|
#discard previous directory's history
|
||||||
|
local original_histsize=$HISTSIZE
|
||||||
|
HISTSIZE=0
|
||||||
|
HISTSIZE=$original_histsize
|
||||||
|
|
||||||
|
#read history in new file
|
||||||
|
if [[ -e $_per_directory_history_directory ]]; then
|
||||||
|
fc -R $_per_directory_history_directory
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function _per-directory-history-addhistory() {
|
||||||
|
print -Sr -- ${1%%$'\n'}
|
||||||
|
fc -p $_per_directory_history_directory
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _per-directory-history-set-directory-history() {
|
||||||
|
if [[ $_per_directory_history_is_global == true ]]; then
|
||||||
|
fc -AI $HISTFILE
|
||||||
|
local original_histsize=$HISTSIZE
|
||||||
|
HISTSIZE=0
|
||||||
|
HISTSIZE=$original_histsize
|
||||||
|
if [[ -e "$_per_directory_history_directory" ]]; then
|
||||||
|
fc -R "$_per_directory_history_directory"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
_per_directory_history_is_global=false
|
||||||
|
}
|
||||||
|
function _per-directory-history-set-global-history() {
|
||||||
|
if [[ $_per_directory_history_is_global == false ]]; then
|
||||||
|
fc -AI $_per_directory_history_directory
|
||||||
|
local original_histsize=$HISTSIZE
|
||||||
|
HISTSIZE=0
|
||||||
|
HISTSIZE=$original_histsize
|
||||||
|
if [[ -e "$HISTFILE" ]]; then
|
||||||
|
fc -R "$HISTFILE"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
_per_directory_history_is_global=true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#add functions to the exec list for chpwd and zshaddhistory
|
||||||
|
chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory")
|
||||||
|
zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory")
|
||||||
|
|
||||||
|
#start in directory mode
|
||||||
|
mkdir -p ${_per_directory_history_directory:h}
|
||||||
|
_per_directory_history_is_global=true
|
||||||
|
_per-directory-history-set-directory-history
|
||||||
|
|
@ -55,7 +55,7 @@ source $ZSH/oh-my-zsh.sh
|
||||||
|
|
||||||
# User configuration
|
# User configuration
|
||||||
|
|
||||||
export PATH=:/usr/local/bin:$HOME/bin:$PATH
|
export PATH=:/usr/local/bin:$HOME/.composer/vendor/bin:$HOME/bin:$PATH
|
||||||
# export MANPATH="/usr/local/man:$MANPATH"
|
# export MANPATH="/usr/local/man:$MANPATH"
|
||||||
|
|
||||||
# You may need to manually set your language environment
|
# You may need to manually set your language environment
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue