Skip to content

Commit

Permalink
Add descriptions and generator
Browse files Browse the repository at this point in the history
  • Loading branch information
kdave committed Nov 20, 2023
1 parent af687ca commit cd2df2c
Show file tree
Hide file tree
Showing 69 changed files with 369 additions and 84 deletions.
219 changes: 219 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
# Shell scripts

Random collection of scripts and snippets.


## btrfs
[**bsdel**](bsdel):
Delete given btrfs subvolumes (as root).
\
[**bstime**](bstime):
Create btrfs snapshot with a timestamp in name.
\
[**gen-dump-image**](gen-dump-image):
Template to generate textual dump of image of filesystem.

## build
[**jj**](jj):
Shortcut for unlimited make with icecream.
\
[**jjc**](jjc):
Shortcut for unlimited make with ccache and icecream.
\
[**makev**](makev):
Run the given make command but open the results in vim
(same as saving make output and running vi -q output).

## crypt
[**device-create-cmd**](device-create-cmd):
Set up a block device with dm-crypt (aes-xts-plain64/sha512)

## data
[**histogram**](histogram):
Print histogram from data set (numbers).
\
[**lines-between**](lines-between):
Print lines between two markers, start included, end excluded.

## fstests
[**fstests-log**](fstests-log):
Quick scan of dmesg or given log file for fstests and warning/bug messages.

## gcc
[**inst-gcc-links**](inst-gcc-links):
Create symlinks for a given gcc & related tools version

## git
[**bgrep**](bgrep):
Grep in local git branches.
\
[**bsel**](bsel):
Visual git branch selector (bgrep, dialog), then print the branch name.
\
[**bsel-co**](bsel-co):
Visual git branch selector (bgrep, dialog), then check out the branch.
\
[**bsel-tig**](bsel-tig):
Visual git branch selector (bgrep, dialog), then run it in tig.
\
[**gd**](gd):
Git diff shortcut.
\
[**ge**](ge):
Edit changelog of HEAD.
\
[**gid**](gid):
Git diff shortcut.
\
[**gis**](gis):
Git show shortcut.
\
[**git-br**](git-br):
Print current branch name.
\
[**git-fixesline**](git-fixesline):
Print line from given commit for the Fixes: tag.
\
[**git-refresh-commit**](git-refresh-commit):
Apply any uncommitted changes to HEAD.
\
[**git-reword**](git-reword):
Edit a commit message of a given commit (rebase and --amend).
\
[**git-stableline**](git-stableline):
Format line for stable patch dependencies (see
Documentation/process/stable-kernel-rules.rst)
\
[**mt**](mt):
Run the preferred git conflict resolution tool (vimdiff).

## kernel
[**add-rev**](add-rev):
Add reviewed-by tag from known people to the right location to the top commit.
\
[**add-rev-to**](add-rev-to):
Edit given commit, run 'add-rev name' and edit to fixup things
then go back.

## log
[**gluelog.pl**](gluelog.pl):
Glue together lines from dmesg that got wrapped due to text width.
\
[**lastlog.pl**](lastlog.pl):
Chop the messages since last boot from a continuous serial console log,
identified by the timestamp change.
\
[**lsslab**](lsslab):
Print slab info with aligned columns, also can filter by slab name.
\
[**revfile.pl**](revfile.pl):
Reverse input, line by line and on each line (rev + tac).
\
[**tscat**](tscat):
'timestamped cat', prepend a timestamp to each line.

## misc
[**drop-caches**](drop-caches):
Drop caches.
\
[**pchown**](pchown):
Preserve permissions on chown on a file.
\
[**set-kbdrate**](set-kbdrate):
In X, set delay and repeat rate for maximum productivity.
\
[**setperm**](setperm):
Fix write permission on all files and directories.
\
[**setro**](setro):
Set "mostly read-only" mask on all files and directories.
\
[**sleepy**](sleepy):
Interactive sleep:
\
[**slowcat**](slowcat):
Print input lines with a small delay (0.1s).
\
[**tdelta**](tdelta):
Time delta between two timestamps.
\
[**waitpid**](waitpid):
Wait until a given pid exits (poll).

## net
[**waitping**](waitping):
Wait until the given host responds to pings.
\
[**waitssh**](waitssh):
Wait until the given host is up and ready for ssh.
\
[**wgetcz**](wgetcz):
Set preferred language to CZ and run wget.

## osc
[**osc-request-ack**](osc-request-ack):
Accept given SR

## packaging
[**kernpurge**](kernpurge):
Print kdialog with list of installed kernel packages and allow selection to
remove them, current kernel is not in the list
\
[**update-python**](update-python):
Convenient way to update python packages that exist on lower version,
and install them on current one (3.11)

## pkg
[**zypper-add-testing-repo**](zypper-add-testing-repo):
Add my testing repo and kernel.
\
[**zypper-install-packages**](zypper-install-packages):
Install a few testing packages.

## tig
[**tigh**](tigh):
Open arg in tig.
\
[**tigs**](tigs):
Shortcut for tig status.

## tmux
[**foursquares**](foursquares):
Create layout with four 50% squares.
\
[**newp**](newp):
Split panel, 2 lines at the bottom just to see the command but not the output,
exit afterwards
\
[**owntmux**](owntmux):
Capture the named session.

## vim
[**vicg**](vicg):
Open vim with coccigrep search, save temporary output for repeated calls
NOTE: upstream coccigrep stopped working for some reason, this is a simpler
version that does not find all occurences.
\
[**vigrep**](vigrep):
vim grep all *.[ch] files in current directory and open (:cNext/:cnext).
\
[**vigrub**](vigrub):
Edit grub1 config as root.
\
[**vihead**](vihead):
In a git tree, list files from the last commit (HEAD), offer a selection and
open in vim with the diff against HEAD^ (i.e. the last changes to the file).
\
[**vihead-all**](vihead-all):
Like vihead, but go through all files.
\
[**vii**](vii):
Translate "file:line:col" format to "vim +line file", to open files from e.g.
make output.
\
[**vimsyn**](vimsyn):
Generate syntax hilighted .xhtml of the given file.

## x
[**xclip-clear**](xclip-clear):
Clear all X clipboards
4 changes: 4 additions & 0 deletions README.md.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Shell scripts

Random collection of scripts and snippets.

1 change: 0 additions & 1 deletion _/set-kbdrate

This file was deleted.

2 changes: 1 addition & 1 deletion btrfs/bsdel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
# delete given btrfs subvolumes
## Delete given btrfs subvolumes (as root).

sudo btrfs subvol delete "$@"
2 changes: 1 addition & 1 deletion btrfs/bstime
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# create btrfs snapshot with a timestamp in name
## Create btrfs snapshot with a timestamp in name.

if ! [ -d "$1" ]; then
echo "$1 does not exist"
Expand Down
2 changes: 1 addition & 1 deletion btrfs/gen-dump-image
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh -x
# template to generate textual dump of image of filesystem
## Template to generate textual dump of image of filesystem.

sz=2g
rnd=$RANDOM
Expand Down
1 change: 1 addition & 0 deletions build/jj
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh
## Shortcut for unlimited make with icecream.
makej -j "$@"
1 change: 1 addition & 0 deletions build/jjc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh
## Shortcut for unlimited make with ccache and icecream.
makejc -j "$@"
4 changes: 2 additions & 2 deletions build/makev
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# run the given make command but open the results in vim
# (same as saving make output and running vi -q output)
## Run the given make command but open the results in vim
## (same as saving make output and running vi -q output).

vi -c ":make $@"
1 change: 1 addition & 0 deletions crypt/device-create-cmd
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
## Set up a block device with dm-crypt (aes-xts-plain64/sha512)
cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat "$@"
2 changes: 1 addition & 1 deletion data/histogram
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
# print histogram from data set
## Print histogram from data set (numbers).

cat "$@" | perl -MStatistics::Histogram -e '@data = <>; chomp @data; print get_histogram(\@data);'
2 changes: 1 addition & 1 deletion data/lines-between
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# print lines between two markers, start included, end excluded
## Print lines between two markers, start included, end excluded.

awk "
BEGIN { doprint=0; }
Expand Down
14 changes: 14 additions & 0 deletions ffmpeg/ff-to-x265-160p
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh -x

in="$1"

codec=libx265
crf=28
q=160

if [ -z "$in" ]; then
echo "usage: $0 infile"
exit 1
fi

ffmpeg -hide_banner -i "$in" -c:v $codec -crf $crf -vf scale=-2:$q -c:a libmp3lame -q:a 2 "$in".${q}p.mp4
14 changes: 14 additions & 0 deletions ffmpeg/ff-to-x265-480p
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh -x

in="$1"

codec=libx265
crf=28
q=480

if [ -z "$in" ]; then
echo "usage: $0 infile"
exit 1
fi

ffmpeg -hide_banner -i "$in" -c:v $codec -crf $crf -vf scale=-2:$q -c:a libmp3lame -q:a 2 "$in".${q}p.mp4
2 changes: 1 addition & 1 deletion fstests/fstests-log
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# quick scan of dmesg or given log file for fstests and warning/bug messages
## Quick scan of dmesg or given log file for fstests and warning/bug messages.

function filter() {
egrep -a '(run fstests|WARNING:|BUG:|RIP:|UBSAN:|^\s+[+-]|CPU:.*Comm:|write time|read time|blocked for more than|Linux version|memory leaks)'
Expand Down
1 change: 1 addition & 0 deletions gcc/inst-gcc-links
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
## Create symlinks for a given gcc & related tools version

if [ -z "$1" ]; then
echo "Usage: $0 version"
Expand Down
2 changes: 1 addition & 1 deletion git/bgrep
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
# grep in local git branches
## Grep in local git branches.

git branch | grep -i "$@"
3 changes: 1 addition & 2 deletions git/bsel
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh
#
# Visual branch selector
## Visual git branch selector (bgrep, dialog), then print the branch name.

width=60
branches=( `bgrep "$1" | sed -e 's/^\*/ /' | sed -e 's/^+/ /'` )
Expand Down
3 changes: 1 addition & 2 deletions git/bsel-co
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh
#
# Select a branch from list and check out
## Visual git branch selector (bgrep, dialog), then check out the branch.

b=$(bsel "$1")
if [ "$?" != 0 ]; then
Expand Down
3 changes: 1 addition & 2 deletions git/bsel-tig
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh
#
# Visually select a branch and tig it
## Visual git branch selector (bgrep, dialog), then run it in tig.

b=$(bsel "$1")
if [ "$?" != 0 ]; then
Expand Down
1 change: 1 addition & 0 deletions git/gd
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh
## Git diff shortcut.
exec git diff "$@"
1 change: 1 addition & 0 deletions git/ge
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh
## Edit changelog of HEAD.
exec git edit "$@"
1 change: 1 addition & 0 deletions git/gid
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh
## Git diff shortcut.
exec git diff "$@"
1 change: 1 addition & 0 deletions git/gis
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh
## Git show shortcut.
exec git show "$@"
2 changes: 1 addition & 1 deletion git/git-br
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# show current branch name
## Print current branch name.

git_dir=$(git rev-parse --git-dir 2> /dev/null) || exit 1
ref=$(git symbolic-ref HEAD 2> /dev/null) || exit 1
Expand Down
2 changes: 1 addition & 1 deletion git/git-fixesline
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
# format a line from given commit for the Fixes: tag
## Print line from given commit for the Fixes: tag.

git --no-pager show -s --abbrev-commit --abbrev=12 --pretty=format:"Fixes: %h (\"%s\")%n" "$@"
2 changes: 1 addition & 1 deletion git/git-refresh-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
# apply any uncommitted changes to HEAD
## Apply any uncommitted changes to HEAD.

git commit --amend -a -v --no-edit
4 changes: 1 addition & 3 deletions git/git-reword
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash
#
# git-reword - edit a commit message only (like "git commit --amend", but
# works for non-HEAD patches).
## Edit a commit message of a given commit (rebase and --amend).

CID="$1"

Expand Down
Loading

0 comments on commit cd2df2c

Please sign in to comment.