1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2025-09-17 18:49:08 +00:00

Compare commits

..

3 Commits

Author SHA1 Message Date
Joel Kuzmarski
36e24eeb08 git-hub-shorten-url: Slug support 2014-02-20 13:03:18 -06:00
Sorin Ionescu
af003d83c5 [Fix #535] Set Pacman frontend to 'pacman' when none set 2014-01-21 22:12:09 -05:00
Kaushal M
839f4a7b83 Fix setting the 'pac' alias 2014-01-13 21:35:38 -05:00
6 changed files with 22 additions and 26 deletions

View File

@@ -22,11 +22,7 @@ Aliases
-------
- `d` prints the contents of the directory stack.
Functions
---------
- `command_not_found_handler` changes the directory to the **n** previous one.
- `1 ... 9` changes the directory to the **n** previous one.
Authors
-------

View File

@@ -1,13 +0,0 @@
#
# Changes the directory to the n previous one.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if [[ "$1" == [[:digit:]]## ]]; then
builtin cd "+$1"
else
return 127
fi

View File

@@ -27,4 +27,5 @@ unsetopt CLOBBER # Do not overwrite existing files with > and >>.
#
alias d='dirs -v'
for index ({1..9}) alias "$index"="cd +${index}"; unset index

View File

@@ -5,8 +5,11 @@
# Completes git-hub-shorten-url.
#
# Authors:
# Joel Kuzmarski <leoj3n@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
_arguments '1:url:' && return 0
_arguments \
'1:url:' \
'2:slug:' && return 0

View File

@@ -2,21 +2,29 @@
# Shortens GitHub URLs.
#
# Authors:
# Joel Kuzmarski <leoj3n@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
local url="$1"
if [[ "$url" == '-' ]]; then
read url <&0
fi
if [[ -z "$url" ]]; then
print "usage: $0 [ url | - ]" >&2
print "usage: $0 [ url | - ] [slug]" >&2
return 1
elif [[ "$url" == '-' ]]; then
read url <&0
elif [[ "$url" != *github.com* ]]; then
url="https://github.com/$url"
fi
if (( $+commands[curl] )); then
curl -s -i 'http://git.io' -F "url=$url" | grep 'Location:' | sed 's/Location: //'
local result="$(curl -s -i 'http://git.io' -F "url=$url" -F "code=$2")"
if [[ $result == *Unprocessable* ]]; then
print "$0: the slug '$2' is already taken!" >&2
else
print $result | grep 'Location:' | sed 's/Location: //'
fi
else
print "$0: command not found: curl" >&2
fi

View File

@@ -28,6 +28,7 @@ if (( $+commands[$_pacman_frontend] )); then
source "${0:h}/${_pacman_frontend}.zsh"
fi
else
_pacman_frontend='pacman'
_pacman_sudo='sudo '
fi
@@ -36,7 +37,7 @@ fi
#
# Pacman.
alias pac= "${_pacman_frontend}"
alias pac="${_pacman_frontend}"
# Installs packages from repositories.
alias paci="${_pacman_sudo}${_pacman_frontend} --sync"