You are not logged in.
Sweet ... I wasn't familiar with xinput. But FYI, "Mouse" would need to be adjusted for laptops with touch/trackpads.
True: I hadn't seen it as general purpose, on my laptops synclient manages the touchpad.
I use this on my dekstop where I tend to accidentally brush against the mouse and the flickering reappearance of the cursor in the corner of my vision tends to induce a micro seizure or some other sort of mildly traumatic neurological event
Offline
I've crafted this after looking for a quick way to check my available free space of each HDD and the total free space. I would suggest putting it as an alias in you bashrc.
clear;echo "Drive Size Used Avail Use Mounted on";df -h|grep sd|column -t|sort && df -h --total|cut -c 1-11,17-37|tail -n1
Here's the output from my console
Drive Size Used Avail Use Mounted on
/dev/sda1 9.9G 5.5G 4.0G 58% /mnt/chakra
/dev/sda2 922G 779G 143G 85% /mnt/movies
/dev/sdb1 459G 215G 245G 47% /mnt/stuff
/dev/sdc1 2.8T 2.3T 501G 83% /mnt/media
/dev/sdd1 2.8T 2.3T 501G 83% /mnt/test
/dev/sde1 99M 27M 67M 29% /boot
/dev/sde3 12G 7.6G 3.7G 68% /
/dev/sde4 18G 3.0G 14G 18% /home
total 6.9T 5.5T 1.5T 80%
Offline
df -h --total --type=ext{2,3,4}
Add any other filesystem types you use.
Edit: ah, mine isn't sorted. Still, I think the original could be simplified quite a bit.
df -h --total --type=ext{2,3,4} | sort | awk 'BEGIN { print "Drive\tSize\tUsed\tAvail\tUse\tMount"; } /^[^F]/ { print $0;}'
Sorted.
Last edited by Trilby (2012-10-11 01:23:43)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I barely know how to use AWK so thats why I didn't use it. I didn't think the --type flag was necessary since I have a mix of EXT4 and XFS filesystems and it works just fine. Also your headers aren't directly over the columns. That was one of my pet peeves about my original version, hence the use of the echo line instead of df -h|head -n1
Your version doesn't show all my drives either....
[bran@ra ~]$ echo "Drive Size Used Avail Use Mounted on";df -h|grep sd|column -t|sort && df -h --total|cut -c 1-11,17-37|tail -n1
Drive Size Used Avail Use Mounted on
/dev/sda1 9.9G 5.5G 4.0G 58% /mnt/chakra
/dev/sda2 922G 779G 143G 85% /mnt/movies
/dev/sdb1 459G 215G 245G 47% /mnt/stuff
/dev/sdc1 2.8T 2.3T 501G 83% /mnt/media
/dev/sdd1 2.8T 2.3T 501G 83% /mnt/test
/dev/sde1 99M 27M 67M 29% /boot
/dev/sde3 12G 7.6G 3.7G 68% /
/dev/sde4 18G 3.0G 14G 18% /home
total 6.9T 5.5T 1.5T 80%
[bran@ra ~]$ df -h --total --type=ext{2,3,4} | sort | awk 'BEGIN { print "Drive\tSize\tUsed\tAvail\tUse\tMount"; } /^[^F]/ { print $0;}'
Drive Size Used Avail Use Mount
/dev/sda1 9.9G 5.5G 4.0G 58% /mnt/chakra
/dev/sdb1 459G 215G 245G 47% /mnt/stuff
/dev/sde1 99M 27M 67M 29% /boot
/dev/sde3 12G 7.6G 3.7G 68% /
/dev/sde4 18G 3.0G 14G 18% /home
total 498G 231G 266G 47%
Last edited by brando56894 (2012-10-11 05:44:03)
Offline
Merging with the venerable Command Line Utilities thread...
Offline
Thanks, I wasn't sure where this belonged.
Offline
@brando56894 & @Trilby: try findmnt.
'findmnt --fstab' prints in the order you have in /etc/fstab, so it can be sorted the way you want.
Brief output:
findmnt --fstab -o TARGET,SIZE,AVAIL,USE% -t noswap,notmpfs
TARGET SIZE AVAIL USE%
/boot 98,8M 73M 21%
/ 7,2G 2G 68%
/home 29,1G 1,6G 90%
Regular-sized output:
$ (findmnt --fstab -o SOURCE,SIZE,USED,AVAIL,USE%,TARGET -t noswap,notmpfs && df -h --total | tail -n1) | column -t
SOURCE SIZE USED AVAIL USE% TARGET
/dev/sda1 98,8M 20,7M 73M 21% /boot
/dev/sda3 7,2G 4,9G 2G 68% /
/dev/sda4 29,1G 26,1G 1,6G 90% /home
total 46G 36G 7,6G 83%
How to properly (i.e. right-aligned) format the middle columns, is left as an exercise for the reader ;P
Getting 'df -h --total' is less than elegant. Custom headers (or no headers at all) are possible but that one-liner would get even longer.
Offline
To save the tmpfile, something like this might work:
cupsfilter -i text/plain <(clip -selection clipboard -o)
Offline
So I'm not sure if this has been posted, but if you install the rfc package (`pacman -S rfc`), you can use this to open an rfc in less:
#!/bin/sh
# display an rfc in `less`
# you may want to install http://www.archlinux.org/packages/community/any/rfc/
# with `pacman -S rfc`
RFC_LOCATION="/usr/share/doc/rfc/txt/"
if [ $# -lt 1 ]; then
echo "Usage: \`$(basename $0) #\` (where # is the number of the rfc you want to see)"
exit
fi
rfc="$RFC_LOCATION/rfc$1.txt"
if [ ! -e $rfc ]; then
echo "rfc '#$1' not found"
exit
fi
less $rfc
For the lazy (myself included), you can put this in ~/bin with:
curl https://raw.github.com/gist/3902455/ -o ~/bin/rfc && chmod +x ~/bin/rfc
Then just:
rfc 2119
to see rfc #2119
Offline
I always run htop in my first Yakuake tab so now I just added this to the end of my .bashrc
# make first Yakuake instance run htop (unless htop is already running)
if [[ $( ps -o command $PPID |grep yakuake ) ]];
then
if [[ ! $(ps -a |grep "\<htop\>" ) ]];
then
htop
fi
fi
Offline
I'm not too sure about the logic, but the syntax can be simplied to something like:
ps -o command "$PPID" | grep yakuake && ps -a | grep "\<htop\>" || htop
Offline
I was absolutely certain someone was going to simplify it (which always happens when I share bash code).
Thanks
What do you mean you're not too sure about the logic?
Offline
pgrep can help
ps -o command "$PPID" | grep yakuake && pgrep -x htop || htop
I don't know what are you trying to do in
if [[ $( ps -o command $PPID |grep yakuake ) ]];
but maybe you can substitute it for some pgrep too.
Last edited by karol (2012-10-18 15:47:06)
Offline
What do you mean you're not too sure about the logic?
I mean I didn't stop to think about what it is you're doing. I just noticed the syntax could be simplified.
Offline
I don't know what are you trying to do in
if [[ $( ps -o command $PPID |grep yakuake ) ]];
but maybe you can substitute it for some pgrep too.
Now that I see it, the original version with the "ifs" works as intended. The simplified one-liners don't.
htop should only start if the parent process is Yakuake (the KDE drop-down terminal), not any kind of terminal. The simplified versions start htop in the first terminal that's opened, when htop isn't running.
Offline
pgrep can help
ps -o command "$PPID" | grep yakuake && pgrep -x htop || htop
I don't know what are you trying to do in
if [[ $( ps -o command $PPID |grep yakuake ) ]];
but maybe you can substitute it for some pgrep too.
Maybe this?
pgrep -s "$PPID" -x yakuake
Last edited by steve___ (2012-10-18 15:58:45)
Offline
karol wrote:I don't know what are you trying to do in
if [[ $( ps -o command $PPID |grep yakuake ) ]];
but maybe you can substitute it for some pgrep too.
Now that I see it, the original version with the "ifs" works as intended. The simplified one-liners don't.
htop should only start if the parent process is Yakuake (the KDE drop-down terminal), not any kind of terminal. The simplified versions start htop in the first terminal that's opened, when htop isn't running.
oops, try:
ps -o command "$PPID" | grep yakuake && { ps -a | grep "\<htop\>" || htop; }
Offline
The simplified versions start htop in the first terminal that's opened, when htop isn't running.
Is it possible to open yakuake and run htop, like
xterm -e htop
?
Offline
You mean have Yakuake run htop directly? Wouldn't that make it run every time I open a new tab in Yakuake?
@steve__: Thanks. The brackets did the trick!
Maybe this?
pgrep -s "$PPID" -x yakuake
pgrep -s "$PPID" always returns nothing.
Should it? pgrep only greps against process name. $PPID is the current process parent PID. It shouldn't be "pgreppable".
Last edited by achilleas.k (2012-10-18 16:12:28)
Offline
You mean have Yakuake run htop directly? Wouldn't that make it run every time I open a new tab in Yakuake?
I've installed yakuake and even --help-all doesn't tell me how can I do the equivalent of
urxvtc -pe tabbed -e htop
This code opens htop in the first tab of urxvt, you can bind it to an alias or keybinding and start urxvt that way or put it in ~/.xinitrc.
urxvtc -pe tabbed -e htop
exec dwm
Not sure if you want to do it this way.
I've tried the code you said you have in your .bashrc, but it didn't do anything.
Offline
Well the current state is
ps -o command "$PPID" | grep yakuake > /dev/null && { pgrep -x htop > /dev/null || htop; }
and that works exactly as intended, so I'll keep it there.
Offline
A little wrapper for get_iplayer, which I have saved as 'iplayernew', to list new programs and use less if necessary:
#!/bin/bash
TMPFILE=$(mktemp)
get_iplayer --refresh --force | grep Added | sed 's/Added: //' > $TMPFILE
LINECOUNT="$(cat $TMPFILE | wc -l)"
if [[ "$LINECOUNT" == "0" ]]; then
echo "No new programs"
elif [[ "$LINECOUNT" -lt "$(tput lines)" ]]; then
cat $TMPFILE
else
less $TMPFILE
fi
rm $TMPFILE
Last edited by owain (2012-10-26 21:15:21)
Offline
This will open the URL for a package:
#!/bin/sh
url=$(eval "expac '%u' $@ || expac -S '%u' $@")
if [ $? -eq 0 ]
then
xdg-open "$url"
else
echo 'Package not found.' 1>&2
exit 1
fi
Last edited by AaronBP (2012-10-27 09:49:49)
Offline