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 #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. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
# Description # Description
# ----------- # -----------
# #
# Completion script for Coffee.js v0.6.11 (http://coffeejs.org) # Completion script for Coffee.js v0.6.11 (https://coffeescript.org)
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Authors # 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 # easier alias to use the plugin
# 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
alias ccat='colorize_via_pygmentize' alias ccat='colorize_via_pygmentize'
alias cless='colorize_via_pygmentize_less'
colorize_via_pygmentize() { colorize_via_pygmentize() {
if [ ! -x "$(which pygmentize)" ]; then if ! (( $+commands[pygmentize] )); then
echo "package \'Pygments\' is not installed!" echo "package 'Pygments' is not installed!"
return -1 return 1
fi fi
# pygmentize stdin if no arguments passed
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
pygmentize -g $@ pygmentize -g
return $?
fi fi
for FNAME in $@ # guess lexer from file extension, or
# guess it from file contents if unsuccessful
local FNAME lexer
for FNAME in "$@"
do do
filename=$(basename "$FNAME") lexer=$(pygmentize -N "$FNAME")
lexer=`pygmentize -N \"$filename\"` if [[ $lexer != text ]]; then
if [ "Z$lexer" != "Ztext" ]; then pygmentize -l "$lexer" "$FNAME"
pygmentize -l $lexer "$FNAME"
else else
pygmentize -g "$FNAME" pygmentize -g "$FNAME"
fi fi
done 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 # 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 # this is installed in Ubuntu
[[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found [[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found
...@@ -31,3 +31,10 @@ if type brew &> /dev/null; then ...@@ -31,3 +31,10 @@ if type brew &> /dev/null; then
eval "$(brew command-not-found-init)"; eval "$(brew command-not-found-init)";
fi fi
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
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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