init
This commit is contained in:
158
.zprezto/modules/utility/README.md
Normal file
158
.zprezto/modules/utility/README.md
Normal file
@@ -0,0 +1,158 @@
|
||||
Utility
|
||||
=======
|
||||
|
||||
Defines general aliases and functions.
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
### Highlighting
|
||||
|
||||
If you have enabled color globally in *zpreztorc*, you may disable it for certain
|
||||
commands.
|
||||
|
||||
To disable `ls` color, add the following line to *zpreztorc*; when coloring is
|
||||
disabled, type indicators (\*, /, =>, @, =, |, %) will be appended to entries.
|
||||
|
||||
zstyle ':prezto:module:utility:ls' color 'no'
|
||||
|
||||
To disable `diff` highlighting, add the following line to *zpreztorc*:
|
||||
|
||||
zstyle ':prezto:module:utility:diff' color 'no'
|
||||
|
||||
To disable `wdiff` highlighting, add the following line to *zpreztorc*:
|
||||
|
||||
zstyle ':prezto:module:utility:wdiff' color 'no'
|
||||
|
||||
To disable `make` highlighting, add the following line to *zpreztorc*:
|
||||
|
||||
zstyle ':prezto:module:utility:make' color 'no'
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
### Disabled Spelling Correction
|
||||
|
||||
- `ack`
|
||||
- `cd`
|
||||
- `cp`
|
||||
- `ebuild`
|
||||
- `gcc`
|
||||
- `gist`
|
||||
- `grep`
|
||||
- `heroku`
|
||||
- `ln`
|
||||
- `man`
|
||||
- `mkdir`
|
||||
- `mv`
|
||||
- `mysql`
|
||||
- `rm`
|
||||
|
||||
### Disabled File Globbing
|
||||
|
||||
- `bower`
|
||||
- `fc`
|
||||
- `find`
|
||||
- `ftp`
|
||||
- `history`
|
||||
- `locate`
|
||||
- `rake`
|
||||
- `rsync`
|
||||
- `scp`
|
||||
- `sftp`
|
||||
|
||||
### General
|
||||
|
||||
- `_` executes a command as another user (`sudo`).
|
||||
- `b` opens the default web browser.
|
||||
- `cp` copies files and directories interactively.
|
||||
- `e` opens the default editor.
|
||||
- `ln` links files and directories interactively.
|
||||
- `mkdir` creates directories, including intermediary directories.
|
||||
- `mv` moves files and directories interactively.
|
||||
- `p` opens the default pager.
|
||||
- `po` removes a directory from the stack and changes to it (`popd`).
|
||||
- `pu` changes the directory and pushes the old directory onto the stack
|
||||
(`pushd`).
|
||||
- `rm` removes files and directories interactively.
|
||||
- `type` displays all the attribute values of a shell parameter.
|
||||
|
||||
### Files and Directories
|
||||
|
||||
- `ls` lists with directories grouped first (GNU only).
|
||||
- `l` lists in one column, hidden files.
|
||||
- `ll` lists human readable sizes.
|
||||
- `lr` lists human readable sizes, recursively.
|
||||
- `la` lists human readable sizes, hidden files.
|
||||
- `lm` lists human readable sizes, hidden files through pager.
|
||||
- `lx` lists sorted by extension (GNU only).
|
||||
- `lk` lists sorted by size, largest last.
|
||||
- `lt` lists sorted by date, most recent last.
|
||||
- `lc` lists sorted by date, most recent last, shows change time.
|
||||
- `lu` lists sorted by date, most recent last, shows access time.
|
||||
- `sl` lists directory contents (`ls`).
|
||||
|
||||
### Mac OS X Everywhere
|
||||
|
||||
- `o` opens files and directories (`open` or `xdg-open`).
|
||||
- `get` downloads files (`curl` or `wget`).
|
||||
- `pbcopy` copies to the pasteboard (`pbcopy`, `xclip` or `xsel`).
|
||||
- `pbpaste` pastes from the pasteboard (`pbcopy`, `xclip` or `xsel`).
|
||||
- `pbc` copies to the pasteboard (`pbcopy`).
|
||||
- `pbp` pastes from the pasteboard (`pbpaste`).
|
||||
|
||||
### Resource Usage
|
||||
|
||||
- `df` displays free disk space using human readable units.
|
||||
- `du` displays disk usage using human readable units.
|
||||
- `top` displays information about processes (aliased to `htop`, if installed).
|
||||
- `topc` displays information about processes sorted by CPU usage (`htop` not
|
||||
installed).
|
||||
- `topm` displays information about processes sorted by RAM usage (`htop` not
|
||||
installed).
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- `http-serve` serves a directory via HTTP.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
### General
|
||||
|
||||
- `slit` prints columns *1, 2, 3 ... n*.
|
||||
|
||||
### Files and Directories
|
||||
|
||||
- `cdls` changes to a directory and lists its contents.
|
||||
- `dut` displays the grand total disk usage using human readable units.
|
||||
- `find-exec` finds files and executes a command on them.
|
||||
- `mkdcd` makes a directory and changes to it.
|
||||
- `popdls` pops an entry off the directory stack and lists its contents.
|
||||
- `pushdls` pushes an entry onto the directory stack and lists its contents.
|
||||
|
||||
### Developer
|
||||
|
||||
- `diff` highlights diff output (requires `colordiff` or `Git`).
|
||||
- `make` highlights make output (requires `colormake`).
|
||||
- `wdiff` highlights wdiff output (requires `wdiff `or `Git`).
|
||||
|
||||
### Resource usage
|
||||
|
||||
- `psu` displays user owned processes status.
|
||||
|
||||
### Search and Replace
|
||||
|
||||
- `prep` provides a grep-like pattern search.
|
||||
- `psub` provides a sed-like pattern substitution.
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
*The authors of this module should be contacted via the [issue tracker][1].*
|
||||
|
||||
- [Robby Russell](https://github.com/robbyrussell)
|
||||
- [Suraj N. Kurapati](https://github.com/sunaku)
|
||||
- [Sorin Ionescu](https://github.com/sorin-ionescu)
|
||||
|
||||
[1]: https://github.com/sorin-ionescu/prezto/issues
|
11
.zprezto/modules/utility/functions/_cdls_popdls_pushdls
Normal file
11
.zprezto/modules/utility/functions/_cdls_popdls_pushdls
Normal file
@@ -0,0 +1,11 @@
|
||||
#compdef cdls popdls pushdls
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes cdls, popdls, and pushdls.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_cd
|
11
.zprezto/modules/utility/functions/_dut
Normal file
11
.zprezto/modules/utility/functions/_dut
Normal file
@@ -0,0 +1,11 @@
|
||||
#compdef dut
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes dut.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_du
|
13
.zprezto/modules/utility/functions/_mkdcd
Normal file
13
.zprezto/modules/utility/functions/_mkdcd
Normal file
@@ -0,0 +1,13 @@
|
||||
#compdef mkdcd
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes mkdcd.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local expl
|
||||
|
||||
_wanted directories expl 'directory' _path_files -/ || _message 'directory'
|
18
.zprezto/modules/utility/functions/_prep
Normal file
18
.zprezto/modules/utility/functions/_prep
Normal file
@@ -0,0 +1,18 @@
|
||||
#compdef prep
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes prep.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments \
|
||||
'-i[ignore case]' \
|
||||
'-m[^ and $ match the start and the end of a line]' \
|
||||
'-s[. matches newline]' \
|
||||
'-v[invert match]' \
|
||||
'-x[ignore whitespace and comments]' \
|
||||
'1::pattern:' \
|
||||
'2::files:_files' && return 0
|
19
.zprezto/modules/utility/functions/_psub
Normal file
19
.zprezto/modules/utility/functions/_psub
Normal file
@@ -0,0 +1,19 @@
|
||||
#compdef psub
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes psub.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments \
|
||||
'-g[match globally]' \
|
||||
'-i[ignore case]' \
|
||||
'-m[^ and $ match the start and the end of a line]' \
|
||||
'-s[. matches newline]' \
|
||||
'-x[ignore whitespace and comments]' \
|
||||
'1::pattern:' \
|
||||
'2::replacement:' \
|
||||
'3::files:_files' && return 0
|
22
.zprezto/modules/utility/functions/diff
Normal file
22
.zprezto/modules/utility/functions/diff
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Highlights diff output.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function diff {
|
||||
if zstyle -t ':prezto:module:utility:diff' color; then
|
||||
if (( $+commands[colordiff] )); then
|
||||
command diff --unified "$@" | colordiff --difftype diffu
|
||||
elif (( $+commands[git] )); then
|
||||
git --no-pager diff --color=auto --no-ext-diff --no-index "$@"
|
||||
else
|
||||
command diff --unified "$@"
|
||||
fi
|
||||
else
|
||||
command diff --unified "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
diff "$@"
|
27
.zprezto/modules/utility/functions/dut
Normal file
27
.zprezto/modules/utility/functions/dut
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Displays the grand total disk usage using human readable units.
|
||||
#
|
||||
# Authors:
|
||||
# Suraj N. Kurapati <sunaku@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function dut {
|
||||
(( $# == 0 )) && set -- *
|
||||
|
||||
if grep -q -i 'GNU' < <(du --version 2>&1); then
|
||||
du -khsc "$@" | sort -h -r
|
||||
else
|
||||
local line size name
|
||||
local -a record
|
||||
|
||||
while IFS=$'\n' read line; do
|
||||
record=(${(z)line})
|
||||
size="$(($record[1] / 1024.0))"
|
||||
name="$record[2,-1]"
|
||||
printf "%9.1LfM %s\n" "$size" "$name"
|
||||
done < <(du -kcs "$@") | sort -n -r
|
||||
fi
|
||||
}
|
||||
|
||||
dut "$@"
|
20
.zprezto/modules/utility/functions/make
Normal file
20
.zprezto/modules/utility/functions/make
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Highlights make output.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function make {
|
||||
if zstyle -t ':prezto:module:utility:make' color; then
|
||||
if (( $+commands[colormake] )); then
|
||||
colormake "$@"
|
||||
else
|
||||
command make "$@"
|
||||
fi
|
||||
else
|
||||
command make "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
make "$@"
|
52
.zprezto/modules/utility/functions/prep
Normal file
52
.zprezto/modules/utility/functions/prep
Normal file
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# Provides a grep-like pattern search.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local usage pattern modifiers invert
|
||||
|
||||
usage="$(
|
||||
cat <<EOF
|
||||
usage: $0 [-option ...] [--] pattern [file ...]
|
||||
|
||||
options:
|
||||
-i ignore case
|
||||
-m ^ and $ match the start and the end of a line
|
||||
-s . matches newline
|
||||
-v invert match
|
||||
-x ignore whitespace and comments
|
||||
EOF
|
||||
)"
|
||||
|
||||
while getopts ':imsxv' opt; do
|
||||
case "$opt" in
|
||||
(i) modifiers="${modifiers}i" ;;
|
||||
(m) modifiers="${modifiers}m" ;;
|
||||
(s) modifiers="${modifiers}s" ;;
|
||||
(x) modifiers="${modifiers}x" ;;
|
||||
(v) invert="yes" ;;
|
||||
(:)
|
||||
print "$0: option requires an argument: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
([?])
|
||||
print "$0: unknown option: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if (( $# < 1 )); then
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
pattern="$1"
|
||||
shift
|
||||
|
||||
perl -n -l -e "print if ${invert:+not} m/${pattern//\//\\/}/${modifiers}" "$@"
|
53
.zprezto/modules/utility/functions/psub
Normal file
53
.zprezto/modules/utility/functions/psub
Normal file
@@ -0,0 +1,53 @@
|
||||
#
|
||||
# Provides a sed-like pattern substitution.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local usage pattern replacement modifiers
|
||||
|
||||
usage="$(
|
||||
cat <<EOF
|
||||
usage: $0 [-option ...] [--] pattern replacement [file ...]
|
||||
|
||||
options:
|
||||
-g match globally
|
||||
-i ignore case
|
||||
-m ^ and $ match the start and the end of a line
|
||||
-s . matches newline
|
||||
-x ignore whitespace and comments
|
||||
EOF
|
||||
)"
|
||||
|
||||
while getopts ':gimsx' opt; do
|
||||
case "$opt" in
|
||||
(g) modifiers="${modifiers}g" ;;
|
||||
(i) modifiers="${modifiers}i" ;;
|
||||
(m) modifiers="${modifiers}m" ;;
|
||||
(s) modifiers="${sodifiers}s" ;;
|
||||
(x) modifiers="${modifiers}x" ;;
|
||||
(:)
|
||||
print "$0: option requires an argument: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
([?])
|
||||
print "$0: unknown option: $OPTARG" >&2
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if (( $# < 2 )); then
|
||||
print "$usage" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
pattern="$1"
|
||||
replacement="$2"
|
||||
repeat 2 shift
|
||||
|
||||
perl -i'.orig' -n -l -e "s/${pattern//\//\\/}/${replacement//\//\\/}/${modifiers}; print" "$@"
|
29
.zprezto/modules/utility/functions/wdiff
Normal file
29
.zprezto/modules/utility/functions/wdiff
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Highlights wdiff output.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
function wdiff {
|
||||
if zstyle -t ':prezto:module:utility:wdiff' color; then
|
||||
if (( $+commands[wdiff] )); then
|
||||
command wdiff \
|
||||
--avoid-wraps \
|
||||
--start-delete="$(print -n $FG[red])" \
|
||||
--end-delete="$(print -n $FG[none])" \
|
||||
--start-insert="$(print -n $FG[green])" \
|
||||
--end-insert="$(print -n $FG[none])" \
|
||||
"$@" \
|
||||
| sed 's/^\(@@\( [+-][[:digit:]]*,[[:digit:]]*\)\{2\} @@\)$/;5;6m\10m/g'
|
||||
elif (( $+commands[git] )); then
|
||||
git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@"
|
||||
else
|
||||
command wdiff "$@"
|
||||
fi
|
||||
else
|
||||
command wdiff "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
wdiff "$@"
|
196
.zprezto/modules/utility/init.zsh
Normal file
196
.zprezto/modules/utility/init.zsh
Normal file
@@ -0,0 +1,196 @@
|
||||
#
|
||||
# Defines general aliases and functions.
|
||||
#
|
||||
# Authors:
|
||||
# Robby Russell <robby@planetargon.com>
|
||||
# Suraj N. Kurapati <sunaku@gmail.com>
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# Load dependencies.
|
||||
pmodload 'helper' 'spectrum'
|
||||
|
||||
# Correct commands.
|
||||
setopt CORRECT
|
||||
|
||||
#
|
||||
# Aliases
|
||||
#
|
||||
|
||||
# Disable correction.
|
||||
alias ack='nocorrect ack'
|
||||
alias cd='nocorrect cd'
|
||||
alias cp='nocorrect cp'
|
||||
alias ebuild='nocorrect ebuild'
|
||||
alias gcc='nocorrect gcc'
|
||||
alias gist='nocorrect gist'
|
||||
alias grep='nocorrect grep'
|
||||
alias heroku='nocorrect heroku'
|
||||
alias ln='nocorrect ln'
|
||||
alias man='nocorrect man'
|
||||
alias mkdir='nocorrect mkdir'
|
||||
alias mv='nocorrect mv'
|
||||
alias mysql='nocorrect mysql'
|
||||
alias rm='nocorrect rm'
|
||||
|
||||
# Disable globbing.
|
||||
alias bower='noglob bower'
|
||||
alias fc='noglob fc'
|
||||
alias find='noglob find'
|
||||
alias ftp='noglob ftp'
|
||||
alias history='noglob history'
|
||||
alias locate='noglob locate'
|
||||
alias rake='noglob rake'
|
||||
alias rsync='noglob rsync'
|
||||
alias scp='noglob scp'
|
||||
alias sftp='noglob sftp'
|
||||
|
||||
# Define general aliases.
|
||||
alias _='sudo'
|
||||
alias b='${(z)BROWSER}'
|
||||
alias e='${(z)VISUAL:-${(z)EDITOR}}'
|
||||
alias mkdir="${aliases[mkdir]:-mkdir} -p"
|
||||
alias p='${(z)PAGER}'
|
||||
alias po='popd'
|
||||
alias pu='pushd'
|
||||
alias type='type -a'
|
||||
|
||||
# ls
|
||||
if is-callable 'dircolors'; then
|
||||
# GNU Core Utilities
|
||||
alias ls='ls --group-directories-first'
|
||||
|
||||
if zstyle -t ':prezto:module:utility:ls' color; then
|
||||
if [[ -s "$HOME/.dir_colors" ]]; then
|
||||
eval "$(dircolors --sh "$HOME/.dir_colors")"
|
||||
else
|
||||
eval "$(dircolors --sh)"
|
||||
fi
|
||||
|
||||
alias ls="${aliases[ls]:-ls} --color=auto"
|
||||
else
|
||||
alias ls="${aliases[ls]:-ls} -F"
|
||||
fi
|
||||
else
|
||||
# BSD Core Utilities
|
||||
if zstyle -t ':prezto:module:utility:ls' color; then
|
||||
# Define colors for BSD ls.
|
||||
export LSCOLORS='exfxcxdxbxGxDxabagacad'
|
||||
|
||||
# Define colors for the completion system.
|
||||
export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:'
|
||||
|
||||
alias ls="${aliases[ls]:-ls} -G"
|
||||
else
|
||||
alias ls="${aliases[ls]:-ls} -F"
|
||||
fi
|
||||
fi
|
||||
|
||||
alias l='ls -lAh' # Lists in one column, hidden files.
|
||||
alias ll='ls -lh' # Lists human readable sizes.
|
||||
alias lr='ll -R' # Lists human readable sizes, recursively.
|
||||
alias la='ll -A' # Lists human readable sizes, hidden files.
|
||||
alias lm='la | "$PAGER"' # Lists human readable sizes, hidden files through pager.
|
||||
alias lx='ll -XB' # Lists sorted by extension (GNU only).
|
||||
alias lk='ll -Sr' # Lists sorted by size, largest last.
|
||||
alias lt='ll -tr' # Lists sorted by date, most recent last.
|
||||
alias lc='lt -c' # Lists sorted by date, most recent last, shows change time.
|
||||
alias lu='lt -u' # Lists sorted by date, most recent last, shows access time.
|
||||
alias sl='ls' # I often screw this up.
|
||||
|
||||
# Grep
|
||||
if zstyle -t ':prezto:module:utility:grep' color; then
|
||||
export GREP_COLOR='37;45' # BSD.
|
||||
export GREP_COLORS="mt=$GREP_COLOR" # GNU.
|
||||
|
||||
alias grep="${aliases[grep]:-grep} --color=auto"
|
||||
fi
|
||||
|
||||
# Mac OS X Everywhere
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
alias o='open'
|
||||
elif [[ "$OSTYPE" == cygwin* ]]; then
|
||||
alias o='cygstart'
|
||||
alias pbcopy='tee > /dev/clipboard'
|
||||
alias pbpaste='cat /dev/clipboard'
|
||||
else
|
||||
alias o='xdg-open'
|
||||
|
||||
if (( $+commands[xclip] )); then
|
||||
alias pbcopy='xclip -selection clipboard -in'
|
||||
alias pbpaste='xclip -selection clipboard -out'
|
||||
elif (( $+commands[xsel] )); then
|
||||
alias pbcopy='xsel --clipboard --input'
|
||||
alias pbpaste='xsel --clipboard --output'
|
||||
fi
|
||||
fi
|
||||
|
||||
alias pbc='pbcopy'
|
||||
alias pbp='pbpaste'
|
||||
|
||||
# File Download
|
||||
if (( $+commands[curl] )); then
|
||||
alias get='curl --continue-at - --location --progress-bar --remote-name --remote-time'
|
||||
elif (( $+commands[wget] )); then
|
||||
alias get='wget --continue --progress=bar --timestamping'
|
||||
fi
|
||||
|
||||
# Resource Usage
|
||||
alias df='df -kh'
|
||||
alias du='du -kh'
|
||||
|
||||
if (( $+commands[htop] )); then
|
||||
alias top=htop
|
||||
else
|
||||
if [[ "$OSTYPE" == (darwin*|*bsd*) ]]; then
|
||||
alias topc='top -o cpu'
|
||||
alias topm='top -o vsize'
|
||||
else
|
||||
alias topc='top -o %CPU'
|
||||
alias topm='top -o %MEM'
|
||||
fi
|
||||
fi
|
||||
|
||||
# Miscellaneous
|
||||
|
||||
# Serves a directory via HTTP.
|
||||
alias http-serve='python -m SimpleHTTPServer'
|
||||
|
||||
#
|
||||
# Functions
|
||||
#
|
||||
|
||||
# Makes a directory and changes to it.
|
||||
function mkdcd {
|
||||
[[ -n "$1" ]] && mkdir -p "$1" && builtin cd "$1"
|
||||
}
|
||||
|
||||
# Changes to a directory and lists its contents.
|
||||
function cdls {
|
||||
builtin cd "$argv[-1]" && ls "${(@)argv[1,-2]}"
|
||||
}
|
||||
|
||||
# Pushes an entry onto the directory stack and lists its contents.
|
||||
function pushdls {
|
||||
builtin pushd "$argv[-1]" && ls "${(@)argv[1,-2]}"
|
||||
}
|
||||
|
||||
# Pops an entry off the directory stack and lists its contents.
|
||||
function popdls {
|
||||
builtin popd "$argv[-1]" && ls "${(@)argv[1,-2]}"
|
||||
}
|
||||
|
||||
# Prints columns 1 2 3 ... n.
|
||||
function slit {
|
||||
awk "{ print ${(j:,:):-\$${^@}} }"
|
||||
}
|
||||
|
||||
# Finds files and executes a command on them.
|
||||
function find-exec {
|
||||
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
|
||||
}
|
||||
|
||||
# Displays user owned processes status.
|
||||
function psu {
|
||||
ps -U "${1:-$LOGNAME}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}"
|
||||
}
|
Reference in New Issue
Block a user