SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#26 2012-05-06 10:30:13

machinebacon
#! unstable
From: China
Registered: 2009-07-02
Posts: 6,620
Website

Re: [Closed] post your handy command-line utilities

^ Thanks rho - but actually it doesn't do much, except of cutting off the rubbish big_smile

Offline

Be excellent to each other!

#27 2012-05-07 08:05:59

fuzetsu
Member
Registered: 2012-05-06
Posts: 12

Re: [Closed] post your handy command-line utilities

In an attempt to teach myself some bash and refresh my javascript and html I wrote this one a couple days ago. Before telling me how terrible it is consider that it's probably the first real bash script I've ever written smile

That aside, I'm pretty proud of it, it isn't all that useful since there are plenty of apps out there that do this much better but I thought it was pretty cool to generate something similar that runs in a browser with a single bash script. It's mostly catered towards my manga reading but it works fine for normal image viewing.

#!/bin/bash
#
# IMAGES TO HTML
# --------------
# This script generates an html file and adds all the images of a defined
# type to an 'image viewer' in the html
#
# Usage: imagestohtml file.html typeofimage(ex: gif jpg png) copy(or just left out)
# Putting 'copy' as the third parameter of the script creates a new directory called
# images and copies all the images there numbered, I just added this because I was 
# having a problem with files that were named strangely.
#

if [ "$3" == "copy" ]; then
    mkdir images
fi
count=0
echo -n "<html>
    <head>
        <style>
            body {
                background-color: #000;
                text-align: center;
                margin: 0px;
                color: white;
            }        
            img {
                height: 100%;
            }
            #back {
                position: fixed;
                width: 50%;
                height: 100%;
                top: 0px;
                left: 0px;
            }
            #next {
                position: fixed;
                width: 50%;
                height: 100%;
                top: 0px;
                right: 0px;
            }
            #imgnum {
                position: fixed;
                bottom: 0px;
                right: 10px;
                font-size: 2em;
            }
            #controldiv {
                position: fixed;
                bottom: 0px;
                left: 10px;
                background-color: black;
            }
            #control {
                text-align: right;
            }
        </style>
        <script type='text/javascript'>
            var count = 0;
            function init() {
                document.images[0].src = imgArray[0];
                document.getElementById('imgnum').innerHTML = count + 1;
                document.getElementById('numpages').innerHTML = imgArray.length - 1;
            }
            function nextImage() {
                ++count;
                if(count > imgArray.length - 2)
                    count = 0;
                document.images[0].src = imgArray[count];
                document.getElementById('imgnum').innerHTML = count + 1;
                window.scroll(0,0);
            }
            function lastImage() {
                if(count == 0)
                    count = imgArray.length - 1;
                --count;
                document.images[0].src = imgArray[count];
                document.getElementById('imgnum').innerHTML = count + 1;
                window.scroll(0,0);
            }
            function setSize(size) {
                if(isNaN(parseInt(size)))
                    alert('invalid size');
                else {
                    document.images[0].style.height = size + '%';
                    window.scroll(0,0);
                }
            }
            function goto(page) {
                if(isNaN(parseInt(page)) || parseInt(page) > imgArray.length - 3 || parseInt(page) < 1)
                    alert('invalid page');
                else {
                    count = parseInt(page) - 2;
                    nextImage();
                }
            }
            var imgArray = [" > $1
for image in *.$2
do
    if [ "$3" == "copy" ]; then
        let count+=1
        cp $image images/$count.$2
        echo -n "'./images/$count.$2'," >> $1
    else
        echo -n "'$image'," >> $1
    fi
done
echo "null];
        </script>
    </head>
    <body onload='init()'>
        <div id='back' onclick='lastImage()'></div>
            <img src='broken'/>
        <div id='next' onclick='nextImage()'></div>
        <div id='imgnum'></div>
        <div id='controldiv'>
            <label>Pages: </label><span id='numpages'></span>
            <br/>
            <span id='control'>
                <label>size: </label><input size='4' type='text' value='' onchange='setSize(this.value)'/>
                <br/>
                <label>goto: </label><input size='4' type='text' value='' onchange='goto(this.value)'/>
            </span>
        </div>
    </body>
</html>" >> $1

Last edited by fuzetsu (2012-05-07 08:10:24)

Offline

#28 2012-05-07 08:52:06

jelloir
#! CrunchBanger
From: Outside the garden wall
Registered: 2009-08-21
Posts: 212

Re: [Closed] post your handy command-line utilities

One liner to batch convert files using ffmpeg.

find ./ -type f -name "*.ogg" -exec sh -c 'ffmpeg -i -map_meta_data 0:0,s0 "{}" "$(dirname "{}")/$(basename "{}" .ogg).mp3"' \;

In this example I needed to convert some ogg's to mp3 for use in iTunes.  Output files will be placed in the same folder as the source file being converted with the new file extension.

You could easily alter the destination file extension, find folder (current directory in this example) and ffmpeg arguments to batch convert pretty much anything you like.  it might be useful to use find's -iname option instead of -name also.

Offline

#29 2012-05-08 12:27:56

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 3,909

Re: [Closed] post your handy command-line utilities

Remember the extract function that got posted earlier? I now made an archive function too. Initially I wanted it to be like the extract function, e.g. looking at the command given to know what to do but somehow that doesn't seem to work. I have still copied those lines in, incase someone with more bash knowledge than me (I simply copied the extract function big_smile) can fix it:

# MAKE ARCHIVES
# usage: mkarchive <file> <archive>
mkarchive ()
{
  #if [[ -f "$2" ]]; then
    case "$2" in
      *.rar)         rar a "$2" "$1"           ;;
      *.zip)         zip -r "$2" "$1"          ;;
      *.tar.gz)   tar -cvpzf "$2" "$1"  ;;
      *.tar.bz2) tar -cvpjf "$2" "$1"   ;;
      *)                  echo "I don't know how to make '$2'" ;;
    esac
  #else
  #  echo "$1 does not exist, or I don't know how to make $2"
  #fi
}

Also, I have not implemented that many archive types, as I find myself mainly using .zip or .rar - I mostly share with the Windows world. Feel free to add more yourself though!

Last edited by Unia (2012-05-08 12:28:15)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Github

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#30 2012-05-08 12:53:24

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: [Closed] post your handy command-line utilities

^ nice idea!

Offline

#31 2012-05-08 14:49:51

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 3,909

Re: [Closed] post your handy command-line utilities

rhowaldt wrote:

^ nice idea!

I have my moments.. big_smile

Last edited by Unia (2012-05-08 14:50:03)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Github

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#32 2012-05-08 15:33:42

gutterslob
#! Resident Bum
Registered: 2009-11-03
Posts: 3,043

Re: [Closed] post your handy command-line utilities

Was (sorta) inspired by Baconator's porn (hustling?) streaming script.
This one's for radio. Just a quick n' dirty job (I'm still at work, just burning time waiting for a client) using perl and mplayer (and related audio codecs). You can probably modify it for vlc if you want, but seriously, who uses QT outside smartphones?! tongue

#!/usr/bin/perl
# radio.pl
# give "list" or a stationname as cli argument
use strict;
use warnings;

my %stations = (
'bbcworld' => 'mms://a973.l3944038972.c39440.g.lm.akamaistream.net/D/973/39440/v0001/reflector:38972',
'oasis-osaka' => 'http://www.oasis-radio.net/mediaplayer_192mp3.wax',
'barcelonajazz' => 'http://www.live365.com/play/jmestres',
'vanillounge' => 'http://listen.radionomy.com/Vanilla-Lounge',
'jazz24' => 'http://sc1.abacast.com:8236/',
'smoothjazz' => 'http://scfire-ntc-aa07.stream.aol.com/stream/1010/'
);
my @stationnames = keys %stations;
my $mplayeroptions = "-input file=mplayer -msgcolor -msgmodule -nolirc";
#my @links = values %stations; # not needed yet but might be useful
my $cliarg;
if ( defined $ARGV[0] ) {
    my $cliarg = $ARGV[0];
    if ( $cliarg eq "list" ) {
        print "@stationnames\n";
        exit 0;
    }
    if ( grep { $_ eq $cliarg } @stationnames ) {
        system("/usr/bin/mplayer $mplayeroptions $stations{$cliarg}");
    } else    {
        print "Please provide a valid radio station name commandline argument. (use \"list\" as argument to see a list of names)\n"; 
        exit 1;
    }
} else {
    my $selection;
    print "Enter the name of the radio station.", "\n";
    $selection = <STDIN>;
    chomp($selection);
    if ( grep { $_ eq $selection } @stationnames ) {
        system("/usr/bin/mplayer $mplayeroptions $stations{$selection}");
    } else    {
        print "Please provide a valid radio station name. (use \"list\" as argument to see a list of names)\n"; 
        exit 1;
    }
}

Some bits/ideas up there were borrowed from various perl scripts. Credit to whoever they originated from.

In the version I'm using the "$mplayeroptions" part sources my mplayer config file, but since most people don't bother creating one, I just switched it with a generic verbose mplayer command. Just replace it with the relevant path if you do have a ~/.mplayer.conf or prefer the default /etc/mplayer/mplayer.conf.local

Lists of stations is small, since I hardly listen to net radio these days. TBH, only ones on there that I listen to are bbcworld and oasis-osaka (at night). Feel free to add your own preferred channels. Maybe someone should start a thread where we can share net radio stations.

Usage = radio.pl <stationname>
Example = radio.pl bbcworld
You can also do "radio.pl list" to list all the stations you've added.

Yeah, like I said, quick n dirty. hmm No fancy cli menus to select station or anything like that.
Sorry .... got bored midway once I realized I was hungry and this script wasn't exactly capable of making dinner. neutral

Last edited by gutterslob (2012-05-09 01:49:31)


Point & Squirt

Offline

#33 2012-05-08 18:49:01

mahatman2
#! Die Hard
From: Chattanooga TN
Registered: 2009-09-13
Posts: 550

Re: [Closed] post your handy command-line utilities

EDIT: topic here

Last edited by mahatman2 (2012-05-09 20:27:16)


Punch all your friends.

Offline

#34 2012-05-09 00:23:38

jelloir
#! CrunchBanger
From: Outside the garden wall
Registered: 2009-08-21
Posts: 212

Re: [Closed] post your handy command-line utilities

rhowaldt wrote:

@arclance: thanks for explaining, i understand now!
@2manydogs:(hope i'm not taking it too far off-topic here, but:) i simply use a bash function for extraction. it is in my ~/.bashrc:

# 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"        ;;
          *.cbr)       rar x "$1"       ;;
          *.cbz)       unzip "$1"       ;;
          *)           echo "don't know how to extract '$1'..." ;;
      esac
  else
      echo "'$1' is not a valid file!"
  fi
}

Another addition I added to this script was to extract .debs which I oocasionally need to do.

*.deb)       dpkg -x "${1}" $(echo "${1}" | sed "s/.deb//") ;;

Offline

#35 2012-05-09 01:26:34

sqlpython
#! Die Hard
From: New England
Registered: 2011-11-28
Posts: 930

Re: [Closed] post your handy command-line utilities

Here's some that I have over the Years... Pretty simple stuff..

First is script used to convert pictures downloaded from my Palm Pilot Zire Camera some years ago..
Converts the *.pdb to *.jpg format.

for jj in `ls -1 *.jpg.pdb`; do pilot-foto -c $jj ; done

Next is one I had posted here to fetch the Weather. I had posted it in CrunchBang forums at One Point.

#!/bin/bash
xfce4-terminal -I "/usr/share/xfce4/weather/icons/liquid/30.png" --geometry 65x10 -T "Weather Report" -H -e "weather-util -c NYC -s NY -i KNYC" 

Then here is one that I had to use upon start out in inittab because the Wifi needed ndiswrapper and before the *.inf would install the ssb and b43 Nic mods had to be removed. Otherwise one stepped on the address of the other.

#!/bin/bash
rmmod ndiswrapper
ndiswrapper -e bcmwl5
rmmod b43
rmmod ssb
ndiswrapper -i /home/sqlpython/.wireless/bcmwl5.inf
modprobe ssb
modprobe b43
ndiswrapper -m
ndiswrapper -l
modprobe ndiswrapper
exit

Here is a CLI  Bash BackUp that I wrote for a friend years ago to help him learn BASH..

#! /bin/bash
# My Backup Program
clear
echo "***My BackUp***"
echo "Enter one of the Backup Commands as Below..."
echo
echo "tarcopy /dir/toCopy"
echo "t7z /dir/finalLocaton  /original/tocompress"
echo "unt7z /dir/touncompress"
echo "zerospace /dir/toZero"
echo "ddimage /dir/tobakup  /dir/tosaveto"
echo "ddrestore /dir/toRestore  /dir/destinaton"
echo
echo "To view a Dir listing type lscmd /dirname"
echo
echo "Enter Command on next line: "
read rname dir1 dir2


case $rname in
   tarcopy)
      echo "This is a tarcopy to $dir1"
      echo "You can enter Ctrl C to HALT this Process."
      echo
      #tarcopy wrote:
      #tar lcf - .|(cd "$1"; tar xpvf - )
      ;;
   "t7z")
      echo "This is t7z $dir1 $dir2 double compression"
      echo "You can enter Ctrl C to HALT this Process."
      echo
      #t7z wrote:
      #tar cpvf - "$dir2" | 7za a -si "$dir1"
      ;;
   "unt7z")
      echo "This is unt7z $dir1 uncompress"
      echo "You can enter Ctrl C to HALT this Process."
      echo
      #unt7z wrote:
      #7za z -so "$dir1" | tar xpvf -
      ;;
   "zerospace")
      echo "This is zerospace $dir1 to zero the dir"
      echo "You can enter Ctrl C to HALT this Process."
      echo
      #zerospace wrote:
      #dd if=/dev/zero of="$dir1/zeroemptyspace"
      #rm "$dir1/zeroemptyspace"
      ;;
   "ddimage")
      echo "This is a ddimage of $dir2 bzip2 to $dir1"
      echo "You can enter Ctrl C to HALT this Process."
      echo
      #ddimage wrote:
      #dd if="$dir2" | bzip2 > "$dir1"
      ;;
   "lscmd")
      echo "This is a Directory List of $dir1"
      echo
      echo
      ls -FC --color $dir1 |more
      #./alsbakup2
      ;;
   ddrestore)
      echo "This is a Restore of $dir1 to $dir2"
      echo "You can enter Ctrl C to HALT this Process."
      echo
      #ddrestore wrote:
      #cat "$dir1" | bunzip2 -c | of="$dir2"
      ;;
   *)
      echo Incorrect Command!
      echo Run My Backup again
      exit
      ;;
esac      
#end the script

And here is my Favorite! It sneaks up on You..

 #!/bin/bash          
    sleep 5
          echo "Hello World!"

Last edited by sqlpython (2012-05-09 01:48:29)


OHCG #!, Jessie,, Siduction-13.1,  Slackware 14,  Bridge,, Sabayon 13.4,

Offline

#36 2012-05-09 01:41:50

sqlpython
#! Die Hard
From: New England
Registered: 2011-11-28
Posts: 930

Re: [Closed] post your handy command-line utilities

Almost forgot this one I did for OpenBox an Idesk Trash Can with Script..

Here is the Idesk Config..

 table Icon
   Caption: Trash
   Icon: /usr/share/icons/hicolor/48x48/devices/trash_empty_48.png
   Width: 48
   Height: 48
   X: 1250
   Y: 600
   Command[0]: thunar trash:///
   Command[1]: /home/sqlpython/.scripts/./checktrash.sh
 end

   Next the Py Script to Empty the Trash... which mechanically works but not polished yet..
I have to add a few lines to Change the Icon from Full to Empty..

import os 
trashbin = '/home/sqlpython/.local/share/Trash/files/' 
if  os.listdir(trashbin) != [ ]: 
# Remove all files
    os.remove(trashbin)    
else: 
    end

OHCG #!, Jessie,, Siduction-13.1,  Slackware 14,  Bridge,, Sabayon 13.4,

Offline

#37 2012-05-10 18:19:40

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 3,909

Re: [Closed] post your handy command-line utilities

Scratch those extract and mkarchive functions! I just came across atool:

http://www.nongnu.org/atool/

Usage?

apack archive.rar  file1 file2 ...
apack archive.tar.gz  file1 file2 ...
apack archive.tar.xz  file1 file2 ...
apack archive.zip  file1 file2 ...

and...

aunpack archive.tar.gz

If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Github

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#38 2012-05-10 18:25:20

fuzetsu
Member
Registered: 2012-05-06
Posts: 12

Re: [Closed] post your handy command-line utilities

^ nice one, very handy!

Offline

#39 2012-05-10 18:42:23

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 3,909

Re: [Closed] post your handy command-line utilities

Question is, pull in 11MB of scripts that can also be done with ~20 lines in .bashrc? Hmmm tongue


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Github

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#40 2012-05-10 19:04:44

fuzetsu
Member
Registered: 2012-05-06
Posts: 12

Re: [Closed] post your handy command-line utilities

11MB? Even the source with all the configuration files and readmes is under 600KB hmm (or are we not talking about atool?)

Offline

#41 2012-05-10 19:30:32

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 3,909

Re: [Closed] post your handy command-line utilities

fuzetsu wrote:

11MB? Even the source with all the configuration files and readmes is under 600KB hmm (or are we not talking about atool?)

Oops, 0,11MB big_smile


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Github

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#42 2012-05-10 19:32:45

fuzetsu
Member
Registered: 2012-05-06
Posts: 12

Re: [Closed] post your handy command-line utilities

lol that makes more sense.

What you say is true, plus you get the gratification of making it yourself tongue

Offline

#43 2012-05-22 00:19:55

gutterslob
#! Resident Bum
Registered: 2009-11-03
Posts: 3,043

Re: [Closed] post your handy command-line utilities

El_Korac's been into making gradient wallpapers on gimp lately. Thought this might save him the trouble.

Requires hsetroot to be installed.

First, the script:

#!/bin/sh

COLOUR_LIST=$HOME/.hsetroot_colors

rndcolour() {
    cat $COLOUR_LIST | shuf | head -n 1
}

rndangle() {
    echo $((RANDOM % 360))
}

hsetroot -add "$(rndcolour)" -add "$(rndcolour)" -add "$(rndcolour)" -gradient $(rndangle)

You can see a path to a file that contains a list of colors above, which means you need to create it.
Mine is called ~/.hsetroot_colors (yes, I intentionally spelled colours the wrong way), but you can name it whatever you want as long as it matches the path in the script. Put whatever colour values you desire.

~/.hsetroot_colors

#000000
#111111
#222222
#333333
#444444
#555555
#666666
#777777
#888888
#999999
#aaaaaa
#bbbbbb
#cccccc
#dddddd
#eeeeee
#ffffff

Edit:
Just thought I'd disclaim that it's not my idea. Originally encountered something similar on another forum (I think it was either Gentoo or Arch). I just modified stuff here and there.

Last edited by gutterslob (2012-05-22 12:36:16)


Point & Squirt

Offline

#44 2012-05-22 06:33:49

el_koraco
#!/loony/bun
From: inside Ed
Registered: 2011-07-25
Posts: 4,749

Re: [Closed] post your handy command-line utilities

Nice slobman. I'm syncing my Gmail account with offlineimap at the moment, will try this once the stuff is complete.

Offline

#45 2012-05-24 02:48:11

pidsley
Window Mangler
Registered: 2012-05-23
Posts: 1,752

Re: [Closed] post your handy command-line utilities

custom dmenu (handy for WMs that cannot be configured while running, like DWM, but also useful for others). bind this script to a key combination (I use mod4-m):

#!/bin/bash

str=`cat ~/.scripts/mymenu.lst | dmenu`
case $str in
    "") exit 1;;
    "mail") str="sylpheed";;
    "files") str="urxvt -e ranger .";;
    *);;
esac

$str &

mymenu.lst -- add apps as you require; if you want to add a reference to an app by a different name, change the "case" statement in the script to accommodate (see mail=sylpheed).

iceweasel
luakit
viewnior
leafpad
mail
truecrypt
files

(not really a CLI utility I guess, but handy)

Last edited by pidsley (2012-06-26 13:29:59)

Offline

#46 2012-06-07 22:30:30

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 3,909

Re: [Closed] post your handy command-line utilities

Here's another one I just put together, after discovering there's burning tools specialised for CD and DVD.

# BURN CD/DVD
# usage burn [cd/dvd] /path/to/file.iso
burn ()
{
  case $1 in
    cd)   wodim -eject -tao speed=1 dev=/dev/sr0 -v -data "$2" ;;
    dvd)  growisofs -dvd-compat -Z /dev/sr0="$2" ;;
  esac
}

And to blank your DVD or CD:

alias blank='dvd+rw-format /dev/sr0'

Don't remember to edit /dev/sr0 to match your setup. Also, you can add -force to the blank alias to enable forcing (duh roll)

Last edited by Unia (2012-06-07 22:33:37)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
Github

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#47 2012-06-08 00:17:52

gutterslob
#! Resident Bum
Registered: 2009-11-03
Posts: 3,043

Re: [Closed] post your handy command-line utilities

Another CD Ripper/Burner from GRML's excellent zsh resource.

# Rip an audio CD
audiorip() {
    mkdir -p ~/ripps
    cd ~/ripps
    cdrdao read-cd --device $DEVICE --driver generic-mmc audiocd.toc
    cdrdao read-cddb --device $DEVICE --driver generic-mmc audiocd.toc
    echo " * Would you like to burn the cd now? (yes/no)"
    read input
    if [[ "$input" = "yes" ]] ; then
        echo " ! Burning Audio CD"
        audioburn
        echo " * done."
    else
        echo " ! Invalid response."
    fi
}

# Burn an audio CD (in combination with audiorip)
audioburn() {
    cd ~/ripps
    cdrdao write --device $DEVICE --driver generic-mmc audiocd.toc
    echo " * Should I remove the temporary files? (yes/no)"
    read input
    if [[ "$input" = "yes" ]] ; then
        echo " ! Removing Temporary Files."
        cd ~
        rm -rf ~/ripps
        echo " * done."
    else
        echo " ! Invalid response."
    fi
}

# Make an audio CD from all mp3 files
mkaudiocd() {
    # TODO: do the renaming more zshish, possibly with zmv()
    emulate -L zsh
    cd ~/ripps
    for i in *.[Mm][Pp]3; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
    for i in *.mp3; do mv "$i" `echo $i | tr ' ' '_'`; done
    for i in *.mp3; do mpg123 -w `basename $i .mp3`.wav $i; done
    normalize -m *.wav
    for i in *.wav; do sox $i.wav -r 44100 $i.wav resample; done
}

Last edited by gutterslob (2012-06-10 10:52:39)


Point & Squirt

Offline

#48 2012-06-10 03:45:55

notbird
Member
Registered: 2012-06-10
Posts: 10

Re: [Closed] post your handy command-line utilities

here's a couple bash functions I put together not too long ago:

for sync'ing one of my home folders to my home server or vice-versa:

#sync files to home with a clever pun
#USE: sink documents in
sink () {
    if [ $2 == 'in' ]
    then
        rsync -rv nth@192.168.1.39:/home/nth/$1/ /home/nth/$1
        return 0    
    elif [ $2 == 'out' ]
    then
        rsync -rv /home/nth/$1/ nth@192.168.1.39:/home/nth/$1
        return 0    
    else
        echo 'invalid arguments, try the dishwasher'
        return 1
    fi        
}    

it seems I've got to come up with a related function called dishwasher()

so xmonad will recognize console applications (like vim) and actually put them where I want them:

#give console apps a name 
#USE: trm vim (optional name here, otherwise name of app is name)
trm () {
    if [ $2 ]
    then
        terminator -T $2 -e $1 &
    else
        terminator -T $1 -e $1 &
    fi        
}

simple one, saves me a few seconds on long files (I know there's a shortcut to do this from within vim, but hey, I was bored this morning) :

#open vim to last line of file
vimend () {
    words=`wc -l $1`
    vim +$words
}

also, just a couple fun aliases (be ready with ctrl-C on the last one):

alias please="sudo"
alias fortune="fortune | cowsay"
#J A C K   I N
alias matrix='echo -ne "\e[32m" ; while true ; do echo -ne "\e[$(($RANDOM % 2 + 1))m" ; tr -c "[:print:]" " " < /dev/urandom | dd count=1 bs=50 2> /dev/null ; done'

Last edited by notbird (2012-06-10 03:46:53)

Offline

#49 2012-06-10 04:57:40

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 10,163
Website

Re: [Closed] post your handy command-line utilities

^ nice additions notbird, thanks for sharing them!


VSIDO | SolusOS

Words That Build Or Destroy

Offline

Be excellent to each other!

#50 2012-06-10 10:44:34

rhowaldt
#!*$%:)
Registered: 2011-03-09
Posts: 4,396

Re: [Closed] post your handy command-line utilities

@notbird:

alias please="sudo"

i like that big_smile

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo