Post usefully shell scripts and aliases you use daily

Post usefully shell scripts and aliases you use daily.

Attached: 1527177773929.png (680x680, 888K)

No

>Post usefully shell scripts and aliases you use daily.
Keep this alive for an hour i will post it. I have a ton of useful scripts. Away from sys now.

```insert_sudo () { zle beginning-of-line; zle -u "sudo " }
zle -n insert-sudo insert_sudo
bindkey "^[s" insert-sudo
```
zsh, insert sudo at the beginning of a line.

sudo $(echo "696d20686178656e20757220626f78656e0a" | xxd -ps -r)

##### YOUTUBE-DL ######
alias youtube-dl-mp3="youtube-dl --extract-audio --audio-format mp3 --audio-quality 6"
alias youtube-dl-mp3-best="youtube-dl --extract-audio --audio-format mp3 --audio-quality 0";

#### MISC ####
alias sauce="source ~/.bashrc";
alias ls='ls --color'
alias meteo="curl wttr.in/SanFrancisco";
alias speedtest="wget -O /dev/null speedtest.wdc01.softlayer.com/downloads/test10.zip";
alias rsyncDlPartial="rsync -av --partial --progress";
alias lock='xset -display :0.0 dpms force off && gnome-screensaver-command -l';
alias findBiggestDirs="du -Sh . | sort -rh | head -n 15";
alias pingGoogle="ping 8.8.8.8";
alias newsboat="docker run -it --rm -v ~/.newsboat/:/root/.newsboat combro2k/alpine-newsboat"

Attached: 1526597522003.jpg (403x292, 33K)

This will delete your computer ! Don't do it !!!1

Attached: 33132489_1689654344484014_5701556892027846656_n.jpg (939x960, 85K)

nice speedtest - snatching
here are some of mine
#update
alias justfuckmyshitupfam='sudo pacman -Syu && yaourt -Suya'
#backup/restore qbittorrent:
alias qbitbackup='sudo cp -r /home/gen0/.local/share/data/qBittorrent/* /mnt/epsilon/epsilon/configs/desktop/qBittorrent/data/qBittorrent/ && sudo cp -r /home/gen0/.config/qBittorrent/* /mnt/epsilon/epsilon/configs/desktop/qBittorrent/qBittorrent/'
alias qbitrestore='sudo cp -r /mnt/epsilon/epsilon/configs/desktop/qBittorrent/data/qBittorrent /home/gen0/.local/share/data/ && sudo cp -r /mnt/epsilon/epsilon/configs/desktop/qBittorrent/qBittorrent /home/gen0/.config/qBittorrent'
#conversion - simply replace the file formats and change bitrate accordingly
alias batchconmp3opus'for i in *.mp3; do ffmpeg -i "$i" -ab 192k "${i%.mp3}.opus";done'
alias batchconmp4WEBM='for i in *.mp4; do ffmpeg -i "$i" -b:v 1500k "${i%.mp4}.webm";done'
alias batchconaviWEBM='for i in *.avi; do ffmpeg -i "$i" -ab 128k -b:v 1500k "${i%.avi}.webm";done'
alias batchconm4aopus='for i in *.m4a; do ffmpeg -i "$i" -ab 192k "${i%.m4a}.opus";done'

#connect/disconnect vpn
alias nlvpn='nmcli con up uuid 1699d6a4-1d35-4823-99df-bf8d2fef4538 passwd-file ~/.config/passwd-file'
alias nonlvpn='nmcli con down uuid 1699d6a4-1d35-4823-99df-bf8d2fef4538'
alias swevpn='nmcli con up uuid 707e77cb-f2c6-49db-8c3e-ed5b3820bb17 passwd-file ~/.config/passwd-file'
alias noswevpn='nmcli con down 707e77cb-f2c6-49db-8c3e-ed5b3820bb17'
#cpu governor + info
alias cpu-performance=' sudo cpupower frequency-set -g performance && cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor'
alias cpu-powersave=' sudo cpupower frequency-set -g powersave && cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor'
alias cpu-speed='watch grep \"cpu MHz\" /proc/cpuinfo'

#pipe kodi to mpv

if [ -d "$HOME/git/kodi-playercorefactory/bash-scripts" ] ; then
PATH="$HOME/git/kodi-playercorefactory/bash-scripts:$PATH"
fi

Attached: 1506234907903.png (776x795, 937K)

>pinging ip to check if dns resolution works
nice one retard

too late :(

Attached: 1510827556546.gif (524x276, 1.29M)

>camelCase
fuck off nigger

alias cp='cp -vi'
alias mv='mv -vi'
alias rm='rm -vI'

im this user.

ok these are simple utility ones i use everyday.

1. moves all jpgs into target folder very quickly
find . -name '*.jpg' -exec mv {} target/ \;

2. get's all the file extensions from a particular page , run as "get_all_media url"

WEBSITE="$1"
echo "Getting png list..."
lynx -cache=0 -dump -listonly "$WEBSITE" | grep ".*\.png$" | awk '{print $2}' | tee png_pic_links.txt
echo "Downloading... png_pics..."
wget -nc -P ./png_pics -i png_pic_links.txt

WEBSITE="$1"
echo "Getting gif list..."
lynx -cache=0 -dump -listonly "$WEBSITE" | grep ".*\.gif$" | awk '{print $2}' | tee gif_pic_links.txt
echo "Downloading....gif_pics..."
wget -nc -P ./gif_pics -i gif_pic_links.txt

WEBSITE="$1"
echo "Getting webm list..."
lynx -cache=0 -dump -listonly "$WEBSITE" | grep ".*\.webm$" | awk '{print $2}' | tee webm_links.txt
echo "Downloading...webms..."
wget -nc -P ./webms -i webm_links.txt

tbc

little clarification on the 2nd script - it needs "lynx" which is in the repositories and get_all_media.sh is what i named it.

and you can ask whichever you are interested in, some of them are here.

Attached: Screenshot_2018-05-24_23-08-00.png (1104x702, 65K)

For get_media you can just use wget.
wget -nc -P ./$ext_pics -A $ext $webpage
If you use -r you can even get subpages.
Also if you use awk there is no reason using grep first and instead of tee just pipe awk's result to a file.

Make a git repo and upload them all.
If not possible I'll pick clear_cache as I wonder what you mean with cache.

>you use daily
Daily no, probably one per month, but in case someone asks to use my browser.
#!/bin/sh
PROFILEDIR=`mktemp -p /tmp -d tmp-fx-profile.XXXXXX.d`
firefox -profile $PROFILEDIR -no-remote -new-instance
rm -rf $PROFILEDIR

and respectively for Chromium
PROFILEDIR=`mktemp -p /tmp -d tmp-fx-profile.XXXXXX.d`
chromium-browser --user-data-dir=$PROFILEDIR --no-first-run
rm -rf $PROFILEDIR

brainlet retard here. where do i put all these alises for commands? inside bashrc?

Brainlet.jpg

It says ping google.
Not test DNS.
8.8.8.8 is a DNS server, so you know it has great uptime and can handle lots of responses in little time, making it a good target for a pingtest to see if you have internet connectivity.

>letting google know that you're online

sl

curl ipecho.net/plain; echo

certbot renew --quiet --deploy-hook "service nginx reload"
vi_nomtime() { M=$(date +%Y%m%d%H%M -d "$(stat -c %y $1)"); vi $1; touch -t $M $1; }
find_oldest() { find . -type f -printf '%TY%Tm%TdT%TH%TM %p\n' |sort |tail }
random_line() { awk 'BEGIN{srand()}{if(int(1+rand()*NR)==1)s=$0}END{print s}' $1 }

Attached: 1335059272948.jpg (719x460, 41K)

#!/bin/sh
clear
neofetch --w3m --source /home/user/gentoo-signet.png --scrot

alias redshit='redshift'

>usefully
That's an adverb; it is used with a verb, not a noun. The word you are looking for is "useful".

Anyone got root in htb celestial? The damn kernel exploit won't pop a shell

Attached: cumslut.jpg (324x326, 20K)

Nvm thought this was hmg ffs

>docker for an rss reader
for what purpose

in .bashrc or in any other file, then source that file in .bashrc

you know you can just type `sudo !!` and it will do that for you?

# Shortcut to step up the directory tree with an arbitrary number of steps,
# like cd .., cd ../.., etc
ud() {

# Check arguments; default to 1 and $PWD
if [ "$#" -gt 2 ] ; then
printf >&2 'ud(): Too many arguments\n'
return 2
fi
set -- "${1:-1}" "${2:-"$PWD"}"

# Check first argument, number of steps upward. "0" is weird, but valid;
# "-1" however makes no sense at all
if [ "$1" -lt 0 ] ; then
printf >&2 'ud(): Invalid step count\n'
return 2
fi

# Check second argument, starting path, for relativity and anchor it if
# need be
case $2 in
/*) ;;
*) set -- "$1" "$PWD"/"$2" ;;
esac

# Chop an element off the target the specified number of times
while [ "$1" -gt 0 ] ; do

# Make certain there are no trailing slashes to foul us up
while : ; do
case $2 in
*/) set -- "$1" "${2%/}" ;;
*) break ;;
esac
done

# Strip a path element
set -- "$(($1-1))" "${2%/*}"
done

# Shift off the count, which should now be zero
shift

# Try to change into the determined directory, or the root if blank
command cd -- "${1:-/}"
}

Attached: uriel.jpg (237x213, 11K)

alias fuck='sudo !!'

I dont think you can in zsh, or am I thinking of fish?

That won't work.

Fish was updated. It supports now !, && and ||.

True, I was lazy and didn't check my .bashrc

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

function extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract

function extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract

Or just use atool.

QUOTE YOUR VARIABLES

Attached: 1526853570047.png (500x500, 170K)

#!/usr/bin/env bash
while true
do
sudo pacman -Syyu
sleep 1h
done

poweroff

Don't:
while true; do something; sleep 1; done

Do:
Don't:
while sleep 1; do something; done

Attached: 1527232143929.jpg (600x800, 98K)

ud() {
if [ "$1" -eq "$1" ] &>/dev/null; then
local str=
for i in `seq 1 $1`; do
str=$str../
done
cd $str
fi
}

>backticks
>unquoted variables
>using [ in bash

>backticks
Fair enough
>unquoted variables
Quotes don't matter after sanitization
>using [ in bash
Habit. [ is more widely supported than [[

>bash
No one said it is though

I use this for my background images folder to filter duplicates
It's probably shit, but I don't really care desu
import os
from PIL import Image
import imagehash
import magic

path = os.getcwd()
filenames = os.listdir(path)

for filename in filenames:
file_type = magic.from_file(filename, mime=True)
if (file_type.endswith("jpeg") or file_type.endswith("png")):
image = Image.open(filename)
newName = str(imagehash.dhash(image))
os.rename(filename, newName)
else:
print filename + " is " + file_type

Quotes ALWAYS matter. Not quoting variables is wrong.

&> is a non posix bashism

Any recommendation for androids if i want to use mobile pentest tools

Am ifag, looking for secondary device to be inconspicous

cat /var/log/nginx/access.log | awk '{ print $1 }' | sort | uniq | wc -l

>mobile pentest tools
What now?

uptime | perl -ne "/(\d+) d/;print 8,q(=)x\$1,\"D\n\""

Prints a dick that's as long as your uptime

Hi vc

hi
do you want a password reset?

>tfw burger and can't use torrents
Get on the Eastern European level, sad faggots