mirror of
https://github.com/ItsDrike/nixdots
synced 2024-11-10 06:59:41 +00:00
Compare commits
No commits in common. "48eca48562a255a3b2cce17cb0179368058eed95" and "36db61f2552b5b0f10f1f5adda265804f220e536" have entirely different histories.
48eca48562
...
36db61f255
|
@ -3,6 +3,5 @@ _: {
|
||||||
./shared.nix
|
./shared.nix
|
||||||
./desktop.nix
|
./desktop.nix
|
||||||
./wayland.nix
|
./wayland.nix
|
||||||
./scripts
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
|
|
||||||
scriptPkgs = (import ./packages {inherit pkgs;});
|
|
||||||
in {
|
|
||||||
home.packages = with scriptPkgs; [
|
|
||||||
bitcoin
|
|
||||||
cheatsh
|
|
||||||
colors256
|
|
||||||
unix
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
{pkgs, ...}:
|
|
||||||
(pkgs.writeShellApplication {
|
|
||||||
name = "bitcoin";
|
|
||||||
runtimeInputs = with pkgs; [coreutils curl jq];
|
|
||||||
text = ''
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
BTC_DATA=$(curl https://api.coindesk.com/v1/bpi/currentprice.json 2>/dev/null || echo 'ERR')
|
|
||||||
|
|
||||||
if [ "$BTC_DATA" != "ERR" ]; then
|
|
||||||
BTC_PRICE=$(echo "$BTC_DATA" | jq -r ".bpi.USD.rate_float")
|
|
||||||
BTC_PRICE=$(printf "%.0f" "$BTC_PRICE")
|
|
||||||
echo \$"$BTC_PRICE"
|
|
||||||
else
|
|
||||||
echo "N/A"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
})
|
|
|
@ -1,112 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# rm_trailing_slashes(string)
|
|
||||||
#
|
|
||||||
# Prints a string without any trailing slashes.
|
|
||||||
# This is used because cheat.sh doesn't play nicely with multiple slashes in
|
|
||||||
# URLs.
|
|
||||||
rm_trailing_slashes() {
|
|
||||||
string="${1-}"
|
|
||||||
last_char="$(printf "%s" "$string" | tail -c 1)"
|
|
||||||
if [ "$last_char" = "/" ]; then
|
|
||||||
rm_trailing_slashes "${string%?}"
|
|
||||||
else
|
|
||||||
echo "$string"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# pick_category(must_match, query, argument, recurse)
|
|
||||||
#
|
|
||||||
# Pick cheat.sh category.
|
|
||||||
# if must_match is 1, only allow listed options to be picked.
|
|
||||||
# if query is specified, pick sub-category of it, else pick global categories.
|
|
||||||
# if argument is specified, optionally perform must_match check and print it.
|
|
||||||
# if recurse is 1, if the selected option ends with /, run the function again.
|
|
||||||
#
|
|
||||||
# Prints the chosen category
|
|
||||||
pick_category() {
|
|
||||||
must_match="$1"
|
|
||||||
query="$(rm_trailing_slashes "$2")"
|
|
||||||
argument="$3"
|
|
||||||
recurse="$4"
|
|
||||||
|
|
||||||
# Query all possible options
|
|
||||||
if [ -n "$query" ]; then
|
|
||||||
url="cheat.sh/$query/:list"
|
|
||||||
else
|
|
||||||
url="cheat.sh/:list"
|
|
||||||
fi
|
|
||||||
selectable="$(curl -s "$url")"
|
|
||||||
|
|
||||||
# If argument is specified, print it, optionally perform must_match check.
|
|
||||||
if [ -n "$argument" ]; then
|
|
||||||
if [ "$must_match" -ne 1 ] || echo "$selectable" | grep -qe "\b$1\b"; then
|
|
||||||
selected="$argument"
|
|
||||||
else
|
|
||||||
echo "Invalid selection: '$argument'"
|
|
||||||
echo "For all selections, query $url"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Select the option with fzf, optionally allow other matches if must_match isn't set.
|
|
||||||
else
|
|
||||||
if [ "$must_match" -ne 1 ]; then
|
|
||||||
if [ -z "$selectable" ]; then
|
|
||||||
header="No selections found, you can use empty query to show category help, or type a custom query."
|
|
||||||
else
|
|
||||||
header="Use alt-enter to enter non-listed query. You can use empty queries to show category help."
|
|
||||||
fi
|
|
||||||
selected="$(
|
|
||||||
printf "\n%s" "$selectable" |
|
|
||||||
fzf --bind=alt-enter:print-query \
|
|
||||||
--print-query \
|
|
||||||
--prompt="cheat.sh/$query query>" \
|
|
||||||
--header="$header"
|
|
||||||
)"
|
|
||||||
else
|
|
||||||
selected=$(printf "%s" "$selectable" | fzf --prompt="cheat.sh/$query category>")
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Invalid selection: '$selected'"
|
|
||||||
echo "For all selections, query $url"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
selected=$(printf "%s" "$selected" | tail -1)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Replace spaces with '+' (cheat.sh resolves those as spaces)
|
|
||||||
selected="$(echo "$selected" | tr ' ' '+')"
|
|
||||||
|
|
||||||
# Prepend the original query, if we have one
|
|
||||||
# Print the selected category, or subcategory with the category
|
|
||||||
if [ -n "$query" ]; then
|
|
||||||
result="$query/$selected"
|
|
||||||
else
|
|
||||||
result="$selected"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Recurse, if specified and the result ended with /
|
|
||||||
if [ "$recurse" -eq 1 ]; then
|
|
||||||
if [ "$(printf "%s" "$selected" | tail -c 1)" = "/" ]; then
|
|
||||||
result="$(pick_category "$must_match" "$result" "$argument" 1)"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print the result
|
|
||||||
printf "%s" "$result"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Select the cheatsheat category (language/core-util/...)
|
|
||||||
query=$(pick_category 1 "" "${1-}" 0)
|
|
||||||
|
|
||||||
# If the query isn't already complete, select a sub-category
|
|
||||||
if ! echo "$query" | grep -qe ":"; then
|
|
||||||
query="$(pick_category 0 "$query" "${2-}" 1)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Construct the URL from given query and print it
|
|
||||||
url="cheat.sh/$query"
|
|
||||||
echo "$url"
|
|
||||||
|
|
||||||
# Show the output of cheat.sh request
|
|
||||||
curl -s "$url"
|
|
|
@ -1,8 +0,0 @@
|
||||||
{pkgs, ...}:
|
|
||||||
(pkgs.writeShellApplication {
|
|
||||||
name = "cheat.sh";
|
|
||||||
runtimeInputs = with pkgs; [coreutils curl jq gnugrep fzf];
|
|
||||||
text = ''
|
|
||||||
${builtins.readFile ./cheat.sh}
|
|
||||||
'';
|
|
||||||
})
|
|
|
@ -1,101 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# # Print out 256 colors, with each number printed in its corresponding colour
|
|
||||||
#
|
|
||||||
# This file is uploaded on <https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/>
|
|
||||||
# It was originally intended to be used as an alias that curled this URL and piped it into bash, however
|
|
||||||
# this is very unsafe as the owner can change the content of this gist at his convenience, meaning it was
|
|
||||||
# a potential security vulnerability. This is a script version of this alias to avoid this issue.
|
|
||||||
#
|
|
||||||
# The copyright for this file belongs to the original author: Tom Hale, 2016
|
|
||||||
# This file was released under MIT license
|
|
||||||
|
|
||||||
set -eu # Fail on errors or undeclared variables
|
|
||||||
|
|
||||||
printable_colours=256
|
|
||||||
|
|
||||||
# Return a colour that contrasts with the given colour
|
|
||||||
# Bash only does integer division, so keep it integral
|
|
||||||
function contrast_colour {
|
|
||||||
colour="$1"
|
|
||||||
|
|
||||||
if ((colour < 16)); then # Initial 16 ANSI colours
|
|
||||||
((colour == 0)) && printf "15" || printf "0"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Greyscale # rgb_R = rgb_G = rgb_B = (number - 232) * 10 + 8
|
|
||||||
if ((colour > 231)); then # Greyscale ramp
|
|
||||||
((colour < 244)) && printf "15" || printf "0"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# All other colours:
|
|
||||||
# 6x6x6 colour cube = 16 + 36*R + 6*G + B # Where RGB are [0..5]
|
|
||||||
# See http://stackoverflow.com/a/27165165/5353461
|
|
||||||
|
|
||||||
# r=$(( (colour-16) / 36 ))
|
|
||||||
g=$((((colour - 16) % 36) / 6))
|
|
||||||
# b=$(( (colour-16) % 6 ))
|
|
||||||
|
|
||||||
# If luminance is bright, print number in black, white otherwise.
|
|
||||||
# Green contributes 587/1000 to human perceived luminance - ITU R-REC-BT.601
|
|
||||||
((g > 2)) && printf "0" || printf "15"
|
|
||||||
return
|
|
||||||
|
|
||||||
# Uncomment the below for more precise luminance calculations
|
|
||||||
|
|
||||||
# # Calculate percieved brightness
|
|
||||||
# # See https://www.w3.org/TR/AERT#color-contrast
|
|
||||||
# # and http://www.itu.int/rec/R-REC-BT.601
|
|
||||||
# # Luminance is in range 0..5000 as each value is 0..5
|
|
||||||
# luminance=$(( (r * 299) + (g * 587) + (b * 114) ))
|
|
||||||
# (( $luminance > 2500 )) && printf "0" || printf "15"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Print a coloured block with the number of that colour
|
|
||||||
function print_colour {
|
|
||||||
local colour="$1" contrast
|
|
||||||
contrast=$(contrast_colour "$1")
|
|
||||||
printf "\e[48;5;%sm" "$colour" # Start block of colour
|
|
||||||
printf "\e[38;5;%sm%3d" "$contrast" "$colour" # In contrast, print number
|
|
||||||
printf "\e[0m " # Reset colour
|
|
||||||
}
|
|
||||||
|
|
||||||
# Starting at $1, print a run of $2 colours
|
|
||||||
function print_run {
|
|
||||||
local i
|
|
||||||
for ((i = "$1"; i < "$1" + "$2" && i < printable_colours; i++)); do
|
|
||||||
print_colour "$i"
|
|
||||||
done
|
|
||||||
printf " "
|
|
||||||
}
|
|
||||||
|
|
||||||
# Print blocks of colours
|
|
||||||
function print_blocks {
|
|
||||||
local start="$1" i
|
|
||||||
local end="$2" # inclusive
|
|
||||||
local block_cols="$3"
|
|
||||||
local block_rows="$4"
|
|
||||||
local blocks_per_line="$5"
|
|
||||||
local block_length=$((block_cols * block_rows))
|
|
||||||
|
|
||||||
# Print sets of blocks
|
|
||||||
for ((i = start; i <= end; i += (blocks_per_line - 1) * block_length)); do
|
|
||||||
printf "\n" # Space before each set of blocks
|
|
||||||
# For each block row
|
|
||||||
for ((row = 0; row < block_rows; row++)); do
|
|
||||||
# Print block columns for all blocks on the line
|
|
||||||
for ((block = 0; block < blocks_per_line; block++)); do
|
|
||||||
print_run $((i + (block * block_length))) "$block_cols"
|
|
||||||
done
|
|
||||||
((i += block_cols)) # Prepare to print the next row
|
|
||||||
printf "\n"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
print_run 0 16 # The first 16 colours are spread over the whole spectrum
|
|
||||||
printf "\n"
|
|
||||||
print_blocks 16 231 6 6 3 # 6x6x6 colour cube between 16 and 231 inclusive
|
|
||||||
print_blocks 232 255 12 2 1 # Not 50, but 24 Shades of Grey
|
|
|
@ -1,9 +0,0 @@
|
||||||
{pkgs, ...}:
|
|
||||||
(pkgs.writeShellApplication {
|
|
||||||
name = "colors-256";
|
|
||||||
runtimeInputs = with pkgs; [coreutils];
|
|
||||||
text = ''
|
|
||||||
${builtins.readFile ./colors-256.sh}
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
packages = {
|
|
||||||
bitcoin = pkgs.callPackage ./bitcoin.nix {};
|
|
||||||
cheatsh = pkgs.callPackage ./cheatsh {};
|
|
||||||
colors256 = pkgs.callPackage ./colors256 {};
|
|
||||||
unix = pkgs.callPackage ./unix {};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
packages
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
{pkgs, ...}:
|
|
||||||
(pkgs.writeShellApplication {
|
|
||||||
name = "unix";
|
|
||||||
runtimeInputs = with pkgs; [coreutils];
|
|
||||||
text = ''
|
|
||||||
${builtins.readFile ./unix.sh}
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#original artwork by http://www.sanderfocus.nl/#/portfolio/tech-heroes
|
|
||||||
#converted to shell by #nixers @ irc.unix.chat
|
|
||||||
|
|
||||||
cat <<'eof'
|
|
||||||
[38;5;255m,_ ,_==▄▂[0m
|
|
||||||
[38;5;255m, ▂▃▄▄▅▅[48;5;240m▅[48;5;20m▂[48;5;240m▅¾[0m. [38;5;199m/ [38;5;20m/[0m
|
|
||||||
[38;5;255m[48;5;20m▄[0m[38;5;255m[48;5;199m▆[38;5;16m[48;5;255m<´ [38;5;32m"[38;5;34m»[38;5;255m▓▓[48;5;32m▓[48;5;240m%[0m\ [38;5;199m/ [38;5;20m/ [38;5;45m/ [38;5;118m/[0m
|
|
||||||
[38;5;255m,[38;5;255m[48;5;240m▅[38;5;16m[48;5;255m7" [38;5;160m´[38;5;34m>[38;5;255m[48;5;39m▓▓[38;5;199m[48;5;255m▓[0m[38;5;255m% [38;5;20m/ [38;5;118m/ [38;5;199m> [38;5;118m/ [38;5;199m>[38;5;255m/[38;5;45m%[0m
|
|
||||||
[38;5;255m▐[48;5;240m[38;5;255m¶[48;5;240m[38;5;255m▓[48;5;255m [38;5;196m,[38;5;34m»[48;5;201m[38;5;255m▓▓[0m[38;5;255m¾´[0m [38;5;199m/[38;5;255m> %[38;5;199m/[38;5;118m%[38;5;255m/[38;5;199m/ [38;5;45m/ [38;5;199m/[0m
|
|
||||||
[38;5;255m[48;5;240m▓[48;5;255m[38;5;16m▃[48;5;16m[38;5;255m▅▅[38;5;16m[48;5;255m▅▃,,[38;5;32m▄[38;5;16m▅[38;5;255m[48;5;16m▅▅[38;5;255m[48;5;20mÆ[0m[38;5;255m\[0m[38;5;20m/[38;5;118m/[38;5;255m /[38;5;118m/[38;5;199m/[38;5;255m>[38;5;45m// [38;5;255m/[38;5;118m>[38;5;199m/ [38;5;20m/[0m
|
|
||||||
[48;5;20m[38;5;255mV[48;5;255m[38;5;16m║[48;5;20m[38;5;255m«[0m[38;5;255m¼.;[48;5;240m[38;5;255m→[48;5;255m[38;5;16m ║[0m[38;5;255m<«.,[48;5;25m[38;5;255m`[48;5;240m=[0m[38;5;20m/[38;5;199m/ [38;5;255m/>[38;5;45m/[38;5;118m/[38;5;255m%/[38;5;199m% / [38;5;20m/[0m
|
|
||||||
[38;5;20m//[48;5;255m[38;5;16m╠<´ -²,)[48;5;16m[38;5;255m(▓[48;5;255m[38;5;16m~"-[38;5;199m╝/[0m[38;5;255m¾[0m[38;5;199m/ [38;5;118m%[38;5;255m/[38;5;118m>[38;5;45m/ [38;5;118m/[38;5;199m>[0m
|
|
||||||
[38;5;20m/ / [38;5;118m/ [48;5;20m[38;5;255m▐[48;5;240m[38;5;16m%[48;5;255m -./▄▃▄[48;5;16m[38;5;255m▅[48;5;255m[38;5;16m▐[48;5;255m[38;5;16m, [38;5;199m/[48;5;199m[38;5;255m7[0m[38;5;20m/[38;5;199m/[38;5;255m;/[38;5;199m/[38;5;118m% [38;5;20m/ /[0m
|
|
||||||
[38;5;20m/ [38;5;199m/[38;5;255m/[38;5;45m/[38;5;118m/[38;5;255m[48;5;240m`[48;5;20m[38;5;255m▌[48;5;20m[38;5;255m▐[48;5;255m[38;5;16m %z[0m[38;5;255mWv xX[48;5;20m[38;5;255m▓[48;5;34m[38;5;255m▇[48;5;199m[38;255m▌[0m[38;5;20m/[38;5;199m/[38;5;255m&;[38;5;20m% [38;5;199m/ [38;5;20m/[0m
|
|
||||||
[38;5;20m/ / [38;5;255m/ [38;5;118m%[38;5;199m/[38;5;255m/%/[48;5;240m[38;5;255m¾[48;5;255m[38;5;16m½´[38;5;255m[48;5;16m▌[0m[38;5;246m▃▄[38;5;255m▄▄[38;5;246m▄▃▃[0m[48;5;16m[38;5;255m▐[38;5;255m[48;5;199m¶[48;5;20m[38;5;255m\[0m[38;5;20m/[0m[48;5;255m[38;5;240m&[0m [38;5;20m/[0m
|
|
||||||
[38;5;199m<[38;5;118m/ [38;5;45m/[38;5;255m</[38;5;118m%[38;5;255m/[38;5;45m/[38;5;255m`[48;5;16m▓[48;5;255m[38;5;16m![48;5;240m[38;5;255m%[48;5;16m[38;5;255m▓[0m[38;5;255m%[48;5;240m[38;5;255m╣[48;5;240m[38;5;255;╣[0m[38;5;255mW[0m[38;5;250mY<Y)[48;5;255m[38;5;16my&[0m[38;5;255m/`[48;5;240m\[0m
|
|
||||||
[38;5;20m/ [38;5;199m/ [38;5;199m%[38;5;255m/%[38;5;118m/[38;5;45m/[38;5;255m<[38;5;118m/[38;5;199m%[38;5;45m/[38;5;20m/[48;5;240m[38;5;255m\[38;5;16m[48;5;255mi7; ╠N[0m[38;5;246m>[38;5;255m)VY>[48;5;240m[38;5;255m7[0m[38;5;255m; [38;5;255m[48;5;240m\[0m[38;5;255m_[0m [38;5;255mUNIX IS VERY SIMPLE [38;5;45mIT JUST NEEDS A[0m
|
|
||||||
[38;5;20m/ [38;5;255m/[38;5;118m<[38;5;255m/ [38;5;45m/[38;5;255m/<[38;5;199m/[38;5;20m/[38;5;199m/[38;5;20m<[38;5;255m_/%\[38;5;255m[48;5;16m▓[48;5;255m[38;5;16m V[0m[38;5;255m%[48;5;255m[38;5;16mW[0m[38;5;255m%£)XY[0m [38;5;240m_/%[38;5;255m‾\_,[0m [38;5;45mGENIUS TO UNDERSTAND ITS SIMPLICITY[38;5;255m[0m
|
|
||||||
[38;5;199m/ [38;5;255m/ [38;5;199m/[38;5;255m/[38;5;118m%[38;5;199m/[48;5;240m[38;5;255m_,=-[48;5;20m-^[0m[38;5;255m/%/%%[48;5;255m[38;5;16m\¾%[0m[38;5;255m¶[0m[48;5;255m[38;5;16m%[0m[38;5;255m%}[0m [38;5;240m/%%%[38;5;20m%%[38;5;240m%;\,[0m
|
|
||||||
[38;5;45m%[38;5;20m/[38;5;199m< [38;5;20m/[48;5;20m[38;5;255m_/[48;5;240m [0m[38;5;255m%%%[38;5;240m%%[38;5;20m;[38;5;255mX[38;5;240m%[38;5;20m%[38;5;255m\%[38;5;240m%;, _/%%%;[38;5;20m,[38;5;240m \[0m
|
|
||||||
[38;5;118m/ [38;5;20m/ [38;5;240m%[38;5;20m%%%%[38;5;240m%;, [38;5;255m\[38;5;240m%[38;5;20m%[38;5;255ml[38;5;240m%%;// _/[38;5;20m%;,[0m [38;5;234mdmr[0m
|
|
||||||
[38;5;20m/ [38;5;240m%[38;5;20m%%;,[0m [38;5;255m<[38;5;20m;[38;5;240m\-=-/ /[0m
|
|
||||||
[38;5;20m;,[0m [38;5;240ml[0m
|
|
||||||
eof
|
|
|
@ -1,6 +1,6 @@
|
||||||
(defwidget bitcoin_module []
|
(defwidget bitcoin_module []
|
||||||
(eventbox
|
(eventbox
|
||||||
:onclick "bitcoin | xargs -I{} ${EWW_CMD} update bitcoin={}"
|
:onclick "~/.local/bin/scripts/cli/bitcoin | xargs -I_ ${EWW_CMD} update bitcoin=_"
|
||||||
:class "module bitcoin"
|
:class "module bitcoin"
|
||||||
|
|
||||||
(box
|
(box
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
(defpoll bitcoin
|
(defpoll bitcoin
|
||||||
:interval "5m"
|
:interval "5m"
|
||||||
:initial "$N/A"
|
:initial "$N/A"
|
||||||
`bitcoin`)
|
`~/.local/bin/scripts/cli/bitcoin`)
|
||||||
|
|
||||||
; TODO: Figure out how to store this one-time
|
; TODO: Figure out how to store this one-time
|
||||||
(defpoll kernel
|
(defpoll kernel
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkIf;
|
inherit (lib) mkIf;
|
||||||
|
|
||||||
scriptPkgs = (import ../../../../packages/cli/scripts/packages {inherit pkgs;});
|
|
||||||
|
|
||||||
cfg = osConfig.myOptions.home-manager.programs.bars.eww;
|
cfg = osConfig.myOptions.home-manager.programs.bars.eww;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -23,7 +21,6 @@ in {
|
||||||
python3
|
python3
|
||||||
bash
|
bash
|
||||||
coreutils
|
coreutils
|
||||||
findutils
|
|
||||||
gnugrep
|
gnugrep
|
||||||
gawk
|
gawk
|
||||||
netcat-openbsd
|
netcat-openbsd
|
||||||
|
@ -39,7 +36,6 @@ in {
|
||||||
wireplumber
|
wireplumber
|
||||||
pulseaudio
|
pulseaudio
|
||||||
hyprland
|
hyprland
|
||||||
scriptPkgs.bitcoin
|
|
||||||
];
|
];
|
||||||
in {
|
in {
|
||||||
Unit = {
|
Unit = {
|
||||||
|
@ -70,7 +66,7 @@ in {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Open bar0 eww (ElKowar's Wacky Widgets) window";
|
Description = "Open bar0 eww (ElKowar's Wacky Widgets) window";
|
||||||
After = [ "eww.service" ];
|
After = [ "eww.service" ];
|
||||||
PartOf = [ "graphical-session.target" "eww.service" ];
|
PartOf = [ "graphical-session.target" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
|
|
||||||
scriptPkgs = (import ./bin {inherit pkgs;});
|
|
||||||
in {
|
|
||||||
programs.git = {
|
programs.git = {
|
||||||
aliases = {
|
aliases = {
|
||||||
quickclone = "clone --single-branch --depth=1";
|
quickclone = "clone --single-branch --depth=1";
|
||||||
|
@ -54,7 +48,7 @@ in {
|
||||||
bD = "branch --delete --force";
|
bD = "branch --delete --force";
|
||||||
bm = "branch --move";
|
bm = "branch --move";
|
||||||
bM = "branch --move --force";
|
bM = "branch --move --force";
|
||||||
bb = "!${scriptPkgs.better-git-branch}/bin/better-git-branch";
|
bb = "!~/.local/bin/scripts/cli/better-git-branch";
|
||||||
|
|
||||||
r = "rebase";
|
r = "rebase";
|
||||||
ri = "rebase -i";
|
ri = "rebase -i";
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# Source: https://gist.github.com/schacon/e9e743dee2e92db9a464619b99e94eff
|
|
||||||
|
|
||||||
# Colors
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
NO_COLOR='\033[0m'
|
|
||||||
BLUE='\033[0;34m'
|
|
||||||
YELLOW='\033[0;33m'
|
|
||||||
NO_COLOR='\033[0m'
|
|
||||||
|
|
||||||
width1=5
|
|
||||||
width2=6
|
|
||||||
width3=30
|
|
||||||
width4=20
|
|
||||||
width5=20
|
|
||||||
|
|
||||||
# Function to count commits
|
|
||||||
count_commits() {
|
|
||||||
local branch="$1"
|
|
||||||
local base_branch="$2"
|
|
||||||
local ahead_behind
|
|
||||||
|
|
||||||
ahead_behind=$(git rev-list --left-right --count "$base_branch"..."$branch")
|
|
||||||
echo "$ahead_behind"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Main script
|
|
||||||
main_branch=$(git rev-parse HEAD)
|
|
||||||
|
|
||||||
printf "${GREEN}%-${width1}s ${RED}%-${width2}s ${BLUE}%-${width3}s ${YELLOW}%-${width4}s ${NO_COLOR}%-${width5}s\n" "Ahead" "Behind" "Branch" "Last Commit" " "
|
|
||||||
|
|
||||||
# Separator line for clarity
|
|
||||||
printf "${GREEN}%-${width1}s ${RED}%-${width2}s ${BLUE}%-${width3}s ${YELLOW}%-${width4}s ${NO_COLOR}%-${width5}s\n" "-----" "------" "------------------------------" "-------------------" " "
|
|
||||||
|
|
||||||
format_string="%(objectname:short)@%(refname:short)@%(committerdate:relative)"
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
for branchdata in $(git for-each-ref --sort=-authordate --format="$format_string" refs/heads/ --no-merged); do
|
|
||||||
sha=$(echo "$branchdata" | cut -d '@' -f1)
|
|
||||||
branch=$(echo "$branchdata" | cut -d '@' -f2)
|
|
||||||
time=$(echo "$branchdata" | cut -d '@' -f3)
|
|
||||||
if [ "$branch" != "$main_branch" ]; then
|
|
||||||
# Get branch description
|
|
||||||
description=$(git config branch."$branch".description)
|
|
||||||
|
|
||||||
# Count commits ahead and behind
|
|
||||||
ahead_behind=$(count_commits "$sha" "$main_branch")
|
|
||||||
ahead=$(echo "$ahead_behind" | cut -f2)
|
|
||||||
behind=$(echo "$ahead_behind" | cut -f1)
|
|
||||||
|
|
||||||
# Display branch info
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
printf "${GREEN}%-${width1}s ${RED}%-${width2}s ${BLUE}%-${width3}s ${YELLOW}%-${width4}s ${NO_COLOR}%-${width5}s\n" $ahead $behind $branch "$time" "$description"
|
|
||||||
fi
|
|
||||||
done
|
|
|
@ -1,4 +0,0 @@
|
||||||
{pkgs, ...}:
|
|
||||||
pkgs.writeShellScriptBin "better-git-branch" ''
|
|
||||||
${builtins.readFile ./better-git-branch.sh}
|
|
||||||
''
|
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
packages = {
|
|
||||||
better-git-branch = pkgs.callPackage ./better-git-branch {};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
packages
|
|
Loading…
Reference in a new issue