Merge branch 'master' of github.com:HariSekhon/DevOps-Bash-tools

pull/2/head
Hari Sekhon 4 years ago
commit 4e3fddaf09

@ -160,6 +160,11 @@ ifconfigco(){
#curl ifconfig.co/json
}
ipinfo(){
# returns json without /ip with region, reverse dns hostname, city, region, country, lat/long coordinates, org, postcode, timezone
curl ipinfo.io/ip
}
ipify(){
curl http://api.ipify.org/
echo

@ -1 +1 @@
gem: --no-document
gem: --no-document --no-ri --no-rdoc

@ -28,20 +28,34 @@
default = simple
[alias]
br = branch
co = checkout
ci = commit
p = push
st = status
# Show verbose output about tags, branches or remotes
tags = tag -l
who = config --get user.email
co = checkout
ci = commit
p = push
st = status
br = branch
ba = branch -a
bav = branch -a -vvv
cp = cherry-pick
ls = ls-files
rem = remote -v
remotes = remote -v
tags = tag -l
branches = branch -a
remotes = remote -v
in = log HEAD..FETCH_HEAD
out = log FETCH_HEAD..HEAD
age = for-each-ref --format '%(authordate:iso) %(refname:short)' --sort=-authordate refs/remotes refs/heads
unstage = reset HEAD --
last = log -1 HEAD
# Show files ignored by git:
ign = ls-files -o -i --exclude-standard
ignored = !git clean -ndX | sed -e 's/^Would remove //' | sed 's/^Would skip repository //'
untracked = ls-files --others --exclude-standard
# how to use commands inside git aliases
visual = !gitk
@ -50,14 +64,20 @@
lg = log -p
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
ls = ls-files
# Show files ignored by git:
ign = ls-files -o -i --exclude-standard
# avoid diff-so-fancy so we can create patches
patch = !git --no-pager diff --no-color
#ffm = merge --ff-only
#ffp = pull --ff-only
#fp = fetch --prune
#mp = merge --no-commit --no-ff
#ma = merge --abort
#dno = diff --name-only
#gone = !git branch -vv | grep ': gone'
#gd = !git branch -vv | awk '/: gone/ {print $1}' | xargs --no-run-if-empty -n1 git branch -D
[help]
# autocorrects git commands and executes the inferred command
# dangerous this just autocorrected my git rename to git rebase, lucky it errored out...

@ -469,6 +469,10 @@ function! WriteRun()
" this gets stdout only at the end so things like welcome.go don't get
" the transition effects when run like this
:! eval go run "%:p" `$bash_tools/lib/args_extract.sh "%:p"` 2>&1 | less
" doesn't work, probably due to no first class support so just get file extension
"elseif &filetype == 'tf'
elseif expand('%:e') == 'tf'
:call TerraformPlan()
elseif expand('%:t') == 'Makefile'
:call Make()
elseif expand('%:t') == 'Dockerfile'
@ -494,6 +498,16 @@ function! Make()
:! bash -c 'cd "%:p:h" && make'
endfunction
function! TerraformPlan()
" '%:p:h' is dirname
:! bash -c 'cd "%:p:h" && terraform plan'
endfunction
"function! TerraformApply()
" " '%:p:h' is dirname
" :! bash -c 'cd "%:p:h" && terraform apply'
"endfunction
" ============================================================================ "
" L o c a l C o n f i g S o u r c i n g

@ -0,0 +1,61 @@
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2020-07-24 16:18:10 +0100 (Fri, 24 Jul 2020)
#
# https://github.com/harisekhon/bash-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1090
. "$srcdir/lib/utils.sh"
# shellcheck disable=SC2034,SC2154
usage_description="
Fetches and parses Atlassian's IP ranges API, outputting the CIDR ranges, one per line"
# used by usage() in lib/utils.sh
# shellcheck disable=SC2034
usage_args="[--ipv4 / --ipv6]
--ipv4 Output only IPv4 CIDR ranges
--ipv6 Output only IPv6 CIDR ranges"
help_usage "$@"
for arg; do
case "$arg" in
--ipv4) IPV4_ONLY=1
;;
--ipv6) IPV6_ONLY=1
;;
esac
done
if [ -n "${IPV4_ONLY:-}" ] &&
[ -n "${IPV6_ONLY:-}" ]; then
usage "IPv4 and IPv6 filters are mutually exclusive"
fi
url="https://ip-ranges.atlassian.com/"
curl -sSL "$url" |
#jq -r '.items[] | [.network, .mask_len | tostring ] | join("/")'
jq -r '.items[] | .cidr' |
if [ -n "${IPV4_ONLY:-}" ]; then
grep -v -e '[:alpha:]' -e ':'
elif [ -n "${IPV6_ONLY:-}" ]; then
grep -e '[:alpha:]' -e ':'
else
cat
fi

@ -31,7 +31,7 @@ parallel
python # Mac usually comes with Python, but pip was missing in Semaphore CI
readline
shellcheck
terraform
#terraform # old 0.11 masking newer 0.12 from install_terraform.sh
wget
whois
yq

Loading…
Cancel
Save