What's the command for "Xterm here"?

Booting, installing, newbie
Post Reply
Message
Author
ghostshadow189
Posts: 34
Joined: Thu 24 Nov 2005, 05:06

What's the command for "Xterm here"?

#1 Post by ghostshadow189 »

I want to know what's the command used in command "Xterm here" ? I used rxvt -e cd /usr/share , but it disappear immediately
thanks :D

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#2 Post by MU »

cd /usr/share && rxvt
or
a=`pwd`;cd /usr && rxvt && cd $a&

If you want to run other commands like "ls":
If you use rxvt, you can use a wrapper:

Code: Select all

#!/bin/bash

#------------------------------------------------
#-- start in a new console-window
#------------------------------------------------

if [ "$1" != "rxvt" ];then

  rxvt -title bc -sb -cr green -bg yellow -geometry 30x10+200+200 -e $0 rxvt $@&
  exit 0

fi

cmd=`echo $@|sed "s/^rxvt//"` 
$cmd

read a
Save as "/usr/local/bin/myrxvt"
Make it executable:
chmod 755 /usr/local/bin/myrxvt

Test it:
myrxvt ls

A new rxvt will open running your command.
The "read a" waits for a keypress before exiting.

You can achive this "inbuilt" with the "real" Xterm:
http://dotpups.de/dotpups/XServer/xterm.pup (313 kb)

Usage:
xterm -hold -e ls

Mark

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#3 Post by MU »

Image

Small Diskmonitor:

Code: Select all

#!/bin/bash

#------------------------------------------------
#-- start in a new console-window
#------------------------------------------------

if [ "$1" != "rxvt" ];then

  rxvt -title diskfree +sb -cr yellow -bg yellow -geometry 20x2+200+200 -e $0 rxvt&
  exit 0

fi

#clear

a=`df -m | grep "/root" | sed "s/[^ ]*%.*$//" | sed "s/ *$//"| sed "s/[^ ]* //g"`
echo $a MB free on /root

sleep 10

exec $0 rxvt
8)

I just did not find out how to suppress the linefeed, then you could make it just 1 line high.

Mark

ndujoe1
Posts: 851
Joined: Mon 05 Dec 2005, 01:06

terminal commands

#4 Post by ndujoe1 »

Thanks for posting that example of using linux commands. Interesting and useful.

User avatar
jmarsden
Posts: 265
Joined: Sat 31 Dec 2005, 22:18
Location: California, USA

#5 Post by jmarsden »

MU wrote:I just did not find out how to suppress the linefeed, then you could make it just 1 line high.
Stuff the result into a variable and output it using echo -n

Here's my "improved" version, using awk not grep and sed for clarity, using variables not "magic numbers" for config settings, and allowing the user to specify which mountpoint to monitor.

Code: Select all

#!/bin/sh
# diskfree -- a minimalist disk freespace monitor using rxvt

RCFILE=".diskfreerc"    # Name of per-user rc file

# Set default configuration
DEFAULTDIR="/root"      # Default mount point
DELAY=10                # Seconds to delay between df invocations
DFFIELD=4               # Which field of df output to display
ROWS=1                  # Height of terminal window in characters
COLUMNS=22              # Width of terminal window in characters
XOFFSET=200             # Horizontal offset of window
YOFFSET=200             # Vertical offset of window
BGCOLOR="yellow"        # Window background color
CURSORCOLOR="$BGCOLOR"  # Cursor color in window
FGCOLOR="black"         # Window foreground (text) color
TERMINALPROG="rxvt"    # Which terminal program to use

usage() { echo $0: Usage is $0 [ mountpoint ] ; exit 1 ;}

# Override defaults from rc file if present
[ -f ~/$RCFILE ] && . ~/$RCFILE

# Set mountpoint to monitor
DIR="$1"
[ -z "$DIR" ] && DIR="$DEFAULTDIR"

# The mountpoint really must be a directory
[ -d "$DIR" ] || usage

# cmd string is interpreted twice: in it initial creation and in rxvt sh
# Therefore, quoting and escaping really matters within it.
cmd="while true
do
  # Extract the Available number from df output
  available=\`df -m $DIR |awk '/^\// {print \$$DFFIELD}'\`
  echo -ne '\n'\$available MB free on $DIR
  sleep $DELAY
done"
#echo "cmd is $cmd"

# Now run terminal program and execute cmd within it
$TERMINALPROG -title "$DIR" +sb -cr $CURSORCOLOR -bg $BGCOLOR -fg $FGCOLOR \
  -geometry ${COLUMNS}x${ROWS}+$XOFFSET+$YOFFSET -e sh -c "$cmd"
Jonathan

ghostshadow189
Posts: 34
Joined: Thu 24 Nov 2005, 05:06

#6 Post by ghostshadow189 »

Thanks so much :wink:

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#7 Post by MU »

ah great, thanks Jonathan :)

Post Reply