You are not logged in.
Randomly colored urxvt terminal window:
#!/usr/bin/ python
import sys, os, random
r = random.randint(1000,8888)
g = random.randint(1000,8888)
b = random.randint(1000,8888)
os.system("urxvt -depth 32 -bg rgba:" + str(r) + "/" + str(g) + "/" + str(b) + "/0000")
Offline
Not really a utility but a trick that I often use when I'm too lazy to write a (bash) script:
a_very_very_long_and_complex_command #tag
After that I can retrieve the command by typing:
^R#tag
The point is about labeling commands for easy retrieval so that you don't have to recall parts of the command that uniquely identify it.
That's a nice one!
I use this a lot
$ cat .inputrc
"\e[A":history-search-backward
"\e[B":history-search-forward
up and down keys scroll the history. Easy to find screen -raAd from history. $ sc(uparrow once or twice)
Offline
Daenyth wrote:karabaja4 wrote:for atheros wireless cards - script to download & install newest madwifi revision from 0.9.4.1 branch (trunk revisions are somewhat slow for me).
Why not use the madwifi-svn package?
Well look at that
didn't know it was there. Anyway, its madwifi-hal-testing branch, I have no idea how it performs against 0.9.4.1 (btw 0.9.4.1 out-performs trunk by alot, why is this?). Will test and report back.
P.S. I'm also kinda more at peace with "make && make install" method
EDIT: It performs exacly the same... interesting ^^
---
Sorry for offtopic, but can you share your bashrc?
Offline
Who exactly? Mine is in my sig.
[git] | [AURpkgs] | [arch-games]
Offline
Sorry for offtopic, but can you share your bashrc?
Mine? I have almost none:
# Check for an interactive session
[ -z "$PS1" ] && return
alias ls='ls --color=auto'
PS1='[deadbeef \W]\$ '
P.S. Ehm, really, I must ask, why you want to have every single config exacly like me? There isn't a config file you didn't ask me to upload . Not that I mind sharing, but you should really try to make your own configuration that you like best and that best suits your needs and habits.
Offline
I use this to quickly scan my syslogs for errors. Kinda crude but it works. It searches for lines with todays date, except for Xorg.0.log which has no date field.
export LC_TIME="POSIX"
sudo egrep -ri "$(date '+%b %e')"'.*(missing|error|fail|(no |not |in)valid|fatal|corrupt|warning|wrong|illegal| fault|caused)' /var/log/* | sort -u
sudo egrep -iH '(missing|error|fail|(no |not |in)valid|fatal|corrupt|warning|wrong|illegal| fault|caused|\(EE\)|\(WW\))' /var/log/Xorg.0.log | sort -u
B.t.w. How about putting up some kind of vote for the best scripts in this thread, maybe per category (files, networking, general ..)?
Last edited by rwd (2009-12-04 15:35:46)
Offline
Who needs AutoFS? Background this!
inotifywait -qm --event CREATE --format %f /dev | while read disk; do
if [[ -b /dev/$disk ]] && [[ ${disk:0:2} == 'sd' ]] && [[ ${disk:(-1)} == [[:digit:]] ]]; then
sleep 1
devkit-disks --mount /dev/$disk
fi
done
Offline
note: a uzbl-script
this'll take you back to the most recent and different domain. let me explain.
say you google something, follow a link, navigate about that site for 12 or so pages, then you want to go back to the google results directly... bind this script to gb.
or let's say you click a screenshot link out of bbs.archlinux.org, navigate about deviantart for 10 or so pages, then you want to go back to the forums... that keybind will take you back to the most recent history entry for bbs.archlinux.org i.e. that forum post that you originally navigated away from.
i find it comes in handy.
#!/bin/bash
#
# pbrisbin 2009
#
###
uzbl_sok="$5" # our socket
curr_url="$6" # our url
history_file="$XDG_DATA_HOME/uzbl/history" # our history file
[ ! -f "$history_file" ] && exit 1
# print the history file in reverse, strip to just urls
tac "$history_file" | awk '{print $3}' | while read this_url; do
# strip to just the domain
curr_domain=$(echo $curr_url | cut -d '/' -f 3)
this_domain=$(echo $this_url | cut -d '/' -f 3)
# find the next entry from a different domain
if [ "$this_domain" != "$curr_domain" ]; then
echo uri $this_url | socat - unix-connect:$uzbl_sok &
break
fi
done
Last edited by brisbin33 (2009-12-04 16:16:25)
//github/
Offline
Who needs AutoFS? Background this!
Great! I was looking for something like this to do automounting in WindowMaker. I'll put the code in a file called "simple-automount" and start it at boot. Then I'll add a "live" item to the WindowMaker root menu to show me the contents of "/media".
By the way, how do you handle unmounting?
Offline
falconindy wrote:Who needs AutoFS? Background this!
Great! I was looking for something like this to do automounting in WindowMaker. I'll put the code in a file called "simple-automount" and start it at boot. Then I'll add a "live" item to the WindowMaker root menu to show me the contents of "/media".
By the way, how do you handle unmounting?
I should really make some aliases this handle this. For now its either 'sudo umount /dev/wutev' or 'devkit-disks --unmount /dev/yada/yada/why/am/i/still/typing'
I don't mind the fact that this ignores my DVD drive because its not hard to type `mount /dev/dvd`.
edit: dont start it at boot. there's some finicky business about when this will and won't work. my testing shows:
from a tty: fail
from screen: fail
from xinitrc: fail
from a straight terminal session: win!
Which means that it needs to be started manually. I wonder if I can source the .Xauth file and do it that way.... hmmmmm....
Last edited by falconindy (2009-12-04 18:43:23)
Offline
Maybe there's some dbus session related issue from starting it early?
[git] | [AURpkgs] | [arch-games]
Offline
i'd try from rc.local:
( sleep 30 && su -c 'bash -cl \'command_to_start_as_me_in_a_login_shell\'' username ) &
note: wholely untested and will likely need tweaking... but you get the idea.
//github/
Offline
#!/bin/bash
echo $$ > ~/Tmp/alarm
amixer set Master 23 > /dev/null
amixer set PCM 0 > /dev/null
mocp -U
x=0
y=0
while [ $x -le 5 ]
do
x=$(( $x + 1 ))
y=$(( $y + 30 ))
amixer set PCM $(($x * 2)) > /dev/null
beep -f $((360+$y))
echo $(( $y + 360 ))'Hz'
sleep 10s
y=$(( $y + 30 ))
beep -f $((360+$y))
sleep 10s
done
date
~/Code/bash/beep
Code/bash/beep:
!/bin/bash
echo $$ > Tmp/alarm
while [ 1 ]
do
x=$[ ( $RANDOM % 4900 + 100 ) ]
echo -n $x','
beep -f $x &
sleep 0.2s
done
does get you up in the morning, especially if you put the keyboard downstairs
Offline
Not so much a "utility", but when using vim to edit PKGBUILD files, this will get rid of the old startdir/ junk
:%s/startdir\/\(pkg\|src\)/\1dir/g
[git] | [AURpkgs] | [arch-games]
Offline
here is a simple application launcher i wrote a while ago, it was inspired by a screen manager that i found in this thread a while ago.
In relation to zenity and launchers - I was disappointed that zenity didn't have the ability to create pop-up menus. I did like to use the list form for launching stuff. For this reason I created this script:
http://pastebin.com/f6ec7eb1a
Called like this:
python PyMenu.py browser:firefox editor:gedit:gtk-edit "file manager":nautilus:gtk-harddisk
it opens a pop-up menu under the mouse. The format is label:command[:gtk_stock_id]
EDIT: Of course requires python and pygtk.
Last edited by spupy (2009-12-05 17:11:55)
There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.
Offline
just a small code for getting no. of files & directories in a directory using tree.
might be available with another piece of code but i was unable to find it.
files() {
if [ ! -z "$1" ]; then
echo "==> $(tree "$1" &> /dev/null | tail -1) [$(du -hs "$1" | cut -f1)]"
else
echo "==> $(tree "$(pwd)" &> /dev/null | tail -1) [$(du -hs "$(pwd)" | cut -f1)]"
fi
}
i use it as a function
Last edited by vik_k (2009-12-06 06:56:47)
"First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack." ~ George Carrette
Offline
just a small code for getting no. of files & directories in a directory using tree.
might be available with another piece of code but i was unable to find it.files() { if [ ! -z "$1" ]; then echo "==> $(tree "$1" &> /dev/null | tail -1) [$(du -hs "$1" | cut -f1)]" else echo "==> $(tree "$(pwd)" &> /dev/null | tail -1) [$(du -hs "$(pwd)" | cut -f1)]" fi }
i use it as a function
Wouldn't it be easier to just use:
files(){ set ${1:-$PWD}; echo "==> $(tree "$1" | tail -1) [$(du -hs "$1" | cut -f1)]"; }
EDIT: I just stole this for my bashrc, regardless.
Last edited by GraveyardPC (2009-12-06 07:51:55)
Offline
Stuff from my .zsh_functions, sourced by .zshrc:
md5name()
{
if [[ -f $1 ]]; then
while [[ -f $1 ]]; do
mv $1 ${$(md5sum $1)[1]}.${1##*.}
shift
done
else
echo "$0: Provide at least one input file, you lemonade head."
fi
}
fiximageexts()
{
zmv '(*).(#i)(jpeg|jpg)' '$1.jpg'
zmv '(*).(#i)(gif)' '$1.gif'
zmv '(*).(#i)(png)' '$1.png'
zmv '(*).(#i)(bmp)' '$1.bmp'
}
mktar7z()
{
echo "Encrypt?"
read enc
tar cf - $argv[2,-1] | 7z a -si $1 `[[ ! -z $enc ]] && echo "-p$enc"`
}
getip()
{
curl http://whatismyip.org/ 2>/dev/null|xclip -i
}
Last edited by JohannesSM64 (2009-12-06 08:07:01)
Offline
Your have() is useless...
Either write
have() { for i in "$@"; do type "$i" &>/dev/null || return 1; done; }
or simpler
have() { type "$@" &>/dev/null ; }
If or you want is ``true if and only if I have them ALL''
Edit: Found you edited it. nvm then.
Last edited by lolilolicon (2009-12-06 08:16:11)
This silver ladybug at line 28...
Offline
Wouldn't it be easier to just use:
files(){ set ${1:-$PWD}; echo "==> $(tree "$1" | tail -1) [$(du -hs "$1" | cut -f1)]"; }
EDIT: I just stole this for my bashrc, regardless.
got it!!!
"First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack." ~ George Carrette
Offline
<removed>
Last edited by rwd (2009-12-06 18:08:37)
Offline
threw this together last night while trying to get my various contact lists in order.
#!/bin/bash
IN='./vcard.vcf'
OUT='./mutt_alias_file'
awk -F ':' '/^FN:|^EMAIL/ {print $2}' "$IN" | while read entry; do
this="$entry"
# if this entry is an email and the last entry was not, then it's our
# primary email so print it.
if [ "$this" != "${this//@/}" -a "$last" = "${last//@/}" ]; then
echo "alias ${last// /_} $last <$this>" >> "$OUT"
fi
last="$entry"
done
//github/
Offline
Wrote this because I didn't find it in pkgtools. Prints files owned by a package:
#!/bin/bash
PACDB="/var/lib/pacman/local"
[[ -z $1 ]] && "Need a valid package to query" && exit 1
multifound() {
echo -e "${#pkgs[*]} packages found:\n"
for pkg in ${pkgs[*]}; do
printf " %s\n" $pkg
done
echo -e "\nPlease refine your search."
exit 0
}
listfiles() {
sed -n -e '/%FILES%/,/^$/p' $PACDB/$1-*/files | less
exit 0
}
pkgs=($(pacman -Qs $1 | grep -e ^local | cut -d\/ -f2 | cut -d\ -f1))
[[ $pkgs = $1 ]] && listfiles $1
case ${#pkgs[*]} in
0) echo "No package '$1' found" ;;
1) listfiles $1 ;;
*) multifound ;;
esac
Could likely be cleaner, but it works (so far). Pretty sure the check for an exact match is a filthy hack.
edit: fix pkg searching
Last edited by falconindy (2009-12-06 22:59:13)
Offline
Wrote this because I didn't find it in pkgtools. Prints files owned by a package:
`pkgfile -l`? You can also file feature requests if there's something you want pkgtools to do that it doesn't
[git] | [AURpkgs] | [arch-games]
Offline
What's wrong with "pacman -Ql"?
Offline