Hello Sup Forums, 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
LITERALLY FUCK YOU NIGGER FAGGOT
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.
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.
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
Thanks for the tip. Where to put and how to import that folder?
you don't "import" the folder you would call the functions
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 typing
testme
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
}
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
}
here you go
echo "'No.' -some variable"
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.
it works fine. you would know that if you tested it.
Least until you hit a filename with a space in it
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
}
Fails when the filename starts with a dash
also when there's a laughing emoji at the beginning of the file
i think unzip has a problem with it not the script
fuck laughing emojis
Putting a single dash (-) after the options stops most of the programs from treating rest of the arguments as options.
Like so: unzip --any-option-you-need - "$1"
else
echo "'$1' is a bad filename, and you should feel bad about it. !"
fi
}
>that delicious teen cleavage
muh lord
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'
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 cbsg.sourceforge.net/cgi-bin/live | grep -Eo '^.*' | sed s,\,,g | shuf -n 1
Quote your variables.
Also grep -r *.log will do this without loop.
Read manpages.
Or you could just use tar xf file.ext
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]
>pick random bits, convert them to hex and grep the lines which have the line "ca fe", corresponding to 1100101011111110
For what purpose
/(?=.*?word1)(?=.*?word2).*/
Not a script but a small regexp to match something only if it contains both words, no matter the order
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.
we've had enough suggestions on this function
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)
^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
>responding to old ass thread shit
this guy went to bed 9 1/2 hours ago.
Which means he's probably up now.
Fucking dumbass