Skip to content

Instantly share code, notes, and snippets.

View colstrom's full-sized avatar

Chris Olstrom colstrom

View GitHub Profile
@colstrom
colstrom / gistpkg.zpl
Last active December 9, 2016 19:31
github-api.fish: interacts with the GitHub API
name = github-api
author = Chris Olstrom
license = MIT
provides = fish/functions/github-api
requires
fish/builtin/case
@colstrom
colstrom / gistpkg.zpl
Last active December 9, 2016 06:46
https-get.fish: a minimalist HTTPS client in fish
name = https-get
author = Chris Olstrom
license = MIT
provides = fish/functions/https-get
requires
command/cat
@colstrom
colstrom / gistpkg.zpl
Last active December 9, 2016 06:52
lines-before.fish: prints lines that occur before a given pattern
name = lines-before
author = Chris Olstrom
license = MIT
provides = fish/functions/lines-before
requires
command/awk
@colstrom
colstrom / gistpkg.zpl
Last active December 9, 2016 06:53
lines-after.fish: prints lines after a given pattern
name = lines-after
author = Chris Olstrom
license = MIT
provides = fish/functions/lines-after
requires
command/awk
@colstrom
colstrom / gistpkg-config.fish
Last active December 9, 2016 19:51
gistpkg-config.fish: gistpkg configuration
function gistpkg-config --argument key
set --local key (printf "%s" $key | string replace --all --regex '[[:punct:]]' _)
switch "$key"
case list
list root origin fish_functions keyring
case root
if set --query GISTPKG_ROOT
echo $GISTPKG_ROOT
else
@colstrom
colstrom / downcase.fish
Last active December 9, 2016 06:51
downcase.fish: converts strings to lowercase
function downcase
if isatty stdin
switch (count $argv)
case 0
echo 'usage: downcase <string> [string ...]'
return 100
case '*'
list $argv | downcase
end
else
@colstrom
colstrom / gistpkg.zpl
Last active December 9, 2016 06:45
upcase.fish: converts strings to uppercase
name = upcase
author = Chris Olstrom
license = MIT
provides = fish/functions/upcase
requires
command/tr
@colstrom
colstrom / gistpkg-alias.fish
Last active December 9, 2016 19:09
gistpkg-alias.fish: assigns alternate names to gistpkgs
function gistpkg-alias --argument canonical alias
empty "$canonical"
and return 100
empty "$alias"
and return 100
set --local canonical (sanitize-git-remote-url $canonical)
set --local alias (gistpkg-config root)/$alias
@colstrom
colstrom / gistpkg-install.fish
Last active December 9, 2016 19:08
gistpkg-install.fish: installs packages from gists
function gistpkg-install --argument package
set --local package (gistpkg-config root)/(sanitize-git-remote-url $package)
test (is-a-directory (gistpkg-config fish/functions)) = false
and mkdir -p (gistpkg-config fish/functions)
if test (count $package/*.fish) -eq 0
printf "%s contains no .fish files" $package
return 0
end
@colstrom
colstrom / gistpkg-fetch.fish
Last active December 9, 2016 20:38
gistpkg-fetch.fish: fetches a gistpkg from the internets
function gistpkg-fetch --argument remote
switch (count $argv)
case 0
echo 'usage: gistpkg-fetch <remote>'
return 100
case '*'
set local (gistpkg-config root)/(sanitize-git-remote-url $remote)
if directory-in-git $local >/dev/null
set origin (git -C $local remote get-url --push origin)