- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Alias for ^P
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2007 05:26 AM
08-03-2007 05:26 AM
Alias for ^P
I've been something rather weird at work.
My boss wants me to find out how I can setup an alias that would call up my history file, much like a ^P would do..
like this:
cup = previous command...
cdn = next command...
Is this even duable? Can this be done?
Thanks. Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2007 07:56 AM
08-03-2007 07:56 AM
Re: Alias for ^P
alias h='fc -l'
So
h (from the command line prompt)
Shows the last N commands.
From the keyboard, [esc]k goes back through the list, and [esc]j goes forward from where [esc]k left off.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2007 02:34 PM
08-03-2007 02:34 PM
Re: Alias for ^P
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 12:52 AM
08-08-2007 12:52 AM
Re: Alias for ^P
Bill, you haven't posted the attachement / your script you're talking about.. I can't see it at least...
Thanks. Patrifck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 01:12 AM
08-08-2007 01:12 AM
Re: Alias for ^P
Mark Syder (like the drink but spelt different)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 01:24 AM
08-08-2007 01:24 AM
Re: Alias for ^P
Okay, I was kinda of embarrassed to say this... but here's the scope of the request :
it's my damn boss who wants this for his blackberry. He wants to be able to do this in his SSH client within the blackberry. I know.. it's freaking stupid if you ask me!! All this just because he doesn't want to have to hit a few more keys to get the special character (i.e. ESC or CTRL)...
I told him I'd quickly looked into it, but I won't try to reinvent the wheel here...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 02:10 AM
08-08-2007 02:10 AM
Re: Alias for ^P
Sounds like your boss has seen "bash". it can do this. you would need to set him up so his login shell is bash and then take a look at the inputrc and bashrc files. I used to have the settings to do this by I can't locate them. Basically, in the inputrc file you map the up-arrow (esc-[-something] to the command for one line back in history.
FWIW: these may be the default assignments w/ bash now, as they work on my redhat boxes and I haven't done any config of the rc files mentioned
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 02:14 AM
08-08-2007 02:14 AM
Re: Alias for ^P
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 02:23 AM
08-08-2007 02:23 AM
Re: Alias for ^P
#!/usr/bin/sh
# The h command - short for history
# Adapts to $LINES or $1 as needed
# make negative as required and reduce by 2 if no param used
# so evrything is shown including the last prompt line
if [ $# -gt 0 ]
then # specified line count
HISTLINES=$1
[ $HISTLINES -gt 0 ] \
&& let HISTLINES=HISTLINES*-1
else # use $LINES
[ $LINES -gt 5 ] \
&& let HISTLINES=0-$LINES+2 \
|| let HISTLINES=0-$LINES
fi
fc -l $HISTLINES
So your boss has shell access. Wow, I hope it is not a root user ID. Sounds like the boss still wants to be a sysadmin and not the boss. What you might offer is a menu script that replaces shell access. Then single characters can be used to run lots of command (limited in scope by prudent sysadmins that write restricted menu scripts).
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 02:31 AM
08-08-2007 02:31 AM
Re: Alias for ^P
To browse the history, you really need something that is _not_ considered a command and does not change what you're browsing.
To minimize the need of special keys, let me suggest something that may not seem very much 21th century... teach him to use the Vi mode of the shell! (set -o vi)
Using the Esc key is still required at some points: for example, to browse the command history, you need just one press of Esc to switch from "insert mode" to "history browsing mode", but after that single press of Esc you can use plain k/j keys to get previous/next command in the history file, and h/l to move left/right on the current command line.
If you're limited to whatever a "stock" HP-UX contains, this might be a good option for you. Your boss can enable the Vi mode himself whenever necessary, so you don't need to install any non-default shells or copy any special configurations to all hosts.
See also this thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=865134
It contains some examples for re-mapping keys with HP-UX sh/ksh.
I haven't had a chance to try out a BlackBerry (for some reason, Nokia Communicators are used instead here in Finland :-)
but I understand it has an ALT key in its keyboard. Find out - by experimentation, if necessary - what characters are produced by the BlackBerry's terminal emulator when Alt+
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 07:21 PM
08-08-2007 07:21 PM
Re: Alias for ^P
Mine is real short, the same as Michael's. ;-)
>Matti: teach him to use the Vi mode of the shell! (set -o vi)
Or he can use emacs mode and just type ^P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 12:43 AM
08-09-2007 12:43 AM
Re: Alias for ^P
I told my boss that he's going to live with having to fetch the CTRL + char in his blackberry! The hell with this! It's a freaking waste of time anyways!
Thank you all for your suggestions!! :)
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2007 05:51 AM
08-09-2007 05:51 AM