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 06:40
is-a-file: sugar for test with string/bool output
name = is-a-file
author = Chris Olstrom
license = MIT
provides = fish/functions/is-a-file
requires
fish/builtin/end
@colstrom
colstrom / gistpkg.zpl
Last active December 9, 2016 06:56
is-a-directory.fish: sugar for test with string/bool output
name = is-a-directory
author = Chris Olstrom
license = MIT
provides = fish/functions/is-a-directory
requires
fish/builtin/end
@colstrom
colstrom / exists.fish
Last active December 9, 2016 06:48
exists.fish: sugar for test with string/bool output
function exists -a target
test -e "$target"
status-to-bool $status
end
@colstrom
colstrom / gistpkg.zpl
Last active December 9, 2016 20:30
list.fish: coerces arguments into lists
name = list
author = Chris Olstrom
license = MIT
provides = fish/functions/list
requires
fish/builtin/case
@colstrom
colstrom / gistpkg.zpl
Last active December 9, 2016 06:46
show-source.fish: pretty-prints function definitions
name = show-source
author = Chris Olstrom
license = MIT
provides = fish/functions/show-source
requires
command/fish_indent
@colstrom
colstrom / gistpkg.zpl
Last active December 9, 2016 19:58
sanitize-git-remote-url.fish: removes clutter from URLs
name = sanitize-git-remote-url
author = Chris Olstrom
license = MIT
provides = fish/functions/sanitize-git-remote-url
requires
fish/builtin/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)
@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-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.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