What custom commands have you added you add to your favorite shell, if any, what function do they serve, and why did you add them? I personally have added:
-hider
A small program that hides and unhides all the system files on my Mac. Useful for adding more programs to bash...
-teatime
A program that estimates how long it will take a kettle of water to boil downstairs and sets off an annoying alarm after that time has elapsed, so that I don't forget about pouring the water. I love most teas (coffee is useful too), but I always forget about the water somehow...
-chlorine
A compiler for a custom programming language of mine (still in development). I love C++, but I think I'll like my language more.
-localpastebin
Basically, this just writes stuff that I stored in it to the command line, usually C++ code. I dunno, it saved me a lot of typing at least twice in the past.
-macrypt
Encrypts files I don't want anyone reading.
The only one I wrote (and lazily) that I actually still use is called "sizeof". It returns the size of a file or files in bytes, kiB and MiB. It's actually quite useful.
It also doesn't use sys/stat.h so it works on any system with a fully functional C stdio library.
Edit: I forgot to mention a Perl script I wrote ages ago. I wrote a script in Python to autodelete files in my wastebasket after 5 minutes but due to assumptions about the time, it was buggy (it would delete files that had been there for only a second if they were sent there just before the time elapsed). helios suggested to me to keep an array of the files and the amount of time since I'd seen them. I decided it would be easiest to use a hash in Perl and that's what I did.
I don't have it any more; but basically what it did was read every file in the directory (D) into an array and store the amount of time they'd been seen there for (it started when the user logged in). When that exceeded N seconds, the files were deleted. D and N were passed on the command-line.
As I'm very pedantic about what people do on my computer (when Linux is running; when window is running I couldn't care less (sometimes people need to use the machine while I'm using it, so I have to wait for them to finish), I was planning at some point to write a Linux loadable kernel module that intercepted keyboard interrupts, wrote them to a file, and then sent them on to the proper interrupt handler but I haven't yet figured out how to pass the scan code on to the interrupt handler.
I don't think there's a way in X windows to take keystrokes and still let them reach their intended destinations either.
Basically the idea is that I can check what someone was doing while I was away without them ever knowing.
Why would you bother writing 'look' -- use pwd (GNU) or cd (windows). I have an excuse for sizeof -- it's easier to type "sizeof <FILE>" than "ls -l <FILE>" for me because sizeof comes more naturally. Also the output is much more legible.
Edit: If aliases count, then I also have pacman32 -- I use 64-bit Arch Linux so I have to chroot to /var/arch32 to run 32-bit programs ( there's a tutorial for building a 32-bit system within Arch64 on http://wiki.archlinux.org/index.php/Install_bundled_32-bit_system_in_Arch64 ) and pacman32 is an alias for "pacman --root /opt/arch32 --cachedir /opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf"
Edit 2: I also have mountloop and umountloop.
I always used to [un]mount loop devices wrong and they'd never be free. I'd either have to free them all manually or reboot (I only did that once, though). So I wrote the two scripts to do it the Right Way.
I wrote a bash script to run bison or flex to a given file ( type assumed by the extension ) and then compile it.
This saves typing when using those tools
I think I still have as command a hello world program I wrote to test the autotools
blackbox.exe is my swiss army command line tool. It has 3 fully working functions right now.
-d<folder name>: Takes me to that folder. Easier then "cd /d X:\long\ass\path\" This one works out of a list though, so It's limited to defined directories and their aliases.
-b<file name> initates my bi0SCRIPT parser, a small scripting language I am writing.
-e<file name> encrypts the file so prying eyes can't view.
edit:
and about 12 not so fully working functions. :P
I've got tons of stuff like that. Mostly aliases, though.
I am currently updating my mpath program, which manipulates the PATH enviroment variable in a convenient and easy way. For example, to see what is in my PATH, I can type:
D:> mpath
0 D:\bin
1 C:\Program Files\Windows Resource Kits\Tools
2 C:\Program Files\Active State\Tcl\bin
... well, other entries omitted for this online example ...
D:>
If I want to add the current directory to the PATH:
D:\prog\foo> mpath a .
If I want to remove the Windows Resource Kits directory from the PATH:
D:> mpath r "Windows\ Resource"
or, as from above:
D:> mpath r 1
If I want to know how many directorys starting with "C:\WINDOWS" are in the PATH:
D:> mpath c c:\windows
4
D:> _
Et cetera.
All this is so much easier than dinking directly with the %PATH% variable at the command-line. Oh, yeah, it keeps the PATH variable itself nicely packed using the 8.3 filenames.
I once wrote a bunch of scripts for managing QEMU, called QEManager. I think I deleted it because it didn't work but I might try writing it again.
Basically it created a directory in the user's home folder, .qemanager, inside which were three directories: InstallImages, HardDisks and OperatingSystems. In the InstallImages folder was a copy of the installation media file (the .iso or .img file the operating system was installed from); in the HardDisks folder was a copy of each hard disk file for QEMU and in the OperatingSystems folder was a shell script, automatically generated, which called QEMU to run the operating system. I think I'll write it again, and this time, make it work...
passgen [n]
Generates a random string of alphanumeric characters of length n (16 if omitted) and puts it in the clipboard. The great thing about it is that, since there's no standard input or output and it doesn't use a directory for context, I don't even need to run it through the console, just Win+R, "passgen", enter works.
hash-rename
Renames all files in the directory to their SHA-1 hash while keeping their extensions. This is something I used to find myself doing an inordinate amount of times.
s2u (incomplete)
Converts Shift JIS to Unicode to and from various sources, including stdin (for piping), the clipboard, and the current directory (recursive). I've actually found some bastards that, not content with the shittiness of SJIS, like to use even shittier and more obscure encodings, so I have to resort to iteratively try different encodings with MultiByteToWideChar(). I suppose I could link to iconv, but I wanted to make it as small as possible.
Gee... that would make an excellent practical joke, except that it might cause a lot of damage. I once wrote a fork bomb that cost a girlfriend of a friend of mine about thirty solid hours of work, but that's another story.
I accidentally wrote a similar program to Albatross'. I was testing a program (called respawnd, with the 'd' being for 'daemon') that ran other programs and tried to restart them if they died with an exit status other than 0. Anyway; I was testing it and didn't realise that it would cause an infinite loop of fork()s.
Anyway I got a kernel panic and a bunch of messages regarding a full process table and there being no free memory. The worst part was because I had a full process table I couldn't run killall to try and stop the process from reproducing.
Which reminds me of the time I tried to write a mailbomber :P I was hosting an SMTP server on my computer and wrote, essentially, this:
1 2 3
while (true) {
mail("<email address>", "Lol", ":)");
}
in PHP.
And that's the story of how chrisname got banned from 000webhost.com.
@chrisname:
At least your first one was an accident. I deliberately run that bomb. It was quite neat, actually, I could detonate it over the internet, so long as I knew the address of the computer it was on.
I'd later use the same bomb against my friend's computer for talking me into planting that bomb.
And helios... what do you have to say about chris's second trick? (this should be good).
Hey, I wasn't doing it to be mean. I was doing it because I was bored. You may have noticed that I was hosting the SMTP server? It was my bandwidth I was eating (mostly).
I once had that idea, but gave up in the middle because it was more effort than was worth and not even interesting. It'd probably be a lot easier to write a Thunderbird addon that mails the same address over and over again.
What I did write... well, the other day, was an XP kernel driver that can remove any process from the process (linked) list. You have to be careful with it, because if the process terminates while unlisted, the system BSODs. Probably something about resources not getting freed, or getting freed when they shouldn't. I can't seem to get it to work on W7, even though all sources tell me I have the right offsets for _EPROCESS.
I had the idea a long time ago to combine that driver, a software keylogger, no-ip.com, a client-server architecture, and internet cafes into one malevolent stew, but meh.
I've written a couple viruses over the years. my favorite of all time is something I called constantine. She was a beauty. embedded it's self deep within the registry, and in a micro partition it creates so that reinstalling windows wouldn't get rid of it. Slowly it would infect every folder that's not been viewed by user (not a virus scan) within 30 days of last infection until eventually it's eaten it's way just into plain view.
A folder with a gibberish name pops up in your documents. You see it. You scan. You find that 90% of your hard drive has this parasite. So you start deleting. and that's when the bomb hits.
Any file that is infected gets deleted and written over so there is no chance of recovery.
I designed this virus, my dad helped me write it (some of the trickery code was beyond my grasp at the age of 14) and then I installed it manually at location on my friends computer. It was beautiful.
I should specify we used to have hacker wars. and this was my a coup de gras for what he had done to me.
Edit: I also attempted to, and failed to write a virus that over clocked processors till they popped.