Unverified Commit 0232ac4b authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

Merge branch 'master' into master

parents afb02876 ebc700be
# Some Useful CloudFoundry Aliases & Functions
alias cfl="cf login"
alias cft="cf target"
alias cfa="cf apps"
alias cfs="cf services"
alias cfm="cf marketplace"
alias cfp="cf push"
alias cfcs="cf create-service"
alias cfbs="cf bind-service"
alias cfus="cf unbind-service"
alias cfds="cf delete-service"
alias cfup="cf cups"
alias cflg="cf logs"
alias cfr="cf routes"
alias cfe="cf env"
alias cfsh="cf ssh"
alias cfsc="cf scale"
alias cfev="cf events"
alias cfdor="cf delete-orphaned-routes"
alias cfbpk="cf buildpacks"
alias cfdm="cf domains"
alias cfsp="cf spaces"
function cfap() { cf app $1 }
function cfh.() { export CF_HOME=$PWD/.cf }
function cfh~() { export CF_HOME=~/.cf }
function cfhu() { unset CF_HOME }
function cfpm() { cf push -f $1 }
function cflr() { cf logs $1 --recent }
function cfsrt() { cf start $1 }
function cfstp() { cf stop $1 }
function cfstg() { cf restage $1 }
function cfdel() { cf delete $1 }
function cfsrtall() {cf apps | awk '/stopped/ { system("cf start " $1)}'}
function cfstpall() {cf apps | awk '/started/ { system("cf stop " $1)}'}
#compdef coffee
# ------------------------------------------------------------------------------
# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users
# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
......@@ -28,7 +28,7 @@
# Description
# -----------
#
# Completion script for Coffee.js v0.6.11 (http://coffeejs.org)
# Completion script for Coffee.js v0.6.11 (https://coffeescript.org)
#
# ------------------------------------------------------------------------------
# Authors
......
# colorize
With this plugin you can syntax-highlight file contents of over 300 supported languages and other text formats.
Colorize will highlight the content based on the filename extension. If it can't find a syntax-highlighting
method for a given extension, it will try to find one by looking at the file contents. If no highlight method
is found it will just cat the file normally, without syntax highlighting.
To use it, add colorize to the plugins array of your zshrc file:
```
plugins=(... colorize)
```
## Usage
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
If no arguments are passed it will colorize the standard input or stdin.
* `cless <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and
open less. If no arguments are passed it will colorize the standard input or stdin.
Note that `cless` will behave as less when provided more than one file: you have to navigate files with
the commands `:n` for next and `:p` for previous. The downside is that less options are not supported.
But you can circumvent this by either using the LESS environment variable, or by running `ccat file1 file2|less --opts`.
In the latter form, the file contents will be concatenated and presented by less as a single file.
## Requirements
You have to install Pygments first: [pygments.org](http://pygments.org/download/)
# Plugin for highlighting file content
# Plugin highlights file content based on the filename extension.
# If no highlighting method supported for given extension then it tries
# guess it by looking for file content.
#easier alias to use plugin
# easier alias to use the plugin
alias ccat='colorize_via_pygmentize'
alias cless='colorize_via_pygmentize_less'
colorize_via_pygmentize() {
if [ ! -x "$(which pygmentize)" ]; then
echo "package \'Pygments\' is not installed!"
return -1
if ! (( $+commands[pygmentize] )); then
echo "package 'Pygments' is not installed!"
return 1
fi
# pygmentize stdin if no arguments passed
if [ $# -eq 0 ]; then
pygmentize -g $@
pygmentize -g
return $?
fi
for FNAME in $@
# guess lexer from file extension, or
# guess it from file contents if unsuccessful
local FNAME lexer
for FNAME in "$@"
do
filename=$(basename "$FNAME")
lexer=`pygmentize -N \"$filename\"`
if [ "Z$lexer" != "Ztext" ]; then
pygmentize -l $lexer "$FNAME"
lexer=$(pygmentize -N "$FNAME")
if [[ $lexer != text ]]; then
pygmentize -l "$lexer" "$FNAME"
else
pygmentize -g "$FNAME"
fi
done
}
colorize_via_pygmentize_less() (
# this function is a subshell so tmp_files can be shared to cleanup function
declare -a tmp_files
cleanup () {
[[ ${#tmp_files} -gt 0 ]] && rm -f "${tmp_files[@]}"
exit
}
trap 'cleanup' EXIT HUP TERM INT
while (( $# != 0 )); do #TODO: filter out less opts
tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")"
tmp_files+=("$tmp_file")
colorize_via_pygmentize "$1" > "$tmp_file"
shift 1
done
less -f "${tmp_files[@]}"
)
# command-not-found plugin
This plugin uses the command-not-found package for zsh to provide suggested packages to be installed if a command cannot be found.
To use it, add `command-not-found` to the plugins array of your zshrc file:
```zsh
plugins=(... command-not-found)
```
An example of how this plugin works in Ubuntu:
```
$ mutt
The program 'mutt' can be found in the following packages:
* mutt
* mutt-kz
* mutt-patched
Try: sudo apt install <selected package>
```
### Supported platforms
It works out of the box with the command-not-found packages for:
- [Ubuntu](https://www.porcheron.info/command-not-found-for-zsh/)
- [Debian](https://packages.debian.org/search?keywords=command-not-found)
- [Arch Linux](https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found)
- [macOS (Homebrew)](https://github.com/Homebrew/homebrew-command-not-found)
- [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound)
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found)
You can add support for other platforms by submitting a Pull Request.
# Uses the command-not-found package zsh support
# as seen in http://www.porcheron.info/command-not-found-for-zsh/
# as seen in https://www.porcheron.info/command-not-found-for-zsh/
# this is installed in Ubuntu
[[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found
......@@ -31,3 +31,10 @@ if type brew &> /dev/null; then
eval "$(brew command-not-found-init)";
fi
fi
# NixOS command-not-found support
if [ -x /run/current-system/sw/bin/command-not-found ]; then
command_not_found_handler () {
/run/current-system/sw/bin/command-not-found $@
}
fi
......@@ -13,7 +13,7 @@ alias lS='ls -1FSsh'
alias lart='ls -1Fcart'
alias lrt='ls -1Fcrt'
alias zshrc='$EDITOR ~/.zshrc' # Quick access to the ~/.zshrc file
alias zshrc='${=EDITOR} ~/.zshrc' # Quick access to the ~/.zshrc file
alias grep='grep --color'
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
......@@ -44,8 +44,6 @@ alias p='ps -f'
alias sortnr='sort -n -r'
alias unexport='unset'
alias whereami=display_info
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
......
# composer
This plugin provides completion for [composer](https://getcomposer.org/), as well as aliases
for frequent composer commands. It also adds Composer's global binaries to the PATH, using
Composer if available.
To use it add `composer` to the plugins array in your zshrc file.
```zsh
plugins=(... composer)
```
## Aliases
| Alias | Command | Description |
| ------ | -------------------------------------------- | -------------------------------------------------------------------------------------- |
| `c` | composer | Starts composer |
| `csu` | composer self-update | Updates composer to the latest version |
| `cu` | composer update | Updates composer dependencies and `composer.lock` file |
| `cr` | composer require | Adds new packages to `composer.json` |
| `crm` | composer remove | Removes packages from `composer.json` |
| `ci` | composer install | Resolves and installs dependencies from `composer.json` |
| `ccp` | composer create-project | Create new project from an existing package |
| `cdu` | composer dump-autoload | Updates the autoloader |
| `cdo` | composer dump-autoload --optimize-autoloader | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) |
| `cgu` | composer global update | Allows update command to run on COMPOSER_HOME directory |
| `cgr` | composer global require | Allows require command to run on COMPOSER_HOME directory |
| `cgrm` | composer global remove | Allows remove command to run on COMPOSER_HOME directory |
| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory |
......@@ -51,5 +51,10 @@ alias cgrm='composer global remove'
# install composer in the current directory
alias cget='curl -s https://getcomposer.org/installer | php'
# Add Composer's global binaries to PATH
export PATH=$PATH:$(composer global config bin-dir --absolute 2>/dev/null)
# Add Composer's global binaries to PATH, using Composer if available.
if (( $+commands[composer] )); then
export PATH=$PATH:$(composer global config bin-dir --absolute 2>/dev/null)
else
[ -d $HOME/.composer/vendor/bin ] && export PATH=$PATH:$HOME/.composer/vendor/bin
[ -d $HOME/.config/composer/vendor/bin ] && export PATH=$PATH:$HOME/.config/composer/vendor/bin
fi
# copydir plugin
Copies the path of your current folder to the system clipboard.
To use, add `copydir` to your plugins array:
```
plugins=(... copydir)
```
Then use the command `copydir` to copy the $PWD.
# copyfile plugin
Puts the contents of a file in your system clipboard so you can paste it anywhere.
To use, add `copyfile` to your plugins array:
```
plugins=(... copyfile)
```
Then you can run the command `copyfile <filename>` to copy the file named `filename`.
# Cpanm
This plugin provides completion for [Cpanm](https://github.com/miyagawa/cpanminus) ([docs](https://metacpan.org/pod/App::cpanminus)).
To use it add cpanm to the plugins array in your zshrc file.
```bash
plugins=(... cpanm)
```
......@@ -6,9 +6,6 @@
#
# Current supported cpanm version: 1.4000 (Tue Mar 8 01:00:49 PST 2011)
#
# The latest code is always located at:
# https://github.com/rshhh/cpanminus/blob/master/etc/_cpanm
#
local arguments curcontext="$curcontext"
typeset -A opt_args
......
# Usage: dash [keyword:]query
dash() { open dash://"$*" }
compdef _dash dash
_dash() {
# No sense doing this for anything except the 2nd position and if we haven't
# specified which docset to query against
if [[ $CURRENT -eq 2 && ! "$words[2]" =~ ":" ]]; then
local -a _all_docsets
_all_docsets=()
# Use defaults to get the array of docsets from preferences
# Have to smash it into one big line so that each docset is an element of
# our DOCSETS array
DOCSETS=("${(@f)$(defaults read com.kapeli.dashdoc docsets | tr -d '\n' | grep -oE '\{.*?\}')}")
# remove all newlines since defaults prints so pretty like
# Now get each docset and output each on their own line
for doc in "$DOCSETS[@]"; do
# Only output docsets that are actually enabled
if [[ "`echo $doc | grep -Eo \"isEnabled = .*?;\" | sed 's/[^01]//g'`" == "0" ]]; then
continue
fi
keyword=''
# Order of preference as explained to me by @kapeli via email
KEYWORD_LOCATORS=(keyword suggestedKeyword platform)
for locator in "$KEYWORD_LOCATORS[@]"; do
# Echo the docset, try to find the appropriate keyword
# Strip doublequotes and colon from any keyword so that everything has the
# same format when output (we'll add the colon in the completion)
keyword=`echo $doc | grep -Eo "$locator = .*?;" | sed -e "s/$locator = \(.*\);/\1/" -e "s/[\":]//g"`
if [[ ! -z "$keyword" ]]; then
# if we fall back to platform, we should do some checking per @kapeli
if [[ "$locator" == "platform" ]]; then
# Since these are the only special cases right now, let's not do the
# expensive processing unless we have to
if [[ "$keyword" == "python" || "$keyword" == "java" || \
"$keyword" == "qt" || "$keyword" == "cocs2d" ]]; then
docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"`
if [[ "$keyword" == "python" ]]; then
if [[ "$docsetName" == "Python 2" ]]; then
keyword="python2"
elif [[ "$docsetName" == "Python 3" ]]; then
keyword="python3"
fi
elif [[ "$keyword" == "java" ]]; then
if [[ "$docsetName" == "Java SE7" ]]; then
keyword="java7"
elif [[ "$docsetName" == "Java SE6" ]]; then
keyword="java6"
elif [[ "$docsetName" == "Java SE8" ]]; then
keyword="java8"
fi
elif [[ "$keyword" == "qt" ]]; then
if [[ "$docsetName" == "Qt 5" ]]; then
keyword="qt5"
elif [[ "$docsetName" == "Qt 4" ]]; then
keyword="qt4"
elif [[ "$docsetName" == "Qt" ]]; then
keyword="qt4"
fi
elif [[ "$keyword" == "cocos2d" ]]; then
if [[ "$docsetName" == "Cocos3D" ]]; then
keyword="cocos3d"
fi
fi
fi
fi
# Bail once we have a match
break
fi
done
# If we have a keyword, add it to the list!
if [[ ! -z "$keyword" ]]; then
_all_docsets+=($keyword)
fi
done
# special thanks to [arx] on #zsh for getting me sorted on this piece
compadd -qS: -- "$_all_docsets[@]"
return
fi
}
# debian
This plugin provides debian related zsh aliases.
To use it add `debian` to the plugins array in your zshrc file.
```zsh
plugins=(... debian)
```
## Common Aliases
| Alias | Command | Description |
| -------- | ------------------------------------------------------------------------------|--------------------------------------------------------------------------- |
| `age` | apt-get | Command line tool for handling packages |
| `api` | aptitude | Same functionality as `apt-get`, provides extra options while installation |
| `acs` | apt-cache search | Command line tool for searching apt software package cache |
| `aps` | aptitude search | Searches installed packages using aptitude |
| `as` | aptitude -F \"* %p -> %d \n(%v/%V)\" \ -no-gui --disable-columns search | - |
| `afs` | apt-file search --regexp | Search file in packages |
| `asrc` | apt-get source | Fetch source packages through `apt-get` |
| `app` | apt-cache policy | Displays priority of package sources |
## Superuser Operations Aliases
| Alias | Command | Description |
| -------- | -------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------- |
| `aac` | sudo $apt_pref autoclean | Clears out the local repository of retrieved package files |
| `abd` | sudo $apt_pref build-dep | Installs all dependencies for building packages |
| `ac` | sudo $apt_pref clean | Clears out the local repository of retrieved package files except lock files |
| `ad` | sudo $apt_pref update | Updates the package lists for upgrades for packages |
| `adg` | sudo $apt_pref update && sudo $apt_pref $apt_upgr | Update and upgrade packages |
| `adu` | sudo $apt_pref update && sudo $apt_pref dist-upgrade | Smart upgrade that handles dependencies |
| `afu` | sudo apt-file update | Update the files in packages |
| `au` | sudo $apt_pref $apt_upgr | - |
| `ai` | sudo $apt_pref install | Command-line tool to install package |
| `ail` | sed -e 's/ */ /g' -e 's/ *//' &#124; cut -s -d ' ' -f 1 &#124; "' xargs sudo $apt_pref install | Install all packages given on the command line while using only the first word of each line |
| `ap` | sudo $apt_pref purge | Removes packages along with configuration files |
| `ar` | sudo $apt_pref remove | Removes packages, keeps the configuration files |
| `ads` | sudo apt-get dselect-upgrade | Installs packages from list and removes all not in the list |
| `dia` | sudo dpkg -i ./*.deb | Install all .deb files in the current directory |
| `di` | sudo dpkg -i | Install all .deb files in the current directory |
| `kclean` | sudo aptitude remove -P ?and(~i~nlinux-(ima&#124;hea) ?not(~n`uname -r`)) | Remove ALL kernel images and headers EXCEPT the one in use |
- `$apt_pref` - Use apt or aptitude if installed, fallback is apt-get.
- `$apt_upgr` - Use upgrade.
## Aliases - Commands using `su`
| Alias | Command |
| -------- | ------------------------------------------------------------------------------|
| `aac` | su -ls \'$apt_pref autoclean\' root |
| `ac` | su -ls \'$apt_pref clean\' root |
| `ad` | su -lc \'$apt_pref update\' root |
| `adg` | su -lc \'$apt_pref update && aptitude $apt_upgr\' root |
| `adu` | su -lc \'$apt_pref update && aptitude dist-upgrade\' root |
| `afu` | su -lc "apt-file update |
| `ag` | su -lc \'$apt_pref $apt_upgr\' root |
| `dia` | su -lc "dpkg -i ./*.deb" root |
## Miscellaneous Aliases
| Alias | Command | Description |
| -------- | -------------------------------------------------|---------------------------------------- |
| `allpkgs`| aptitude search -F "%p" --disable-columns ~i | Display all installed packages |
| `mydeb` | time dpkg-buildpackage -rfakeroot -us -uc | Create a basic .deb package |
## Functions
| Fucntion | Description |
|-----------------------|-------------------------------------------------------------------------------|
| `apt-copy` | Create a simple script that can be used to 'duplicate' a system |
| `apt-history` | Displays apt history for a command |
| `kerndeb` | Builds kernel packages |
| `apt-list-packages` | List packages by size |
......@@ -5,9 +5,12 @@
#
# Debian-related zsh aliases and functions for zsh
# Use aptitude if installed, or apt-get if not.
# Use apt or aptitude if installed, fallback is apt-get
# You can just set apt_pref='apt-get' to override it.
if [[ -e $( which -p aptitude 2>&1 ) ]]; then
if [[ -e $( which -p apt 2>&1 ) ]]; then
apt_pref='apt'
apt_upgr='upgrade'
elif [[ -e $( which -p aptitude 2>&1 ) ]]; then
apt_pref='aptitude'
apt_upgr='safe-upgrade'
else
......@@ -176,7 +179,7 @@ apt-copy() {
# apt-history remove
# apt-history rollback
# apt-history list
# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
# Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
apt-history () {
case "$1" in
install)
......
# dircycle
Plugin for cycling through the directory stack
This plugin enables directory navigation similar to using back and forward on browsers or common file explorers like Finder or Nautilus. It uses a small zle trick that lets you cycle through your directory stack left or right using <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> / <kbd>Right</kbd> . This is useful when moving back and forth between directories in development environments, and can be thought of as kind of a nondestructive pushd/popd.
## Enabling the plugin
1. Open your `.zshrc` file and add `dircycle` in the plugins section:
```zsh
plugins=(
# all your enabled plugins
dircycle
)
```
2. Reload the source file or restart your Terminal session:
```console
$ source ~/.zshrc
$
```
## Usage Examples
Say you opened these directories on the terminal:
```console
~$ cd Projects
~/Projects$ cd Hacktoberfest
~/Projects/Hacktoberfest$ cd oh-my-zsh
~/Projects/Hacktoberfest/oh-my-zsh$ dirs -v
0 ~/Projects/Hacktoberfest/oh-my-zsh
1 ~/Projects/Hacktoberfest
2 ~/Projects
3 ~
```
By pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd>, the current working directory or `$CWD` will be from `oh-my-zsh` to `Hacktoberfest`. Press it again and it will be at `Projects`.
And by pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd>, the `$CWD` will be from `Projects` to `Hacktoberfest`. Press it again and it will be at `oh-my-zsh`.
Here's a example history table with the same accessed directories like above:
| Current `$CWD` | Key press | New `$CWD` |
| --------------- | ----------------------------------------------------- | --------------- |
| `oh-my-zsh` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> | `Hacktoberfest` |
| `Hacktoberfest` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> | `Projects` |
| `Projects` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> | `~` |
| `~` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | `Projects` |
| `Projects` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | `Hacktoberfest` |
| `Hacktoberfest` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | `oh-my-zsh` |
| `oh-my-zsh` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | `~` |
Note the last traversal, when pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> on a last known `$CWD`, it will change back to the first known `$CWD`, which in the example is `~`.
Here's an asciinema cast demonstrating the example above:
[![asciicast](https://asciinema.org/a/204406.png)](https://asciinema.org/a/204406)
## Functions
| Function | Description |
| -------------------- | --------------------------------------------------------------------------------------------------------- |
| `insert-cycledleft` | Change `$CWD` to the previous known stack, binded on <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> |
| `insert-cycledright` | Change `$CWD` to the next known stack, binded on <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> |
## Rebinding keys
You can bind these functions to other key sequences, as long as you know the bindkey sequence. For example, these commands bind to <kbd>Alt</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> / <kbd>Right</kbd> in `xterm-256color`:
```zsh
bindkey '^[[1;4D' insert-cycledleft
bindkey '^[[1;4C' insert-cycledright
```
You can get the bindkey sequence by pressing <kbd>Ctrl</kbd> + <kbd>V</kbd>, then pressing the keyboard shortcut you want to use.
......@@ -9,31 +9,36 @@
# pushd -N: start counting from right of `dirs' output
switch-to-dir () {
[[ ${#dirstack} -eq 0 ]] && return
setopt localoptions nopushdminus
[[ ${#dirstack} -eq 0 ]] && return 1
while ! builtin pushd -q $1 &>/dev/null; do
# We found a missing directory: pop it out of the dir stack
builtin popd -q $1
# Stop trying if there are no more directories in the dir stack
[[ ${#dirstack} -eq 0 ]] && break
[[ ${#dirstack} -eq 0 ]] && return 1
done
}
insert-cycledleft () {
emulate -L zsh
setopt nopushdminus
switch-to-dir +1 || return
switch-to-dir +1
local fn
for fn (chpwd $chpwd_functions precmd $precmd_functions); do
(( $+functions[$fn] )) && $fn
done
zle reset-prompt
}
zle -N insert-cycledleft
insert-cycledright () {
emulate -L zsh
setopt nopushdminus
switch-to-dir -0 || return
switch-to-dir -0
local fn
for fn (chpwd $chpwd_functions precmd $precmd_functions); do
(( $+functions[$fn] )) && $fn
done
zle reset-prompt
}
zle -N insert-cycledright
......
# Dirhistory plugin
This plugin adds keyboard shortcuts for navigating directory history and hierarchy.
To use it, add `dirhistory` to the plugins array in your zshrc file:
```zsh
plugins=(... dirhistory)
```
## Keyboard Shortcuts
| Shortcut | Description |
|-----------------------------------|-----------------------------------------------------------|
| <kbd>alt</kbd> + <kbd>left</kbd> | Go to previous directory |
| <kbd>alt</kbd> + <kbd>right</kbd> | Undo <kbd>alt</kbd> + <kbd>left</kbd> |
| <kbd>alt</kbd> + <kbd>up</kbd> | Move into the parent directory |
| <kbd>alt</kbd> + <kbd>down</kbd> | Move into the first child directory by alphabetical order |
......@@ -2,6 +2,10 @@
# Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
#
# Navigate directory hierarchy using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented)
# ALT-UP moves to higher hierarchy (cd ..)
# ALT-DOWN moves into the first directory found in alphabetical order
#
dirhistory_past=($PWD)
dirhistory_future=()
......@@ -120,7 +124,9 @@ zle -N dirhistory_zle_dirhistory_back
bindkey "\e[3D" dirhistory_zle_dirhistory_back
bindkey "\e[1;3D" dirhistory_zle_dirhistory_back
# Mac teminal (alt+left/right)
bindkey "^[b" dirhistory_zle_dirhistory_back
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[b" dirhistory_zle_dirhistory_back
fi
# Putty:
bindkey "\e\e[D" dirhistory_zle_dirhistory_back
# GNU screen:
......@@ -129,8 +135,56 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back
zle -N dirhistory_zle_dirhistory_future
bindkey "\e[3C" dirhistory_zle_dirhistory_future
bindkey "\e[1;3C" dirhistory_zle_dirhistory_future
bindkey "^[f" dirhistory_zle_dirhistory_future
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[f" dirhistory_zle_dirhistory_future
fi
bindkey "\e\e[C" dirhistory_zle_dirhistory_future
bindkey "\eO3C" dirhistory_zle_dirhistory_future
#
# HIERARCHY Implemented in this section, in case someone wants to split it to another plugin if it clashes bindings
#
# Move up in hierarchy
function dirhistory_up() {
cd .. || return 1
}
# Move down in hierarchy
function dirhistory_down() {
cd "$(find . -mindepth 1 -maxdepth 1 -type d | sort -n | head -n 1)" || return 1
}
# Bind keys to hierarchy navigation
function dirhistory_zle_dirhistory_up() {
zle kill-buffer # Erase current line in buffer
dirhistory_up
zle accept-line
}
function dirhistory_zle_dirhistory_down() {
zle kill-buffer # Erase current line in buffer
dirhistory_down
zle accept-line
}
zle -N dirhistory_zle_dirhistory_up
# xterm in normal mode
bindkey "\e[3A" dirhistory_zle_dirhistory_up
bindkey "\e[1;3A" dirhistory_zle_dirhistory_up
# Mac teminal (alt+up)
#bindkey "^[?" dirhistory_zle_dirhistory_up #dont know it
# Putty:
bindkey "\e\e[A" dirhistory_zle_dirhistory_up
# GNU screen:
bindkey "\eO3A" dirhistory_zle_dirhistory_up
zle -N dirhistory_zle_dirhistory_down
bindkey "\e[3B" dirhistory_zle_dirhistory_down
bindkey "\e[1;3B" dirhistory_zle_dirhistory_down
# Mac teminal (alt+down)
#bindkey "^[?" dirhistory_zle_dirhistory_down #dont know it
bindkey "\e\e[B" dirhistory_zle_dirhistory_down
bindkey "\eO3B" dirhistory_zle_dirhistory_down
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment