mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 08:41:43 +00:00
Moved hub into the git plugin.
This commit is contained in:
68
plugins/archive/functions/extract
Normal file
68
plugins/archive/functions/extract
Normal file
@ -0,0 +1,68 @@
|
||||
local remove_archive
|
||||
local success
|
||||
local file_name
|
||||
local extract_dir
|
||||
|
||||
if (( $# == 0 )); then
|
||||
print "Usage: extract [-option] [file ...]"
|
||||
print
|
||||
print "Options:"
|
||||
print " -r, --remove Remove archive."
|
||||
print
|
||||
print "Report bugs to <sorin.ionescu@gmail.com>."
|
||||
fi
|
||||
|
||||
remove_archive=1
|
||||
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
|
||||
remove_archive=0
|
||||
shift
|
||||
fi
|
||||
|
||||
while (( $# > 0 )); do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
print "extract: '$1' is not a valid file" 1>&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
success=0
|
||||
file_name="${1:t}"
|
||||
extract_dir="${file_name:r}"
|
||||
case "$1" in
|
||||
(*.tar.gz|*.tgz) tar xvzf "$1" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
|
||||
(*.tar.xz|*.txz) tar --xz --help &> /dev/null \
|
||||
&& tar --xz -xvf "$1" \
|
||||
|| xzcat "$1" | tar xvf - ;;
|
||||
(*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
|
||||
&& tar --lzma -xvf "$1" \
|
||||
|| lzcat "$1" | tar xvf - ;;
|
||||
(*.tar) tar xvf "$1" ;;
|
||||
(*.gz) gunzip "$1" ;;
|
||||
(*.bz2) bunzip2 "$1" ;;
|
||||
(*.xz) unxz "$1" ;;
|
||||
(*.lzma) unlzma "$1" ;;
|
||||
(*.Z) uncompress "$1" ;;
|
||||
(*.zip) unzip "$1" -d $extract_dir ;;
|
||||
(*.rar) unrar e -ad "$1" ;;
|
||||
(*.7z) 7za x "$1" ;;
|
||||
(*.deb)
|
||||
mkdir -p "$extract_dir/control"
|
||||
mkdir -p "$extract_dir/data"
|
||||
cd "$extract_dir"; ar vx "../${1}" > /dev/null
|
||||
cd control; tar xzvf ../control.tar.gz
|
||||
cd ../data; tar xzvf ../data.tar.gz
|
||||
cd ..; rm *.tar.gz debian-binary
|
||||
cd ..
|
||||
;;
|
||||
(*)
|
||||
print "extract: '$1' cannot be extracted" 1>&2
|
||||
success=1
|
||||
;;
|
||||
esac
|
||||
|
||||
(( success = $success > 0 ? $success : $? ))
|
||||
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
|
||||
shift
|
||||
done
|
||||
|
45
plugins/archive/functions/ls-archive
Normal file
45
plugins/archive/functions/ls-archive
Normal file
@ -0,0 +1,45 @@
|
||||
local verbose
|
||||
|
||||
if (( $# == 0 )); then
|
||||
print "Usage: extract [-option] [file ...]"
|
||||
print
|
||||
print "Options:"
|
||||
print " -v, --verbose Verbose archive listing."
|
||||
print
|
||||
print "Report bugs to <sorin.ionescu@gmail.com>."
|
||||
fi
|
||||
|
||||
if [[ "$1" == "-v" ]] || [[ "$1" == "--verbose" ]]; then
|
||||
verbose=0
|
||||
shift
|
||||
fi
|
||||
|
||||
while (( $# > 0 )); do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
print "extract: '$1' is not a valid file" 1>&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
(*.tar.gz|*.tgz) tar t${verbose:+v}vzf "$1" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar t${verbose:+v}jf "$1" ;;
|
||||
(*.tar.xz|*.txz) tar --xz --help &> /dev/null \
|
||||
&& tar --xz -t${verbose:+v}f "$1" \
|
||||
|| xzcat "$1" | tar t${verbose:+v}f - ;;
|
||||
(*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
|
||||
&& tar --lzma -t${verbose:+v}f "$1" \
|
||||
|| lzcat "$1" | tar x${verbose:+v}f - ;;
|
||||
(*.tar) tar t${verbose:+v}f "$1" ;;
|
||||
(*.zip) unzip -l${verbose:+v} "$1" ;;
|
||||
(*.rar) unrar ${${verbose:+v}:-l} "$1" ;;
|
||||
(*.7z) 7za l "$1" ;;
|
||||
(*)
|
||||
print "ls-archive: '$1' cannot be listed" 1>&2
|
||||
success=1
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
@ -1,125 +0,0 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# FILE: extract.plugin.zsh
|
||||
# DESCRIPTION: oh-my-zsh plugin file.
|
||||
# AUTHOR: Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
# VERSION: 1.0.2
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
function extract() {
|
||||
local remove_archive
|
||||
local success
|
||||
local file_name
|
||||
local extract_dir
|
||||
|
||||
if (( $# == 0 )); then
|
||||
echo "Usage: extract [-option] [file ...]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -r, --remove Remove archive."
|
||||
echo
|
||||
echo "Report bugs to <sorin.ionescu@gmail.com>."
|
||||
fi
|
||||
|
||||
remove_archive=1
|
||||
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
|
||||
remove_archive=0
|
||||
shift
|
||||
fi
|
||||
|
||||
while (( $# > 0 )); do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
echo "extract: '$1' is not a valid file" 1>&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
success=0
|
||||
file_name="$( basename "$1" )"
|
||||
extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )"
|
||||
case "$1" in
|
||||
(*.tar.gz|*.tgz) tar xvzf "$1" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
|
||||
(*.tar.xz|*.txz) tar --xz --help &> /dev/null \
|
||||
&& tar --xz -xvf "$1" \
|
||||
|| xzcat "$1" | tar xvf - ;;
|
||||
(*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
|
||||
&& tar --lzma -xvf "$1" \
|
||||
|| lzcat "$1" | tar xvf - ;;
|
||||
(*.tar) tar xvf "$1" ;;
|
||||
(*.gz) gunzip "$1" ;;
|
||||
(*.bz2) bunzip2 "$1" ;;
|
||||
(*.xz) unxz "$1" ;;
|
||||
(*.lzma) unlzma "$1" ;;
|
||||
(*.Z) uncompress "$1" ;;
|
||||
(*.zip) unzip "$1" -d $extract_dir ;;
|
||||
(*.rar) unrar e -ad "$1" ;;
|
||||
(*.7z) 7za x "$1" ;;
|
||||
(*.deb)
|
||||
mkdir -p "$extract_dir/control"
|
||||
mkdir -p "$extract_dir/data"
|
||||
cd "$extract_dir"; ar vx "../${1}" > /dev/null
|
||||
cd control; tar xzvf ../control.tar.gz
|
||||
cd ../data; tar xzvf ../data.tar.gz
|
||||
cd ..; rm *.tar.gz debian-binary
|
||||
cd ..
|
||||
;;
|
||||
(*)
|
||||
echo "extract: '$1' cannot be extracted" 1>&2
|
||||
success=1
|
||||
;;
|
||||
esac
|
||||
|
||||
(( success = $success > 0 ? $success : $? ))
|
||||
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
function ls-archive() {
|
||||
local verbose
|
||||
|
||||
if (( $# == 0 )); then
|
||||
echo "Usage: extract [-option] [file ...]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -v, --verbose Verbose archive listing."
|
||||
echo
|
||||
echo "Report bugs to <sorin.ionescu@gmail.com>."
|
||||
fi
|
||||
|
||||
if [[ "$1" == "-v" ]] || [[ "$1" == "--verbose" ]]; then
|
||||
verbose=0
|
||||
shift
|
||||
fi
|
||||
|
||||
while (( $# > 0 )); do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
echo "extract: '$1' is not a valid file" 1>&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
(*.tar.gz|*.tgz) tar t${verbose:+v}vzf "$1" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar t${verbose:+v}jf "$1" ;;
|
||||
(*.tar.xz|*.txz) tar --xz --help &> /dev/null \
|
||||
&& tar --xz -t${verbose:+v}f "$1" \
|
||||
|| xzcat "$1" | tar t${verbose:+v}f - ;;
|
||||
(*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
|
||||
&& tar --lzma -t${verbose:+v}f "$1" \
|
||||
|| lzcat "$1" | tar x${verbose:+v}f - ;;
|
||||
(*.tar) tar t${verbose:+v}f "$1" ;;
|
||||
(*.zip) unzip -l${verbose:+v} "$1" ;;
|
||||
(*.rar) unrar ${${verbose:+v}:-l} "$1" ;;
|
||||
(*.7z) 7za l "$1" ;;
|
||||
(*)
|
||||
echo "ls-archive: '$1' cannot be listed" 1>&2
|
||||
success=1
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ alias bl='b list'
|
||||
alias bo='b open'
|
||||
alias bp='b package'
|
||||
alias bu='b update'
|
||||
alias binit="bi && b package && echo '\nvendor/ruby' >>! .gitignore"
|
||||
alias binit="bi && b package && print '\nvendor/ruby' >>! .gitignore"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Uses the command-not-found package ZSH support as seen in
|
||||
# Uses the command-not-found package Zsh support as seen in
|
||||
# http://www.porcheron.info/command-not-found-for-zsh/ and
|
||||
# installed in Ubuntu.
|
||||
|
||||
|
9
plugins/dpkg/functions/apt-copy
Normal file
9
plugins/dpkg/functions/apt-copy
Normal file
@ -0,0 +1,9 @@
|
||||
# Create a simple script that can be used to 'duplicate' a system.
|
||||
print '#!/bin/sh'"\n" > apt-copy.sh
|
||||
|
||||
list=$(perl -m'AptPkg::Cache' -e '$c=AptPkg::Cache->new; for (keys %$c){ push @a, $_ if $c->{$_}->{'CurrentState'} eq 'Installed';} print "$_ " for sort @a;')
|
||||
|
||||
print 'aptitude install '"$list\n" >> apt-copy.sh
|
||||
|
||||
chmod +x apt-copy.sh
|
||||
|
10
plugins/dpkg/functions/dbb-build
Normal file
10
plugins/dpkg/functions/dbb-build
Normal file
@ -0,0 +1,10 @@
|
||||
# Kernel-package building shortcut.
|
||||
MAKEFLAGS='' # Temporarily unset MAKEFLAGS ( '-j3' will fail ).
|
||||
appendage='-custom' # This shows up in $ (uname -r ).
|
||||
revision=$(date +"%Y%m%d") # This shows up in the .deb file name.
|
||||
|
||||
make-kpkg clean
|
||||
|
||||
time fakeroot make-kpkg --append-to-version "$appendage" --revision \
|
||||
"$revision" kernel_image kernel_headers
|
||||
|
@ -1,5 +1,3 @@
|
||||
# Debian ZSH Aliases and Functions
|
||||
|
||||
# Aliases
|
||||
alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" --no-gui --disable-columns search" # Search package.
|
||||
alias ad="sudo apt-get update" # Update packages lists.
|
||||
@ -22,28 +20,3 @@ alias debc='time dpkg-buildpackage -rfakeroot -us -uc'
|
||||
# Remove ALL kernel images and headers EXCEPT the one in use.
|
||||
alias kclean='su -c '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))'\'' root'
|
||||
|
||||
# Functions
|
||||
|
||||
# Create a simple script that can be used to 'duplicate' a system.
|
||||
function apt-copy() {
|
||||
print '#!/bin/sh'"\n" > apt-copy.sh
|
||||
|
||||
list=$(perl -m'AptPkg::Cache' -e '$c=AptPkg::Cache->new; for (keys %$c){ push @a, $_ if $c->{$_}->{'CurrentState'} eq 'Installed';} print "$_ " for sort @a;')
|
||||
|
||||
print 'aptitude install '"$list\n" >> apt-copy.sh
|
||||
|
||||
chmod +x apt-copy.sh
|
||||
}
|
||||
|
||||
# Kernel-package building shortcut.
|
||||
function dbb-build() {
|
||||
MAKEFLAGS='' # Temporarily unset MAKEFLAGS ( '-j3' will fail ).
|
||||
appendage='-custom' # This shows up in $ (uname -r ).
|
||||
revision=$(date +"%Y%m%d") # This shows up in the .deb file name.
|
||||
|
||||
make-kpkg clean
|
||||
|
||||
time fakeroot make-kpkg --append-to-version "$appendage" --revision \
|
||||
"$revision" kernel_image kernel_headers
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,20 @@
|
||||
# Get the latest Git completion.
|
||||
completion_file="${0:h}/_git"
|
||||
completion_file="${0:h}/completions/_git"
|
||||
completion_file_url='http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD'
|
||||
if [[ ! -e "$completion_file" ]] && (( $+commands[git] )); then
|
||||
if (( $+commands[curl] )); then
|
||||
curl -L "$completion_file_url" -o "$completion_file" &> /dev/null &!
|
||||
# Remove empty completions directory.
|
||||
if [[ -d "${completion_file:h}"(/^F) ]]; then
|
||||
rmdir "${completion_file:h}" 2> /dev/null
|
||||
fi
|
||||
|
||||
if (( $+commmands[wget] )); then
|
||||
wget -C "$completion_file_url" -O "$completion_file" &> /dev/null &!
|
||||
if mkdir -p "${completion_file:h}" > /dev/null; then
|
||||
if (( $+commands[curl] )); then
|
||||
curl -L "$completion_file_url" -o "$completion_file" &> /dev/null &!
|
||||
fi
|
||||
|
||||
if (( $+commmands[wget] )); then
|
||||
wget -C "$completion_file_url" -O "$completion_file" &> /dev/null &!
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
unset completion_file
|
||||
|
9
plugins/git/functions/git-branch
Normal file
9
plugins/git/functions/git-branch
Normal file
@ -0,0 +1,9 @@
|
||||
# Gets the current branch.
|
||||
local ref="$(git symbolic-ref HEAD 2> /dev/null)"
|
||||
if [[ -n "$ref" ]]; then
|
||||
print "${ref#refs/heads/}"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
22
plugins/git/functions/git-hub
Normal file
22
plugins/git/functions/git-hub
Normal file
@ -0,0 +1,22 @@
|
||||
# Open the GitHub repository in the browser.
|
||||
local url=$(
|
||||
git config -l \
|
||||
| grep "remote.origin.url" \
|
||||
| sed -En "s/remote.origin.url=(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p"
|
||||
)
|
||||
|
||||
if [[ -n "$url" ]]; then
|
||||
url="${url}/tree/${$(git-branch):-master}"
|
||||
|
||||
if (( $+commands[$BROWSER] )); then
|
||||
"$BROWSER" "$url"
|
||||
return 0
|
||||
else
|
||||
print "fatal: Browser not set or set to a non-existent browser." >&2
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
print "fatal: Not a Git repository or origin remote not set." >&2
|
||||
return 1
|
||||
fi
|
||||
|
@ -1,22 +1,3 @@
|
||||
# The default styles.
|
||||
zstyle ':git-info:' action 'action:%s' # %s - Special action name (am, merge, rebase).
|
||||
zstyle ':git-info:' added 'added:%a' # %a - Indicator to notify of added files.
|
||||
zstyle ':git-info:' ahead 'ahead:%A' # %A - Indicator to notify of ahead branch.
|
||||
zstyle ':git-info:' behind 'behind:%B' # %B - Indicator to notify of behind branch.
|
||||
zstyle ':git-info:' branch '%b' # %b - Branch name.
|
||||
zstyle ':git-info:' clean 'clean' # %C - Indicator to notify of clean branch.
|
||||
zstyle ':git-info:' commit 'commit:%c' # %c - SHA-1 hash.
|
||||
zstyle ':git-info:' deleted 'deleted:%d' # %d - Indicator to notify of deleted files.
|
||||
zstyle ':git-info:' dirty 'dirty' # %D - Indicator to notify of dirty branch.
|
||||
zstyle ':git-info:' modified 'modified:%m' # %m - Indicator to notify of modified files.
|
||||
zstyle ':git-info:' remote '%R' # %R - Remote name.
|
||||
zstyle ':git-info:' renamed 'renamed:%r' # %r - Indicator to notify of renamed files.
|
||||
zstyle ':git-info:' stashed 'stashed:%S' # %S - Indicator to notify of stashed files.
|
||||
zstyle ':git-info:' unmerged 'unmerged:%U' # %U - Indicator to notify of unmerged files.
|
||||
zstyle ':git-info:' untracked 'untracked:%u' # %u - Indicator to notify of untracked files.
|
||||
zstyle ':git-info:' prompt ' git:(%b %D%C)' # Left prompt.
|
||||
zstyle ':git-info:' rprompt '' # Right prompt.
|
||||
|
||||
# Gets the Git special action (am, merge, rebase, etc.).
|
||||
# Borrowed from vcs_info and edited.
|
||||
function _git-action() {
|
||||
@ -36,7 +17,7 @@ function _git-action() {
|
||||
else
|
||||
action='am/rebase'
|
||||
fi
|
||||
echo "$action"
|
||||
print "$action"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
@ -45,7 +26,7 @@ function _git-action() {
|
||||
"${git_dir}/rebase-merge/interactive" \
|
||||
"${git_dir}/.dotest-merge/interactive"; do
|
||||
if [[ -f "$action_dir" ]]; then
|
||||
echo 'rebase-i'
|
||||
print 'rebase-i'
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
@ -54,23 +35,23 @@ function _git-action() {
|
||||
"${git_dir}/rebase-merge" \
|
||||
"${git_dir}/.dotest-merge"; do
|
||||
if [[ -d "$action_dir" ]]; then
|
||||
echo 'rebase-m'
|
||||
print 'rebase-m'
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -f "${git_dir}/MERGE_HEAD" ]]; then
|
||||
echo 'merge'
|
||||
print 'merge'
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/CHERRY_PICK_HEAD" ]]; then
|
||||
echo 'cherry-pick'
|
||||
print 'cherry-pick'
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/BISECT_LOG" ]]; then
|
||||
echo 'bisect'
|
||||
print 'bisect'
|
||||
return 0
|
||||
fi
|
||||
|
||||
@ -175,7 +156,7 @@ function git-info() {
|
||||
elif [[ "$1" == [Oo][Ff][Ff] ]]; then
|
||||
git config --bool prompt.showinfo false
|
||||
else
|
||||
echo "Usage: $0 [ on | off ]"
|
||||
print "Usage: $0 [ on | off ]"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
@ -355,3 +336,5 @@ function git-info() {
|
||||
return 0
|
||||
}
|
||||
|
||||
git-info "$@"
|
||||
|
9
plugins/git/functions/git-root
Normal file
9
plugins/git/functions/git-root
Normal file
@ -0,0 +1,9 @@
|
||||
# Gets the repository root.
|
||||
local root="$(git rev-parse --show-toplevel 2> /dev/null)"
|
||||
if [[ -n "$root" ]]; then
|
||||
print "$root"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
@ -1,5 +1,3 @@
|
||||
# Aliases
|
||||
|
||||
# Hub by defunkt
|
||||
# https://github.com/defunkt/hub
|
||||
if (( $+commands[hub] )); then
|
@ -6,8 +6,8 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# Source plugin files.
|
||||
source "${0:h}/utility.zsh"
|
||||
source "${0:h}/alias.zsh"
|
||||
source "${0:h}/info.zsh"
|
||||
source "${0:h}/hub.zsh"
|
||||
source "${0:h}/style.zsh"
|
||||
source "${0:h}/completion.zsh"
|
||||
|
||||
|
18
plugins/git/style.zsh
Normal file
18
plugins/git/style.zsh
Normal file
@ -0,0 +1,18 @@
|
||||
# The default styles.
|
||||
zstyle ':git-info:' action 'action:%s' # %s - Special action name (am, merge, rebase).
|
||||
zstyle ':git-info:' added 'added:%a' # %a - Indicator to notify of added files.
|
||||
zstyle ':git-info:' ahead 'ahead:%A' # %A - Indicator to notify of ahead branch.
|
||||
zstyle ':git-info:' behind 'behind:%B' # %B - Indicator to notify of behind branch.
|
||||
zstyle ':git-info:' branch '%b' # %b - Branch name.
|
||||
zstyle ':git-info:' clean 'clean' # %C - Indicator to notify of clean branch.
|
||||
zstyle ':git-info:' commit 'commit:%c' # %c - SHA-1 hash.
|
||||
zstyle ':git-info:' deleted 'deleted:%d' # %d - Indicator to notify of deleted files.
|
||||
zstyle ':git-info:' dirty 'dirty' # %D - Indicator to notify of dirty branch.
|
||||
zstyle ':git-info:' modified 'modified:%m' # %m - Indicator to notify of modified files.
|
||||
zstyle ':git-info:' remote '%R' # %R - Remote name.
|
||||
zstyle ':git-info:' renamed 'renamed:%r' # %r - Indicator to notify of renamed files.
|
||||
zstyle ':git-info:' stashed 'stashed:%S' # %S - Indicator to notify of stashed files.
|
||||
zstyle ':git-info:' unmerged 'unmerged:%U' # %U - Indicator to notify of unmerged files.
|
||||
zstyle ':git-info:' untracked 'untracked:%u' # %u - Indicator to notify of untracked files.
|
||||
zstyle ':git-info:' prompt ' git:(%b %D%C)' # Left prompt.
|
||||
zstyle ':git-info:' rprompt '' # Right prompt.
|
@ -1,46 +0,0 @@
|
||||
# Gets the current branch.
|
||||
function git-branch() {
|
||||
local ref="$(git symbolic-ref HEAD 2> /dev/null)"
|
||||
if [[ -n "$ref" ]]; then
|
||||
echo "${ref#refs/heads/}"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Gets the repository root.
|
||||
function git-root() {
|
||||
local root="$(git rev-parse --show-toplevel 2> /dev/null)"
|
||||
if [[ -n "$root" ]]; then
|
||||
echo "$root"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Open the GitHub repository in the browser.
|
||||
function git-hub() {
|
||||
local url=$(
|
||||
git config -l \
|
||||
| grep "remote.origin.url" \
|
||||
| sed -En "s/remote.origin.url=(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p"
|
||||
)
|
||||
|
||||
if [[ -n "$url" ]]; then
|
||||
url="${url}/tree/${$(git-branch):-master}"
|
||||
|
||||
if (( $+commands[$BROWSER] )); then
|
||||
"$BROWSER" "$url"
|
||||
return 0
|
||||
else
|
||||
echo "fatal: Browser not set or set to a non-existent browser." >&2
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo "fatal: Not a Git repository or origin remote not set." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
To activate this script, load it into an interactive ZSH session:
|
||||
To activate this script, load it into an interactive Zsh session:
|
||||
|
||||
% source history-substring-search.zsh
|
||||
|
||||
|
@ -147,9 +147,9 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then
|
||||
# Rebind all ZLE widgets to make them invoke _zsh_highlights.
|
||||
_zsh_highlight_bind_widgets()
|
||||
{
|
||||
# Load ZSH module zsh/zleparameter, needed to override user defined widgets.
|
||||
# Load Zsh module zsh/zleparameter, needed to override user defined widgets.
|
||||
zmodload zsh/zleparameter 2>/dev/null || {
|
||||
echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2
|
||||
print 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then
|
||||
zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
|
||||
|
||||
# Default: unhandled case.
|
||||
*) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;;
|
||||
*) print "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
@ -347,7 +347,7 @@ function _history-substring-search-down-buffer() {
|
||||
|
||||
function _history-substring-search-up-history() {
|
||||
#
|
||||
# Behave like up in ZSH, except clear the $BUFFER
|
||||
# Behave like up in Zsh, except clear the $BUFFER
|
||||
# when beginning of history is reached like in Fish.
|
||||
#
|
||||
if [[ -z $_history_substring_search_query ]]; then
|
||||
@ -369,7 +369,7 @@ function _history-substring-search-up-history() {
|
||||
|
||||
function _history-substring-search-down-history() {
|
||||
#
|
||||
# Behave like down-history in ZSH, except clear the
|
||||
# Behave like down-history in Zsh, except clear the
|
||||
# $BUFFER when end of history is reached like in Fish.
|
||||
#
|
||||
if [[ -z $_history_substring_search_query ]]; then
|
||||
|
@ -3,7 +3,6 @@ alias kate='kate >/dev/null 2>&1' # Silent start.
|
||||
|
||||
# Functions
|
||||
function kt() {
|
||||
cd "$1"
|
||||
kate "$1"
|
||||
cd "$1" && kate .
|
||||
}
|
||||
|
||||
|
4
plugins/node/functions/node-docs
Normal file
4
plugins/node/functions/node-docs
Normal file
@ -0,0 +1,4 @@
|
||||
# Open the node api for your current version to the optional section.
|
||||
# TODO: Make the sections easier to use.
|
||||
open "http://nodejs.org/docs/$(node --version)/api/all.html#${1}"
|
||||
|
@ -9,9 +9,3 @@ else
|
||||
fi
|
||||
unset cache_file
|
||||
|
||||
# Open the node api for your current version to the optional section.
|
||||
# TODO: Make the sections easier to use.
|
||||
function node-docs() {
|
||||
open "http://nodejs.org/docs/$(node --version)/api/all.html#$1"
|
||||
}
|
||||
|
||||
|
10
plugins/osx/README.md
Normal file
10
plugins/osx/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
Provides the following commands.
|
||||
|
||||
- `tab` create a new tab (works in both _Terminal_ and _iTerm_).
|
||||
- `pfd` print current _Finder_ directory.
|
||||
- `pfs` print current _Finder_ selection.
|
||||
- `cdf` cd to current _Finder_ directory.
|
||||
- `pushdf` pushd to current _Finder_ directory.
|
||||
- `ql` quick look at files.
|
||||
- `manp` Open MAN pages in _Preview.app_.
|
||||
- `trash` Move files and folders to _Trash_.
|
@ -1,5 +0,0 @@
|
||||
#compdef man-preview
|
||||
#autoload
|
||||
|
||||
_man
|
||||
|
6
plugins/osx/functions/pfd
Normal file
6
plugins/osx/functions/pfd
Normal file
@ -0,0 +1,6 @@
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "Finder"
|
||||
return POSIX path of (target of window 1 as alias)
|
||||
end tell
|
||||
EOF
|
||||
|
11
plugins/osx/functions/pfs
Normal file
11
plugins/osx/functions/pfs
Normal file
@ -0,0 +1,11 @@
|
||||
osascript 2>/dev/null <<EOF
|
||||
set output to ""
|
||||
tell application "Finder" to set the_selection to selection
|
||||
set item_count to count the_selection
|
||||
repeat with item_index from 1 to count the_selection
|
||||
if item_index is less than item_count then set the_delimiter to "\n"
|
||||
if item_index is item_count then set the_delimiter to ""
|
||||
set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter
|
||||
end repeat
|
||||
EOF
|
||||
|
34
plugins/osx/functions/tab
Normal file
34
plugins/osx/functions/tab
Normal file
@ -0,0 +1,34 @@
|
||||
local command="cd \\\"$PWD\\\""
|
||||
(( $# > 0 )) && command="${command}; $*"
|
||||
|
||||
the_app=$(
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
name of first item of (every process whose frontmost is true)
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
|
||||
[[ "$the_app" == 'Terminal' ]] && {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Terminal" to keystroke "t" using command down
|
||||
tell application "Terminal" to do script "${command}" in front window
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
||||
[[ "$the_app" == 'iTerm' ]] && {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "iTerm"
|
||||
set current_terminal to current terminal
|
||||
tell current_terminal
|
||||
launch session "Default Session"
|
||||
set current_session to current session
|
||||
tell current_session
|
||||
write text "${command}"
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
}
|
13
plugins/osx/functions/trash
Normal file
13
plugins/osx/functions/trash
Normal file
@ -0,0 +1,13 @@
|
||||
local trash_dir="${HOME}/.Trash"
|
||||
local trash_item
|
||||
local item
|
||||
for item in "${@}"; do
|
||||
if [[ -e "${item}" ]] || [[ -L "${item}" ]]; then
|
||||
trash_item="${trash_dir}/${item:t}"
|
||||
if [[ -e "${trash_item}" ]] || [[ -L "${trash_item}" ]]; then
|
||||
trash_item="${trash_item} $(date "+%H-%M-%S")"
|
||||
fi
|
||||
mv -f "${item}" "${trash_item}"
|
||||
fi
|
||||
done
|
||||
|
@ -1,103 +1,23 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
# FILE: osx.plugin.zsh
|
||||
# DESCRIPTION: oh-my-zsh plugin file.
|
||||
# AUTHOR: Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
# VERSION: 1.0.2
|
||||
# ------------------------------------------------------------------------------
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
|
||||
# Change directory to the current Finder directory.
|
||||
alias cdf='cd "$(pfd)"'
|
||||
|
||||
function tab() {
|
||||
local command="cd \\\"$PWD\\\""
|
||||
(( $# > 0 )) && command="${command}; $*"
|
||||
# Push directory to the current Finder directory.
|
||||
alias pushdf='pushd "$(pfd)"'
|
||||
|
||||
the_app=$(
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
name of first item of (every process whose frontmost is true)
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
|
||||
[[ "$the_app" == 'Terminal' ]] && {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Terminal" to keystroke "t" using command down
|
||||
tell application "Terminal" to do script "${command}" in front window
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
||||
[[ "$the_app" == 'iTerm' ]] && {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "iTerm"
|
||||
set current_terminal to current terminal
|
||||
tell current_terminal
|
||||
launch session "Default Session"
|
||||
set current_session to current session
|
||||
tell current_session
|
||||
write text "${command}"
|
||||
end tell
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
# Open files in Quick Look.
|
||||
function ql() {
|
||||
(( $# > 0 )) && qlmanage -p "$@" &> /dev/null
|
||||
}
|
||||
|
||||
function pfd() {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "Finder"
|
||||
return POSIX path of (target of window 1 as alias)
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
||||
function pfs() {
|
||||
osascript 2>/dev/null <<EOF
|
||||
set output to ""
|
||||
tell application "Finder" to set the_selection to selection
|
||||
set item_count to count the_selection
|
||||
repeat with item_index from 1 to count the_selection
|
||||
if item_index is less than item_count then set the_delimiter to "\n"
|
||||
if item_index is item_count then set the_delimiter to ""
|
||||
set output to output & ((item item_index of the_selection as alias)'s POSIX path) & the_delimiter
|
||||
end repeat
|
||||
EOF
|
||||
}
|
||||
|
||||
function cdf() {
|
||||
cd "$(pfd)"
|
||||
}
|
||||
|
||||
function pushdf() {
|
||||
pushd "$(pfd)"
|
||||
}
|
||||
|
||||
function quick-look() {
|
||||
(( $# > 0 )) && qlmanage -p $* &>/dev/null &
|
||||
}
|
||||
|
||||
function man-preview() {
|
||||
man -t "$@" | open -f -a Preview
|
||||
}
|
||||
|
||||
function trash() {
|
||||
local trash_dir="${HOME}/.Trash"
|
||||
local temp_ifs=$IFS
|
||||
IFS=$'\n'
|
||||
for item in "$@"; do
|
||||
if [[ -e "$item" ]]; then
|
||||
item_name="$(basename $item)"
|
||||
if [[ -e "${trash_dir}/${item_name}" ]]; then
|
||||
mv -f "$item" "${trash_dir}/${item_name} $(date "+%H-%M-%S")"
|
||||
else
|
||||
mv -f "$item" "${trash_dir}/"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS=$temp_ifs
|
||||
# Open man pages in Preview.
|
||||
function manp() {
|
||||
(( $# > 0 )) && man -t "$@" | open -f -a Preview
|
||||
}
|
||||
compdef _man manp
|
||||
|
||||
# Delete .DS_Store and __MACOSX directories.
|
||||
function rm-osx-cruft() {
|
||||
find ${@:-$PWD} \( -type f -name ".DS_Store" \) -o \( -type d -name '__MACOSX' \) -delete
|
||||
find "${@:-$PWD}" \( -type f -name '.DS_Store' \) -o \( -type d -name '__MACOSX' \) -print0 | xargs rm -rf
|
||||
}
|
||||
|
||||
|
16
plugins/pacman/functions/pacdisowned
Normal file
16
plugins/pacman/functions/pacdisowned
Normal file
@ -0,0 +1,16 @@
|
||||
# List disowned files.
|
||||
tmp="${TMPDIR-/tmp}/pacman-disowned-$UID-$$"
|
||||
db="$tmp/db"
|
||||
fs="$tmp/fs"
|
||||
|
||||
mkdir "$tmp"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
pacman -Qlq | sort -u > "$db"
|
||||
|
||||
find /bin /etc /lib /sbin /usr \
|
||||
! -name lost+found \
|
||||
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
|
||||
|
||||
comm -23 "$fs" "$db"
|
||||
|
4
plugins/pacman/functions/paclist
Normal file
4
plugins/pacman/functions/paclist
Normal file
@ -0,0 +1,4 @@
|
||||
# List explicitly installed packages.
|
||||
sudo pacman -Qei $(pacman -Qu|cut -d" " -f 1) \
|
||||
| awk ' BEGIN {FS=":"}/^Name/{printf("\033[1;36m%s\033[1;37m", $2)}/^Description/{print $2}'
|
||||
|
@ -1,26 +1,48 @@
|
||||
# Archlinux ZSH Aliases and Functions
|
||||
# Arch Linux Zsh Aliases and Functions
|
||||
#
|
||||
# Pacman Tips:
|
||||
# https://wiki.archlinux.org/index.php/Pacman_Tips
|
||||
|
||||
# Yaourt Aliases
|
||||
if (( $+commands[yaourt] )); then
|
||||
function arch-upgrade() {
|
||||
yaourt -Syu
|
||||
}
|
||||
# Upgrade Arch Linux.
|
||||
alias arch-upgrade='yaourt -Syu'
|
||||
|
||||
alias yaconf='yaourt -C' # Fix all configuration files with vimdiff.
|
||||
alias yaupg='yaourt -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
|
||||
alias yain='yaourt -S' # Install specific package(s) from the repositories.
|
||||
alias yains='yaourt -U' # Install specific package(s) not from the repositories but from a file .
|
||||
alias yare='yaourt -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies.
|
||||
alias yarem='yaourt -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies.
|
||||
alias yarep='yaourt -Si' # Display information about a given package in the repositories.
|
||||
alias yareps='yaourt -Ss' # Search for package(s) in the repositories.
|
||||
alias yaloc='yaourt -Qi' # Display information about a given package in the local database.
|
||||
alias yalocs='yaourt -Qs' # Search for package(s) in the local database.
|
||||
alias yamir='yaourt -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
|
||||
alias yainsd='yaourt -S --asdeps' # Install given package(s) as dependencies of another package
|
||||
# Fix all configuration files with vimdiff.
|
||||
alias yaconf='yaourt -C'
|
||||
|
||||
# Synchronize with repositories before upgrading packages that are out of date on the local system.
|
||||
alias yaupg='yaourt -Syu'
|
||||
|
||||
# Install specific package(s) from the repositories.
|
||||
alias yain='yaourt -S'
|
||||
|
||||
# Install specific package(s) not from the repositories but from a file .
|
||||
alias yains='yaourt -U'
|
||||
|
||||
# Remove the specified package(s), retaining its configuration(s) and required dependencies.
|
||||
alias yare='yaourt -R'
|
||||
|
||||
# Remove the specified package(s), its configuration(s) and unneeded dependencies.
|
||||
alias yarem='yaourt -Rns'
|
||||
|
||||
# Display information about a given package in the repositories.
|
||||
alias yarep='yaourt -Si'
|
||||
|
||||
# Search for package(s) in the repositories.
|
||||
alias yareps='yaourt -Ss'
|
||||
|
||||
# Display information about a given package in the local database.
|
||||
alias yaloc='yaourt -Qi'
|
||||
|
||||
# Search for package(s) in the local database.
|
||||
alias yalocs='yaourt -Qs'
|
||||
|
||||
# Force refresh of all package lists after updating /etc/pacman.d/mirrorlist
|
||||
alias yamir='yaourt -Syy'
|
||||
|
||||
# Install given package(s) as dependencies of another package
|
||||
alias yainsd='yaourt -S --asdeps'
|
||||
|
||||
# Update and refresh the local package and ABS databases against repositories.
|
||||
if (( $+commands[abs] )); then
|
||||
@ -29,25 +51,49 @@ if (( $+commands[yaourt] )); then
|
||||
alias yaupd='yaourt -Sy'
|
||||
fi
|
||||
else
|
||||
function arch-upgrade() {
|
||||
sudo pacman -Syu
|
||||
}
|
||||
# Upgrade Arch Linux.
|
||||
alias arch-upgrade='sudo pacman -Syu'
|
||||
fi
|
||||
|
||||
# Pacman Aliaases
|
||||
alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
|
||||
alias pacin='sudo pacman -S' # Install specific package(s) from the repositories.
|
||||
alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file.
|
||||
alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies.
|
||||
alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies.
|
||||
alias pacrep='pacman -Si' # Display information about a given package in the repositories.
|
||||
alias pacreps='pacman -Ss' # Search for package(s) in the repositories.
|
||||
alias pacloc='pacman -Qi' # Display information about a given package in the local database.
|
||||
alias paclocs='pacman -Qs' # Search for package(s) in the local database.
|
||||
alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package.
|
||||
alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist.
|
||||
alias paclsorphans='sudo pacman -Qdt' # List orphan packages(s).
|
||||
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)' # Remove orphan package(s).
|
||||
# Pacman Aliases
|
||||
# Synchronize with repositories before upgrading packages that are out of date on the local system.
|
||||
alias pacupg='sudo pacman -Syu'
|
||||
|
||||
# Install specific package(s) from the repositories.
|
||||
alias pacin='sudo pacman -S'
|
||||
|
||||
# Install specific package not from the repositories but from a file.
|
||||
alias pacins='sudo pacman -U'
|
||||
|
||||
# Remove the specified package(s), retaining its configuration(s) and required dependencies.
|
||||
alias pacre='sudo pacman -R'
|
||||
|
||||
# Remove the specified package(s), its configuration(s) and unneeded dependencies.
|
||||
alias pacrem='sudo pacman -Rns'
|
||||
|
||||
# Display information about a given package in the repositories.
|
||||
alias pacrep='pacman -Si'
|
||||
|
||||
# Search for package(s) in the repositories.
|
||||
alias pacreps='pacman -Ss'
|
||||
|
||||
# Display information about a given package in the local database.
|
||||
alias pacloc='pacman -Qi'
|
||||
|
||||
# Search for package(s) in the local database.
|
||||
alias paclocs='pacman -Qs'
|
||||
|
||||
# Install given package(s) as dependencies of another package.
|
||||
alias pacinsd='sudo pacman -S --asdeps'
|
||||
|
||||
# Force refresh of all package lists after updating /etc/pacman.d/mirrorlist.
|
||||
alias pacmir='sudo pacman -Syy'
|
||||
|
||||
# List orphan packages(s).
|
||||
alias paclsorphans='sudo pacman -Qdt'
|
||||
|
||||
# Remove orphan package(s).
|
||||
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
|
||||
|
||||
# Update and refresh the local package and ABS databases against repositories.
|
||||
if (( $+commands[abs] )); then
|
||||
@ -56,27 +102,3 @@ else
|
||||
alias pacupd='sudo pacman -Sy'
|
||||
fi
|
||||
|
||||
# List explicitly installed packages.
|
||||
function paclist() {
|
||||
sudo pacman -Qei $(pacman -Qu|cut -d" " -f 1) \
|
||||
| awk ' BEGIN {FS=":"}/^Name/{printf("\033[1;36m%s\033[1;37m", $2)}/^Description/{print $2}'
|
||||
}
|
||||
|
||||
# List disowned files.
|
||||
function pacdisowned() {
|
||||
tmp="${TMPDIR-/tmp}/pacman-disowned-$UID-$$"
|
||||
db="$tmp/db"
|
||||
fs="$tmp/fs"
|
||||
|
||||
mkdir "$tmp"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
pacman -Qlq | sort -u > "$db"
|
||||
|
||||
find /bin /etc /lib /sbin /usr \
|
||||
! -name lost+found \
|
||||
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
|
||||
|
||||
comm -23 "$fs" "$db"
|
||||
}
|
||||
|
||||
|
12
plugins/perl/functions/pgs
Normal file
12
plugins/perl/functions/pgs
Normal file
@ -0,0 +1,12 @@
|
||||
# Perl Global Substitution
|
||||
if (( $# < 2 )); then
|
||||
print "Usage: $0 find replace [file ...]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local find="$1"
|
||||
local replace="$2"
|
||||
repeat 2 shift
|
||||
|
||||
perl -i.orig -pe 's/'"$find"'/'"$replace"'/g' "$@"
|
||||
|
11
plugins/perl/functions/prep
Normal file
11
plugins/perl/functions/prep
Normal file
@ -0,0 +1,11 @@
|
||||
# Perl grep since 'grep -P' is terrible.
|
||||
if (( $# < 1 )) ; then
|
||||
print "Usage: $0 pattern [file ...]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local pattern="$1"
|
||||
shift
|
||||
|
||||
perl -nle 'print if /'"$pattern"'/;' "$@"
|
||||
|
@ -42,30 +42,3 @@ alias pbu='perlbrew use'
|
||||
alias ple='perl -wlne'
|
||||
alias pd='perldoc'
|
||||
|
||||
# Perl Global Substitution
|
||||
function pgs() {
|
||||
if (( $# < 2 )) ; then
|
||||
echo "Usage: $0 find replace [file ...]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local find="$1"
|
||||
local replace="$2"
|
||||
repeat 2 shift
|
||||
|
||||
perl -i.orig -pe 's/'"$find"'/'"$replace"'/g' "$@"
|
||||
}
|
||||
|
||||
# Perl grep since 'grep -P' is terrible.
|
||||
function prep() {
|
||||
if (( $# < 1 )) ; then
|
||||
echo "Usage: $0 pattern [file ...]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local pattern="$1"
|
||||
shift
|
||||
|
||||
perl -nle 'print if /'"$pattern"'/;' "$@"
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ if [[ "$OSTYPE" == darwin* ]]; then
|
||||
# gem is slow; cache its output.
|
||||
cache_file="${0:h}/cache.zsh"
|
||||
if [[ ! -f "$cache_file" ]]; then
|
||||
echo export GEM_PATH=$GEM_HOME:$(gem env gempath) >! "$cache_file"
|
||||
print export GEM_PATH=$GEM_HOME:$(gem env gempath) >! "$cache_file"
|
||||
source "$cache_file"
|
||||
else
|
||||
source "$cache_file"
|
||||
|
@ -28,13 +28,13 @@ function _ssh-agent-start() {
|
||||
local -a identities
|
||||
|
||||
# Start ssh-agent and setup environment.
|
||||
/usr/bin/env ssh-agent | sed 's/^echo/#echo/' > "${_ssh_agent_env}"
|
||||
/usr/bin/env ssh-agent | sed 's/^print/#print/' > "${_ssh_agent_env}"
|
||||
chmod 600 "${_ssh_agent_env}"
|
||||
source "${_ssh_agent_env}" > /dev/null
|
||||
|
||||
# Load identies.
|
||||
zstyle -a :omz:plugins:ssh-agent identities identities
|
||||
echo starting...
|
||||
print starting...
|
||||
/usr/bin/ssh-add "$HOME/.ssh/${^identities}"
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ alias mr='mate CHANGELOG app config db lib public script spec test'
|
||||
|
||||
# Functions
|
||||
function tm() {
|
||||
cd $1
|
||||
mate $1
|
||||
cd "$1" && mate .
|
||||
}
|
||||
|
||||
|
13
plugins/wakeonlan/functions/wake
Normal file
13
plugins/wakeonlan/functions/wake
Normal file
@ -0,0 +1,13 @@
|
||||
local config_file="$HOME/.wakeonlan/$1"
|
||||
if [[ ! -f "$config_file" ]]; then
|
||||
print "$0: $1: There is no such device file." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if (( ! $+commands[wakeonlan] )); then
|
||||
print "$0: Can't find wakeonlan. Is it installed?" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
wakeonlan -f "$config_file"
|
||||
|
@ -1,15 +0,0 @@
|
||||
function wake() {
|
||||
local config_file="$HOME/.wakeonlan/$1"
|
||||
if [[ ! -f "$config_file" ]]; then
|
||||
echo "$0: $1: There is no such device file." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if (( ! $+commands[wakeonlan] )); then
|
||||
echo "$0: Can't find wakeonlan. Is it installed?" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
wakeonlan -f "$config_file"
|
||||
}
|
||||
|
Reference in New Issue
Block a user