From ac8583b02b00e60b34e4087dc377de522577f47e Mon Sep 17 00:00:00 2001 From: ntsd Date: Sun, 7 Jul 2024 21:31:42 +0700 Subject: [PATCH] fix: go path asdf and remove unsued functions --- system/.asdf | 5 +++++ system/.function | 12 +----------- system/.function_network | 22 ---------------------- system/.function_text | 7 ------- test/function.bats | 25 ------------------------- 5 files changed, 6 insertions(+), 65 deletions(-) delete mode 100644 system/.function_text delete mode 100644 test/function.bats diff --git a/system/.asdf b/system/.asdf index 52c077e..1133a6e 100644 --- a/system/.asdf +++ b/system/.asdf @@ -3,3 +3,8 @@ . "$HOME/.asdf/asdf.sh" # Load asdf completions . "$HOME/.asdf/completions/asdf.bash" + +# set bin path and GOPATH for the current Go +export GOPATH=$(asdf where golang)/packages +export GOROOT=$(asdf where golang)/go +export PATH="${PATH}:$(go env GOPATH)/bin" diff --git a/system/.function b/system/.function index 9d07abb..1402879 100644 --- a/system/.function +++ b/system/.function @@ -1,20 +1,10 @@ -# Switch long/short prompt +# Switch to short prompt ps0() { unset PROMPT_COMMAND PS1='$ ' } -ps1() { - source "$DOTFILES_DIR"/system/.prompt -} - -# Get named var (usage: get "VAR_NAME") - -get() { - echo "${!1}" -} - # Add to path prepend-path() { diff --git a/system/.function_network b/system/.function_network index c07f584..1dcbec7 100644 --- a/system/.function_network +++ b/system/.function_network @@ -10,25 +10,3 @@ srv() { open "http://localhost:$PORT" http-server "$DIR" -p "$PORT" } - -# Get IP from hostname - -hostname2ip() { - ping -c 1 "$1" | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' -} - -# Upload file to transfer.sh -# https://github.com/dutchcoders/transfer.sh/ - -transfer() { - tmpfile=$( mktemp -t transferXXX ) - curl --progress-bar --upload-file "$1" https://transfer.sh/$(basename $1) >> $tmpfile; - cat $tmpfile; - rm -f $tmpfile; -} - -# Find real from shortened url - -unshorten() { - curl -sIL $1 | sed -n 's/Location: *//p' -} diff --git a/system/.function_text b/system/.function_text deleted file mode 100644 index 3e645ce..0000000 --- a/system/.function_text +++ /dev/null @@ -1,7 +0,0 @@ -# Show line, optionally show surrounding lines - -line() { - local LINE_NUMBER=$1 - local LINES_AROUND=${2:-0} - sed -n "`expr $LINE_NUMBER - $LINES_AROUND`,`expr $LINE_NUMBER + $LINES_AROUND`p" -} diff --git a/test/function.bats b/test/function.bats deleted file mode 100644 index 492e980..0000000 --- a/test/function.bats +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bats - -load "../system/.function" -load "../system/.function_text" - -FIXTURE=$'foo\nbar\nbaz\nfoo' -FIXTURE_TEXT="foo" - -@test "get" { - ACTUAL=$(get "FIXTURE_TEXT") - EXPECTED="foo" - [ "$ACTUAL" = "$EXPECTED" ] -} - -@test "line" { - ACTUAL=$(get "FIXTURE" | line 2) - EXPECTED="bar" - [ "$ACTUAL" = "$EXPECTED" ] -} - -@test "line + surrounding lines" { - ACTUAL=$(get "FIXTURE" | line 3 1) - EXPECTED=$(echo -e "bar\nbaz\nfoo") - [ "$ACTUAL" = "$EXPECTED" ] -}