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 tosudo apt-get install youtube-dl
ITT: Share fancy linux stuff
>>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.
>>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.
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 typingtestme
>>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
}
>>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.
>>56025638
here you goecho "'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.
>>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.
>>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
>>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.
after the option?
>>56026078
Like so: unzip --any-option-you-need - "$1"
>>56026121else
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
## 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 --
# 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
# 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 usetar 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 ".
alias kimg='cat /dev/urandom | hexdump -C | grep "ca fe"'
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
>>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.
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