Skip to content

Instantly share code, notes, and snippets.

View colstrom's full-sized avatar

Chris Olstrom colstrom

View GitHub Profile
@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-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 / 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.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: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 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-avail.fish
Last active December 9, 2016 18:45
gistpkg-avail.fish: list available gistpkgs from user
function gistpkg-avail --argument username
switch (count $argv)
case 0
echo 'usage: gistpkg-avail <username>'
return 100
case '*'
github-api /users/$username/gists | jq -r '.[] | select(.files | keys[] | test("^gistpkg.zpl$")) | [([.owner.login, .id] | join("/")), .description] | @tsv'
end
end
@colstrom
colstrom / gistpkg-list.fish
Last active December 9, 2016 19:20
gistpkg-list.fish: list installed gistpkgs
function gistpkg-list
set local (gistpkg-config root)/(gistpkg-config origin)
if test (is-a-directory $local) = true
find $local -type d -mindepth 1 -name .git -exec dirname '{}' \; | string replace --all --regex "^$local/" ''
end
end
@colstrom
colstrom / gistpkg.zpl
Last active December 9, 2016 06:45
sonar-lexer.fish: a lexer for fish, written in fish
name = sonar-lexer
author = Chris Olstrom
license = MIT
provides = fish/functions/sonar-lexer
requires
fish/builtin/and
@colstrom
colstrom / gistpkg.zpl
Created December 9, 2016 20:11
user-is-root.fish: checks if the current user is root
name = user-is-root
author = Chris Olstrom
license = MIT
provides = fish/functions/user-is-root
requires
command/id