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

Hello /g/, I'm going to show you a nifty trick. Little things

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 55
Thread images: 18

File: sshot.png (172KB, 540x960px) Image search: [Google]
sshot.png
172KB, 540x960px
Hello /g/, I'm going to show you a nifty trick. Little things like this make me love linux (fuck off, Stalman).

tplay () { totem-audio-preview $(youtube-dl -g --default-search auto "$@" | tail -1)"; }


You can put that on your .bashrc, then:

tplay 'melano - on fire'


Also, you might need to
sudo apt-get install youtube-dl


ITT: Share fancy linux stuff
>>
File: 1470454797034.jpg (236KB, 630x844px) Image search: [Google]
1470454797034.jpg
236KB, 630x844px
>>56024705

LITERALLY FUCK YOU NIGGER FAGGOT
>>
>>56024719
There is no need for filthy language...
The fucked posted something that he just learned, don't be a dick. This is why you shitpost.
>>
File: india.jpg (38KB, 352x288px) Image search: [Google]
india.jpg
38KB, 352x288px
>>56024983
WELCOME TO THE SUCK RAJEED YOU FUCKING CURRY NIGGER
>>
A small tip for people who likes to write small bash functions and put them in the bashrc:

Put them in a separate file with the same name as the function in a script folder.

Now you can make a script manager.

Then you can easily print, edit, or add scripts as you wish.

And your bashrc won't get a huge un manageable mess as it will only include the sourcing of the include file.
>>
>>56025077
small tip from a non faggot here

put all of your bash functions in your ~/.bashrc instead of making a separate folder. that way you're not a faggot

.t not a faggot
>>
>>56025077
Thanks for the tip. Where to put and how to import that folder?
>>
>>56025196
you don't "import" the folder you would call the functions
>>
>>56025227
Well, I have to put the function definitions somewhere, right? Other than in .bashrc, that is.
>>
File: 1.jpg (195KB, 599x900px) Image search: [Google]
1.jpg
195KB, 599x900px
Try this as an example:
$ cd && mkdir scripts && nano ~/scripts/test.sh 


Write this in the file:
echo this is a test! 

Hit control x then answer y and press enter to save

$ nano ~/.bashrc 


Add this to the file:
#Aliases from ~/scripts
alias testme='/home/scripts.test.sh


Hit control x then answer y and press enter to save
$ . ~/.bashrc 


test your shit out by typing
testme 
>>
>>56024705
You forgot a quote faggot.
>>
install-gentoo() {
str="${@:-Install Gentoo}"

clr() { printf '\033c'; }; clr

while :; do
printf '\033[%s;%sf\033[%sm%s\033[m' \
"$((RANDOM%LINES+1))" \
"$((RANDOM%$((COLUMNS-${#str}+2))))" \
"$((RANDOM%8+30))" \
"$str"
read -s -n 1 -t .01 && clr && break
done
}
>>
File: 2154476_2_o.jpg (129KB, 682x1024px) Image search: [Google]
2154476_2_o.jpg
129KB, 682x1024px
>>56025250
>>56025518
And here's something useful

## Easy extract
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar 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
}

>>
>>56025629
Quote your variables.
>>
File: 2154476_1_o.jpg (148KB, 682x1024px) Image search: [Google]
2154476_1_o.jpg
148KB, 682x1024px
>>56025638
here you go

echo "'No.'  -some variable" 
>>
>>56025685
muh dik
>>
>>56024705
thanks op this is cool
>>
>>56025685
Enjoy your broken script then, faggot.
>>
Bash scripting is why I can't go back to windows.

Although windows 10 has that bash support now, windows 10 is a disaster in slow motion.
>>
File: 2159529_8_o.jpg (147KB, 682x1024px) Image search: [Google]
2159529_8_o.jpg
147KB, 682x1024px
>>56025745
it works fine. you would know that if you tested it.
>>
>>56025781
Least until you hit a filename with a space in it
>>
>>56025620
Nice.
>>
File: 2154476_12_o.jpg (125KB, 682x1024px) Image search: [Google]
2154476_12_o.jpg
125KB, 682x1024px
>>56025788
you're right. fixed

## Easy extract
extract () {
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xvjf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) rar 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
}

>>
>>56025954
Fails when the filename starts with a dash
>>
>>56026003
also when there's a laughing emoji at the beginning of the file
>>
File: 2159529_5_o.jpg (131KB, 682x1024px) Image search: [Google]
2159529_5_o.jpg
131KB, 682x1024px
>>56026003
i think unzip has a problem with it not the script

>>56026018
fuck laughing emojis
>>
>>56026045
Putting a single dash (-) after the options stops most of the programs from treating rest of the arguments as options.
>>
File: 2881502_16_o.jpg (110KB, 682x1024px) Image search: [Google]
2881502_16_o.jpg
110KB, 682x1024px
after the option?
>>
>>56026078
Like so: unzip --any-option-you-need - "$1"
>>
File: 2129721_15_o.jpg (133KB, 682x1024px) Image search: [Google]
2129721_15_o.jpg
133KB, 682x1024px
>>56026121

 else
echo "'$1' is a bad filename, and you should feel bad about it. !"
fi
}

>>
>>56026045
>that delicious teen cleavage
muh lord
>>
>>56026187
Yeah, if anyone seriously saves files with emojis or dashes at the start they can get fucked
>>
File: 11.jpg (116KB, 680x1024px) Image search: [Google]
11.jpg
116KB, 680x1024px
## Misc Maint.
alias @root='du -x / | sort -n'
>>
>>56026121
A single dash makes programs read from stdin. To make filename starting with a dash work, you need to use double dash --
>>
File: 3 (2).jpg (365KB, 1125x1680px)
3 (2).jpg
365KB, 1125x1680px
# find which log files contain (or don't contain) particular error messages
for i in *.log; do grep OutOfMemo $i >/dev/null && echo $i oom || echo $i ok; done
>>
File: 1 (1).jpg (113KB, 683x1024px) Image search: [Google]
1 (1).jpg
113KB, 683x1024px
# random corporate bullshit printer
curl -s http://cbsg.sourceforge.net/cgi-bin/live | grep -Eo '^<li>.*</li>' | sed s,\</\\?li\>,,g | shuf -n 1
>>
>>56027326
Quote your variables.
Also grep -r *.log will do this without loop.
Read manpages.
>>
>>56027383
More.
>>
>>56025629
Or you could just use
tar xf file.ext
>>
>>56026187
>>56025954
It will still break.

Run echo "'faggot' is not a valid file!" to see why. You can prevent this using ' instead of ".
>>
File: 15 (3).jpg (113KB, 682x1024px) Image search: [Google]
15 (3).jpg
113KB, 682x1024px
alias kimg='cat /dev/urandom | hexdump -C | grep "ca fe"'
>>
File: 7 (1).jpg (212KB, 682x1024px) Image search: [Google]
7 (1).jpg
212KB, 682x1024px
hile ! ping -c1 the_host_down; do sleep 1; done && date | mail -s 'the host is back!' [email protected]
>>
>>56027696
>pick random bits, convert them to hex and grep the lines which have the line "ca fe", corresponding to 1100101011111110
For what purpose
>>
File: 2162500_6_o.jpg (139KB, 682x1024px)
2162500_6_o.jpg
139KB, 682x1024px
>>56028050
its fun
>>
/(?=.*?word1)(?=.*?word2).*/


Not a script but a small regexp to match something only if it contains both words, no matter the order
>>
>>56024705
Doin' that with mpd and bookmarklets and a little shell script to get stuff to play from my smartphone.

Also dwm and custom xsetroot script.
>>
File: 2225343_9_o.jpg (117KB, 1024x682px) Image search: [Google]
2225343_9_o.jpg
117KB, 1024x682px
alias k='cd && clear'
>>
>>56025629
Just use unp
>>
>>56028474
we've had enough suggestions on this function
>>
>>56025518
Or you could just add the script folder to your $PATH like a normal human being instead of over-engineering it.

You don't even need to keep the .sh extension if you add a shebang at the start of the file (#!/bin/sh)
>>
>>56028583
^this

Put this line in your bashrc
export PATH=$PATH:$HOME/bin

Put all your fuckin scripts in ~/bin dir
>>
Ubuntu touch is so cute, shame it didn't catch on
>>
>>56028814
>responding to old ass thread shit
this guy >>56025196
went to bed 9 1/2 hours ago.
>>
>>56028923
Which means he's probably up now.

Fucking dumbass
>>
>>56029192
he killed himself faggot
Thread posts: 55
Thread images: 18


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.