Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal for option for allowing alias definitions #341

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions modules/directory/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ unsetopt CLOBBER # Do not overwrite existing files with > and >>.
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all directory; then
return 0
fi

alias d='dirs -v'
for index ({1..9}) alias "$index"="cd +${index}"; unset index

5 changes: 5 additions & 0 deletions modules/dpkg/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ fi
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all dpkg; then
return 0
fi

# Cleans the cache.
alias debc='sudo apt-get clean && sudo apt-get autoclean'

Expand Down
5 changes: 5 additions & 0 deletions modules/fasd/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ function fasd_cd {
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all fasd; then
return 0
fi

# Changes the current working directory interactively.
alias j='fasd_cd -i'

5 changes: 5 additions & 0 deletions modules/git/alias.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ zstyle -s ':prezto:module:git:status:ignore' submodules '_git_status_ignore_subm
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all git; then
return 0
fi

# Git
alias g='git'

Expand Down
5 changes: 5 additions & 0 deletions modules/history/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@ setopt HIST_BEEP # Beep when accessing non-existent history.
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all history; then
return 0
fi

# Lists the ten most used commands.
alias history-stat="history 0 | awk '{print \$2}' | sort | uniq -c | sort -n -r | head"
5 changes: 5 additions & 0 deletions modules/macports/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ path=(
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all macports; then
return 0
fi

alias portc='sudo port clean --all installed'
alias porti='sudo port install'
alias ports='port search'
Expand Down
25 changes: 15 additions & 10 deletions modules/osx/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ if [[ "$OSTYPE" != darwin* ]]; then
return 1
fi

#
# Aliases
#

# Change directory to the current Finder directory.
alias cdf='cd "$(pfd)"'

# Push directory to the current Finder directory.
alias pushdf='pushd "$(pfd)"'

#
# Functions
#
Expand All @@ -37,3 +27,18 @@ function rm-osx-cruft {
\) -print0 | xargs -0 rm -rf
}

#
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all osx; then
return 0
fi

# Change directory to the current Finder directory.
alias cdf='cd "$(pfd)"'

# Push directory to the current Finder directory.
alias pushdf='pushd "$(pfd)"'

5 changes: 5 additions & 0 deletions modules/pacman/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ fi
# Frontend
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all pacman; then
return 0
fi

# Get the Pacman frontend.
zstyle -s ':prezto:module:pacman' frontend '_pacman_frontend'

Expand Down
5 changes: 5 additions & 0 deletions modules/perl/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ fi
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all perl; then
return 0
fi

# General
alias pl='perl'
alias pld='perldoc'
Expand Down
5 changes: 5 additions & 0 deletions modules/python/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ fi
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all python; then
return 0
fi

alias py='python'

# pythonz
Expand Down
5 changes: 5 additions & 0 deletions modules/rails/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ fi
# Aliases (Compatible with Rails 2)
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all rails; then
return 0
fi

alias ror='rails'
alias rorc='_rails-command console'
alias rordc='_rails-command dbconsole'
Expand Down
5 changes: 5 additions & 0 deletions modules/rsync/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ fi
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all rsync; then
return 0
fi

_rsync_cmd='rsync --verbose --progress --human-readable --compress --archive --hard-links --one-file-system'

# Mac OS X and HFS+ Enhancements
Expand Down
5 changes: 5 additions & 0 deletions modules/ruby/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ fi
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all ruby; then
return 0
fi

# General
alias rb='ruby'

Expand Down
5 changes: 5 additions & 0 deletions modules/screen/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ fi
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all screen; then
return 0
fi

alias scr='screen'
alias scrl='screen -list'
alias scrn='screen -U -S'
Expand Down
5 changes: 5 additions & 0 deletions modules/tmux/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ fi
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all tmux; then
return 0
fi

alias tmuxa='tmux attach-session'
alias tmuxl='tmux list-sessions'
83 changes: 44 additions & 39 deletions modules/utility/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,54 @@ pmodload 'helper' 'spectrum'
# Correct commands.
setopt CORRECT

#
# 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:-$USER}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}"
}

#
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all utility; then
return 0
fi

# Disable correction.
alias ack='nocorrect ack'
alias cd='nocorrect cd'
Expand Down Expand Up @@ -139,42 +183,3 @@ fi
# 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:-$USER}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}"
}

5 changes: 5 additions & 0 deletions modules/yum/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ fi
# Aliases
#

# Return if conditions are unsatistied
if ! zstyle -t ':prezto:alias' pmodule all yum; then
return 0
fi

alias yumc='sudo yum clean all' # Cleans the cache.
alias yumh='yum history' # Displays history.
alias yumi='sudo yum install' # Installs package(s).
Expand Down
10 changes: 10 additions & 0 deletions runcoms/zpreztorc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ zstyle ':prezto:load' pmodule \
'completion' \
'prompt'

#
# Alias
#

# Allow aliases defined in all loaded modules with 'all'
# Commenting out will disable aliases
# Specific modules can be loaded with:
# zstyle ':prezto:alias' pmodule 'git' 'ruby' 'osx'
zstyle ':prezto:alias' pmodule 'all'

#
# Editor
#
Expand Down