1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

10 Commits

Author SHA1 Message Date
1da55a29c4 aliases: git: Add -v to git commit
Shows full patch in the commit message editor. Very handy, yes

Signed-off-by: Joe Groocock <jgroocock@cloudflare.com>
2024-04-11 14:54:32 +00:00
2cc93a1649 scripts/otp: Refactor & ensure notifications are dismissed
Modernise the script and make it more sane.
Ensure lingering notifications are removed when the script exits to
prevent collecting many notifications if the script is called in a loop.

Signed-off-by: Joe Groocock <me@frebib.net>
2023-03-29 12:43:29 +00:00
787008fdb7 polybar: Normalise some module configs
Remove host-specific options from the wifi/ethernet modules, because
polybar is able to work it out for itself.

Signed-off-by: Joe Groocock <me@frebib.net>
2023-03-29 12:32:50 +00:00
79dc6a7389 aliases: git: Strip a/b prefix from paths by default
This makes double-click copy/paste much easier

Signed-off-by: Joe Groocock <me@frebib.net>
2023-02-28 09:54:31 +00:00
fede67c22a aliases: git: Add missing gfp/gt aliases
Signed-off-by: Joe Groocock <me@frebib.net>
2023-02-28 09:54:31 +00:00
b87cf96ff2 i3: replagce 'gist' with 'gh gist'
The old ruby 'gist' script uses a deprecated API and is replaced by the
first-party 'gh' tool instead.

Signed-off-by: Joe Groocock <me@frebib.net>
2023-01-01 14:59:37 +00:00
4143aa4e48 aliases: dpsa uses org.opencontainers.image labels
org.label-schema was deprecated in favour of the opencontainers labels,
which apparently a bunch of images actually use (unlike the label-schema
labels).

Signed-off-by: Joe Groocock <me@frebib.net>
2022-12-21 16:35:07 +00:00
73131b086f aliases: git: gfrb/gfrbi defaults to defbranch
Much like how `git pull` will default to the remote tracking branch if
called with no arguments, gfrb and gfrbi will fetch and rebase from the
"default" branch according to git defbranch.

Signed-off-by: Joe Groocock <me@frebib.net>
2022-10-30 13:43:18 +00:00
a7af23bfbb git: Allow git cleanmerged/defbranch to take args
These aliases now make zero assumptions about either branch or origin
names. They default to origin, and the primary branch is determined from
the refs/remotes/$remote/HEAD symbolic-ref, which will be pulled from
the remote if it's not known locally.
With these it is now possible to act on any remote/branch combination:

    # Get default branch for 'upstream' remote
    $ git defbranch upstream

    # Delete branches merged into the default branch of the 'upstream'
    # remote
    $ git cleanmerged upstream

    # Delete branches merged into the upstream/foo branch
    $ git cleanmerged upstream foo

Signed-off-by: Joe Groocock <me@frebib.net>
2022-10-27 09:16:57 +00:00
56fd0ad602 git: Add mv/reflog/clean-merged aliases
Signed-off-by: Joe Groocock <me@frebib.net>
2022-10-27 09:16:51 +00:00
5 changed files with 90 additions and 65 deletions

52
aliases
View File

@ -110,25 +110,38 @@ alias ginit='git init'
alias gignore='$EDITOR .gitignore'
alias gitc='$EDITOR $XDG_CONFIG_HOME/git/config'
alias ggignore='$EDITOR $XDG_CONFIG_HOME/git/gitignore'
alias gcl="git clone --recursive"
alias gco="git checkout"
alias gcom="git checkout \"\$(git defbranch)\""
alias gsw="git switch"
alias gswm="git switch \"\$(git defbranch)\""
alias gbr="git branch"
alias gtg="git tag"
alias gbl="git blame"
alias gt="git tag"
alias gst="git status"
alias grl="git reflog"
alias gfp="git format-patch"
alias gcl="git clone --recursive"
alias ga="git add"
alias gap="git add -p"
alias gau="git add -u"
alias gaN="git add -N"
alias gaa="ga -A"
alias grm="git rm"
alias gc="git commit -s"
alias gcm="git commit -s -em"
alias gca="git commit -s --amend --date=\"\$(date -R)\""
alias gcn="git commit -s --no-edit"
alias gcan="gca -s --no-edit"
alias gcam="gca -s -m"
alias gst="git status"
alias gmv="git mv"
alias gc="git commit -sv"
alias gcm="git commit -sv -em"
alias gca="git commit -sv --amend --date=\"\$(date -R)\""
alias gcn="git commit -sv --no-edit"
alias gcan="gca --no-edit"
alias gcam="gca -m"
alias gm="git merge"
alias gma="git merge --abort"
alias gmc="git merge --continue"
alias grb="git rebase"
alias grbi="grb -i"
@ -136,9 +149,9 @@ alias grba="grb --abort"
alias grbc="grb --continue"
alias grbsk="grb --skip"
alias grbsh="grb --show-current"
alias grbom="git rebase \"origin/\$(git defbranch)\""
gfrb() { remote="${1%/*}"; git fetch "$remote" && git rebase "$@"; }
gfrbi() { remote="${1%/*}"; git fetch "$remote" && git rebase -i "$@"; }
alias grbom="git rebase \"origin/\$(git defbranch origin)\""
gfrb() { ref="${1:-origin/$(git defbranch origin)}"; remote="${ref%%/*}"; git fetch "$remote" && git rebase "$ref" "${@:2}"; }
gfrbi() { ref="${1:-origin/$(git defbranch origin)}"; remote="${ref%%/*}"; git fetch "$remote" && git rebase -i "$ref" "${@:2}"; }
alias gam="git am"
alias gama="git am --abort"
@ -164,10 +177,10 @@ alias gpsuom="git push --set-upstream origin \"\$(git defbranch)\""
alias gpall="git remote | xargs -L1 git push"
alias gl="git pull --rebase"
alias glp="gl && gp"
alias gd="git diff --patch-with-stat"
alias gdni="gd --no-index"
alias gds="gd --staged"
alias gsh="git show --format=fuller --patch-with-stat"
alias gd="git diff --patch-with-stat --no-prefix"
alias gdni="gd --no-index --no-prefix"
alias gds="gd --staged --no-prefix"
alias gsh="git show --format=fuller --patch-with-stat --no-prefix"
alias glg="git log --color --format=fuller --stat --no-merges --graph"
alias glgp="git log --color --format=fuller --patch-with-stat --no-merges --graph"
alias glog="git log --color --oneline --decorate --graph"
@ -175,10 +188,9 @@ alias glog="git log --color --oneline --decorate --graph"
alias grst="git reset"
alias gundo="git reset --keep @~1"
alias gclean="git clean"
alias gbr="git branch"
alias gclm="git cleanmerged"
alias gbrl="git for-each-ref --sort=committerdate refs/heads/ --format=\"%(refname:short)\" | fzf -x --ansi --multi --preview-window=right:70% --preview=\"git log --format=fuller --stat --color=always {} | head -n\$((\$(tput lines)*10))\""
alias gtg="git tag"
alias gbl="git blame"
alias gr="git remote"
alias gra="gr add"
alias grr="gr rm"
@ -189,12 +201,12 @@ alias gsta='git stash'
alias gstd='gsta drop'
alias gstl='gsta list --stat --color'
alias gstp='gsta pop'
alias gstv="gsta show -p stash@{0}"
alias gstv="gsta show --patch-with-stat stash@{0}"
# Docker aliases
alias d=docker
alias dps="docker ps --format='table {{.ID}}\t{{.Image}}\t{{.Label \"org.label-schema.version\"}}\t{{.Networks}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}' | sed '1s/version/VERSION/'"
alias dpsa="docker ps -a --format='table {{.ID}}\t{{.Image}}\t{{.Label \"org.label-schema.version\"}}\t{{.Networks}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}' | sed '1s/version/VERSION/'"
alias dpsa="docker ps -a --format='table {{.ID}}\t{{.Image}}\t{{.Label \"org.opencontainers.image.version\"}}\t{{.Networks}}\t{{.RunningFor}}\t{{.Status}}\t{{.Names}}' | sed '1s/version/VERSION/'"
alias dnets="docker network ls -q | xargs docker inspect | jq '.[] | select(.Name != \"host\" and .Name != \"none\") | [.] | map(.Name + \"\t\" + (.IPAM.Config | map(.Subnet) | join(\"\t\")))[]' -r | sort -V -k2,3 | column -t"
daddrs() { docker inspect "${1:-bridge}" | jq '.[0].Containers | map(.Name + "\t" + .IPv4Address + "\t" + .IPv6Address)[]' -r | sort -V -k2,3 | column -t; }
alias din='docker inspect'

View File

@ -37,7 +37,23 @@
count = !echo $(pwd) && git rev-list HEAD --count
unpushed = !git log --oneline @{u}..HEAD
leaders = !git shortlog -s -n --all --no-merges
defbranch = !git symbolic-ref refs/remotes/origin/HEAD | sed \"s@^refs/remotes/origin/@@\"
defbranch = "!defbranch() { \
r=\"${1:-origin}\"; \
{ \
git symbolic-ref \"refs/remotes/$r/HEAD\" || { \
git remote set-head \"$r\" -a >&2 && \
git symbolic-ref \"refs/remotes/$r/HEAD\"; \
}; \
} 2>/dev/null \
| sed \"s@^refs/remotes/$r/@@\"; \
}; defbranch"
cleanmerged = "!cleanmerged() { \
r=\"${1:-origin}\"; \
b=\"${2:-$(git defbranch \"$r\")}\"; \
git branch --merged \"$r/$b\" | \
grep -ve \"^\\\\*\" -e \"^. $b$\" | \
xargs -r git branch -d; \
}; cleanmerged"
[advice]
statusHints = false
pushUpdateRejected = false

View File

@ -150,7 +150,7 @@ bindsym $mod+Shift+x exec systemd-run-i3 -n i3-sensible-terminal --cl
bindsym $mod+$alt+space exec systemd-run-i3 -s background -n ~/.config/i3/cycleaudio.py
bindsym $mod+numbersign exec systemd-run-i3 -n i3-sensible-terminal --hold -e sh -c 'xclip -o | gpg --decrypt 2>&1'
bindsym $mod+r exec bash -c 'pwgen -snc 32 1 | tee >(xargs notify-send Generated\ password\:) | xclip -i -r'
bindsym $mod+g exec systemd-run-i3 -n notify-send -c transfer "$(gist -PRpc)"
bindsym $mod+g exec systemd-run-i3 -n bash -xc 'xclip -o | gh gist create -d Paste - 2>&1 | grep -vE "^[-✓] Creat(ing|ed) gist" | tee >(xclip -i >&2 >/dev/null) | xargs -r notify-send -c transfer'
bindsym --release $mod+i exec systemd-run-i3 -s background -n sh -c 'sleep 0.5 && xdotool getactivewindow type --delay 10 -- "$(xclip -o -selection clipboard)"'
bindsym $mod+z exec otp | rofi -dmenu -p otp | xargs otp

View File

@ -44,8 +44,7 @@ line-colour = #f00
modules-left = i3
modules-center =
# modules-right = volume updates weather xkeyboard wlan gateway eth memory cpu xbacklight battery cputemp gputemp date
modules-right = volume updates weather wlan eth memory cpu xbacklight battery cputemp gputemp date
modules-right = volume updates weather wifi ethernet memory cpu cputemp backlight battery date
tray-position = right
tray-detached = false
@ -132,8 +131,9 @@ label-urgent-foreground = ${colours.urgent}
label-urgent-padding = ${self.label-focused-padding}
[module/xbacklight]
type = internal/xbacklight
[module/backlight]
type = internal/backlight
card = intel_backlight
label = %percentage%
format = <label>
@ -141,12 +141,6 @@ format-prefix = " "
format-prefix-foreground = ${colours.icon}
[module/backlight-acpi]
inherit = module/xbacklight
type = internal/backlight
card = intel_backlight
[module/cpu]
type = internal/cpu
interval = 2
@ -164,9 +158,9 @@ format-prefix-foreground = ${colours.icon}
label = %percentage_used%%
[module/wlan]
[module/wifi]
type = internal/network
interface = wlp1s0
interface-type = wireless
interval = 3.0
format-connected = <ramp-signal> <label-connected>
@ -185,9 +179,9 @@ ramp-signal-2 = 
ramp-signal-foreground = ${colours.icon}
[module/eth]
[module/ethernet]
type = internal/network
interface = lan
interface-type = wired
interval = 10.0
label-connected = %local_ip% & %local_ip6%

View File

@ -1,42 +1,45 @@
#!/usr/bin/env bash
set -euo pipefail
NOTIF_PERSIST=30000
NOTIF_INFORM=5000
stdout=
caller=
notif=
while getopts "on:" o; do
case "${o}" in
o)
stdout=1;;
n)
caller="${OPTARG}"
;;
*)
exec ykman oath accounts list
;;
esac
case "${o}" in
o)
stdout=1;;
n)
caller="${OPTARG}"
;;
*)
exec ykman oath accounts list
;;
esac
done
shift $((OPTIND-1))
if [ $# -lt 1 ]; then
exec ykman oath accounts list
exec ykman oath accounts list
fi
if [ -n "$caller" ]; then
notif="$(notify-send -p "Touch your Yubikey" "$caller is requesting otp for $1")"
notif="$(notify-send -p -t $NOTIF_PERSIST "Touch your Yubikey" "$caller is requesting otp for $1")"
trap 'notify-send -r $notif -t 1 "Touch your Yubikey" "$caller is requesting otp for $1"' EXIT
fi
ykman oath accounts code -s "$1" 2>&1 |
while read -r x; do
if grep -Pqw '[0-9]{6}' <<< "$x"; then
if [ -z "$stdout" ]; then
echo "$x" | tee >(xclip -i)
xdotool type "$x"
else
echo "$x"
fi
fi
if [ -z "$stdout" ]; then
notify-send "$x";
fi
done
if [ -n "$notif" ]; then
notify-send -r "$notif" -t 1000 "Touch your Yubikey" "otp generated for $caller"
code=$(ykman oath accounts code -s "$1")
if [ -z "$stdout" ]; then
echo "$code" | tee >(xclip -i)
xdotool type "$code"
else
echo "$code"
fi
if [ -n "$code" ] && [ -n "$notif" ]; then
trap : EXIT
notify-send -r "$notif" -t $NOTIF_INFORM "Yubikey Touched" "otp generated for $caller"
fi