Intro
This is a collection of awesome one-liners in shells.
List
- Get current BTC price (without demicals) using rate.sx API
curl -s 'rate.sx/1btc?format=qT' | cut -f1 -d\.
- Pull all git repo in the folder, including sub-folders (change
3
to dig deeper)
find . -maxdepth 3 -name .git -type d | rev | cut -c 6- | rev | xargs -I {} git -C {} pull
- Get the internal WSL IP
ip route |awk '/^default/{print $3}'
- Get the Windows host IP from WSL (if
generateHosts
isn’t set toFalse
in/etc/wsl.conf
)
host `hostname` | grep -oP '(\s)\d+(\.\d+){3}' | tail -1 | awk '{ print $NF }' | tr -d '\r'
# Make sure `ghostscript` is installed
gs -dBATCH -dNOPAUSE -sDEVICE=pnggray -r300 -dUseCropBox -sOutputFile=item-%03d.png examples.pdf
- Get inet IP
ip a | grep inet | cut -d '/' -f 1 | tail -n 2
mkdir empty && rsync -r --delete empty/ some-dir && rmdir some-dir
- Get nightly or any selected release file on GitHub (inspired by Bash: Determining latest GitHub release tag and version)
# Get Citra Nightly Download URL
GITHUB_URL=$(curl --silent --location https://api.github.com/repos/citra-emu/citra-nightly/releases/latest | jq --raw-output ".assets[].browser_download_url" | grep --extended-regexp "citra-linux-.*?.tar.xz")
# A more advanced (read: wicked) one
# Download Sophia-Script Selected Release
curl --silent --location https://api.github.com/repos/farag2/Sophia-Script-for-Windows/releases/latest | jq --raw-output ".assets[].browser_download_url" | grep --extended-regexp "SHA256SUM|10.LTSC.2021|11.v" | xargs wget --quiet --input-file
- GitHub Action custom filter
on:
push:
branches: ['main']
# Only run when foo is changed
paths: ['a-path/foo']
jobs:
build-that-can-skip:
runs-on: ubuntu-latest
# Skip build with [ci skip] in last commit
if: "! contains(github.event.head_commit.message, '[ci skip]')"
sensitive-build:
runs-on: ubuntu-latest
# Only run on commits with [build]
if: "contains(toJSON(github.event.head_commit.message), '[build]')"
- Create a full git bundle using repository name:
gbc() {
# Create git bundle using repo name
git bundle create $(basename `git rev-parse --show-toplevel`).bundle --all
}