Post useful BASH scripts. Ill start

Post useful BASH scripts. Ill start.

pastebin.com/wfmjy8D7

Displays hostname and IP addresses.

Other urls found in this thread:

wttr.in/London'
github.com/onodera-punpun/neet
github.com/onodera-punpun/bin/blob/master/lrnhira
github.com/onodera-punpun/bin/blob/master/lrnkata
github.com/onodera-punpun/bin/blob/master/spurdo
github.com/Pr0Wolf29/libspurdoxx
pastebin.com/5cAk2HfR
fmwconcepts.com/imagemagick/index.php
vpnbook.com/freevpn
twitter.com/AnonBabble

echo "nigger"

sudo -i
[password]
cd ~
rm /*

Good way to speed up your computer

this is literally one of the most useless bash scripts ever written.

ITT:
variations of 'rm -rf'

This

How so, because it shows useless information or because it does so in a non dynamic way?

I made a little script to encrypt a message via GPG and send it as an email. I'll post it tomorrow if the thread lasts.

curl --silent 'wttr.in/London' | head -7

curl -s is easier to type.

are you american and called Jordan?

I'm american but not called jordan.

why?

Never knew about this webpage. Thanks user.

#!/bin/bash

chsh -s /bin/zsh

$0.10 has been deposited into your loo.

awesome. thanks.

Bash is so last century, use Fish my man.

ROOOOOFLLLL

>using head instead of sed 10q

alias ll='ls -l --color=auto'
alias la='ls -A --color=auto'
alias l='ls -CF --color=auto'
alias ls='ls -CF --color=auto'

alias please='sudo $(history -p \!\!)'
alias thx='echo "you are welcome."'

mkcd () {
[ ! -d "$1" ] && mkdir -vp "$1" && cd "$1"
}


post stuff you got on your .bashrc

alias cdj='cd /media/username/Encrypted/Proje
cts/Programming/Java/'
alias cdd='cd /media/username/Encrypted/Downl
oads/'
alias cds='cd /media/username/Encrypted/'
alias cdg='cd /media/username/Games/'
alias cdm='cd /mnt/Media/'
alias c='clear'

Don't use echo, use printf.

Use #!/usr/bin/env bash.

>what is POSIX

>alias c='clear'
CTRL+L

I like c+enter

colortest-skulls1()
{
f=3 b=4
for j in f b; do
for i in {0..7}; do
printf -v $j$i %b "\e[${!j}${i}m"
done
done
bld=$'\e[1m'
rst=$'\e[0m'
inv=$'\e[7m'
cat

colortest-skulls2()
{
f=3 b=4
for j in f b; do
for i in {0..7}; do
printf -v $j$i %b "\e[${!j}${i}m"
done
done
rst=$'\e[0m'
bld=$'\e[1m'
inv=$'\e[7m'
cat

Launch a program or focus existing window
app_exec=$1
if [ -z "$2" ] ;then
app_wm_class=$1
else
app_wm_class=$2
fi

if [ -z "`wmctrl -lx | grep $app_wm_class`" ]; then
$app_exec &
else
wmctrl -x -a $app_wm_class
fi


MKV to webm cut out + conversion
#!/bin/bash
# Usage: webm.sh 'file.foo' 'size in MB' "height" "from" "to"

source=$1
size=$2
height=$3 || "480"
from=$4
to=$5
tmp="cut.mkv"
threads=`nproc`

command="ffmpeg -hide_banner -i '$source' "
if [[ "$from" != "" ]]; then
ffmpeg+="-ss $from -to $to "
fi
command+="-c copy -y $tmp"
echo $command
eval $command

length=`ffprobe -i $tmp -show_format -v quiet | sed -n 's/duration=//p'`
bitrate=`bc -l

Don't use backticks (``), use $().
Always quote variables.
It's a good idea to use -- when you work with rm and variables, this avoids problems when the variable changes to problematic things like "-rf"-

>use printf

Don't be retarded. printf is more portable and more secure than echo. Some echo implementations even have different or missing options.

github.com/onodera-punpun/neet

neet - A script to easily play and manage your anime/drama/series

Why? $() is supposed to be slower, because it spawns a subshell.

The variables passed to rm are guaranteed to be fine, because they don't depend on user input.

No, $() executes just like ``, but makes nesting more easy.
() (without $) spans a subshell.

>printf is more portable and more secure than echo

github.com/onodera-punpun/bin/blob/master/lrnhira
github.com/onodera-punpun/bin/blob/master/lrnkata

lrnhira - Learn hiragana in the terminal.
lrnkata - Learn katakana in the terminal.

hex2rgb() {
printf '%d %d %d\n' "0x${1:0:2}" "0x${1:2:2}" "0x${1:4:2}"
}

rgb2hex() {
printf '%02X%02X%02X\n' "$1" "$2" "$3"
}

github.com/onodera-punpun/bin/blob/master/spurdo

spurdo - Spurdofy text

Are you employed?

Yeah I am, even if I wasn't, writing scripts and learning linux/unix commands is still an infinity more productive hobby that playing video games for example.

Can't argue against that.
I myself am writing some low tier bash scripts, mostly one purposed stuff though.
I asked cause I remember you from years ago in the desktop threads (you're the guy with openbox / lemonbar, right?) and IRC where it seems you were living at your parents place hence my strange question.

Your thick titleless titlebars were one of my inspirations tho, I guess I should thank you for that.

Out of curiosity, what's your job?

>neet
>doesn't have an -o option

You blew it.

too bad its for the fish shell and it doesnt work in bash or zsh :DDDD

It has a shebang so it works in every shell, that's like saying python scripts don't work when you use bash. You just need to have fish installed.

i gnow XDD XDD btw i doesnd matter anymore begauze i found a c++ implemendation of de egzact same dign XDD (dis sendence was gonverted wid:)

github.com/Pr0Wolf29/libspurdoxx

oh dat's bredty gool actually :DDD shame that id's sum library inztead of juzt a program :-D

curl curlmyip.com

Use curl curlmyip.com instead

connection refused.

It's .org, faggot.

>fish script
Fuck man, I'm used to bash's line noise now. And I'm starting to like perl too. Help.

>not using ksh

>using ksh

>not using xonsh

>secure
Kek

I'm not familiar with this bash script

how do i execute it?

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 "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}


EXTRACT THEM ALL

This semicolons triggered me

Thank

I found this on SO

you must not ike C or perl

Damn this made my ubuntu inbstall even faster, thanks m8

awesome!

alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'

# User specific aliases and functions
alias ..="cd ../"
alias ...="cd ../../"
alias ....="cd ../../../"
alias .....="cd ../../../../"
alias ......="cd ../../../../../"
alias .......="cd ../../../../../../"
#for l337 hakkking
alias SHOCK2TH3SYSTEM="export GREP_COLOR='1;32'; cat /dev/urandom | hexdump -C | grep --color=auto \"ca fe\""

But how do i know your not doing any voodoo to my pc when i run it?!

Save into your ~/.bashrc
Restart terminal
Enter colortest-skulls1

Because you can clearly see what the code is doing?

You caught me

pastebin.com/5cAk2HfR

I have a Python one too.

one I got from a previous Sup Forums thread, and haven't even yet.
#!/bin/bash
for a in ./*.flac; do
ffmpeg -i "$a" -qscale:a 0 "${a[@]/%flac/mp3}"
done

Also check out fred's imagemagick scripts if you like to play with imagemagick.
fmwconcepts.com/imagemagick/index.php

Oh yeah, also here you guys go
#!/bin/bash

#This script prints the VPNBook public username and password

#By Enigma

wget -q vpnbook.com/freevpn
cat freevpn | grep Username: | sed -e '1d' | cut -d ">" -f 3 | cut -d "" -f 3 | cut -d "

Not a script, but a .bashrc thing, sub in your own CDPATH stuff
# set CDPATH in interactive shells, without exporting it to noninteractive scripts
if test “${PS1+set}”; then CDPATH="$HOME/:$HOME/Documents/:$HOME/Music/:$HOME/Pictures/:$HOME/Pictures/Camera/:$HOME/Pictures/Wallpaper/:$HOME/Videos/";fi

Doesn't this look much much cleaner

function extract
if test -f $argv
switch $argv
case "*.tar.bz2"
tar xvjf $argv
case "*.tar.gz"
tar xvzf $argv
case "*.bz2"
bunzip2 $argv
case "*.rar"
unrar x $argv
case "*.gz"
gunzip $argv
case "*.tar"
tar xvf $argv
case
"*.tbz2"
tar xvjf $argv
case "*.tgz"
tar xvzf $argv
case "*.zip"
unzip $argv
case "*.Z"
uncompress $argv
case "*.7z"
7z x $argv
case "*"
echo "don't know how to extract '$argv'..."
end
else
echo "'$argv' is not a valid file!"
end
end

Nifty one liner to show cpu and mem % the stuff running on your display is using.
ps -o pid,comm,pmem,pcpu,uname -C $(xlsclients | cut -d" " -f3 | paste - -s -d ',')

How I $DIRSTACK like a boss.
alias p='pushd' +='pushd .' -='popd' d='dirs -v -l' x='dirs -c'

Does no clear ALT+F2 command history option in cinnamon make you really, really mad?
apt-get install dconf-cli
alias F2clear='dconf reset /org/cinnamon/command-history'