History for custom BASH function


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting History for custom BASH function
# 1  
Old 05-06-2009
Computer History for custom BASH function

Hello all, I have a bash function that opens Safari (I'm on OS X) with a specified argument.

Here it is :

Code:
function safari
{

#Safari bash function

TLDS=( "http://www."  ".com"  ".org"  ".net"  ".gov"  ".edu" )

if [ $1 = "-o" ]; then
open -a Safari ${TLDS[0]}$2${TLDS[2]} 
	elif [ $1 = "-n" ]; then
	open -a Safari ${TLDS[0]}$2${TLDS[3]}
		elif [ $1 = "-g" ]; then
		open -a Safari ${TLDS[0]}$2${TLDS[4]}
			elif [ $1 = "-e" ]; then
			open -a Safari ${TLDS[0]}$2${TLDS[5]}
				elif [ $1 = "-c" ]; then
				open -a Safari ${TLDS[0]}$2${TLDS[1]}
					else
					open -a Safari ${TLDS[0]}$1${TLDS[1]}
fi

}

I don't have a problem with the function, but I would like to know if my function can have a command history, like after each argument is taken, is it possible that i could write it to a file for later retrieval?

for example after a ( this is my prompt ) :

(%) ~ <-- safari arstechnica // opens Safari @ arstechnica.com

(%) ~ <-- safari ars[TAB] // completes as arstechnica after reading file

Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print smallest integer from file using awk custom function?

`awk` function looks like this in a file name `fun.awk`: { print small() } function small() { a=$0 smal=0 for(i=1;i<=3;i++) { if( a<a) smal=a else (4 Replies)
Discussion started by: lazerz
4 Replies

2. OS X (Apple)

I have a backdoor in my OS X? This is what I found in my bash history

That's what appears at the beginning of my bash history (when you type "open .bash_history" in terminal) sudo -k export PS1="";sudo echo AUTHENTICATED;echo RETRY exit export PS1="" sudo echo AUTHENTICATED ; sudo -k ; echo AUTHENTIKILL ; echo PROCESSEDAUTHENTICATION sudo ls;sudo -k;exit;echo... (1 Reply)
Discussion started by: jonathansmith
1 Replies

3. Shell Programming and Scripting

[Bash] Read History function & Read Arrowkeys

Hi. How can I create a history function? (By "read" command or so) & How can I configure a read command so that the arrow keys are not displayed so funny? (^[[A) Thanks in advance. (4 Replies)
Discussion started by: sinnlosername
4 Replies

4. Shell Programming and Scripting

Change / Setup bash custom prompt (PS1)

I am trying to create my custom prompt and I have almost succeeded. Right now I have PS1='\n\\$\ ' What I have not figured out is how to make the directories bold when I'm using commands ls or ls -la. Any idea how to do it??? Many thanx. (2 Replies)
Discussion started by: emailkia
2 Replies

5. Shell Programming and Scripting

Increase bash history size

Hi I am trying to increase the number of commands recorded in my .bash_history file. I followed what is indicated and have add to my .bashrc export HISTCONTROL=ignoreboth export HISTSIZE=1000000 export HISTFILESIZE=1000000 export HISTIGNORE='ls'but the .bash_history only contains 690... (5 Replies)
Discussion started by: louisJ
5 Replies

6. Shell Programming and Scripting

export bash history to file

Hi, I want to export bash history to a file, I used the following command history > /home/administrator/bashHistory But the exported file only contains commands with line number from 996 to the last one, How to export all the commands including commands before line 996? Thanks a lot.... (2 Replies)
Discussion started by: Roy987
2 Replies

7. Shell Programming and Scripting

bash history buffer cache

Moderators, Please excuse if I am in the wrong section. I have a question that someone may know the answer to. We know that a current bash shell keeps a record of all commands in a buffer. When the shell is terminated this buffer is written out to ~/.bash_history for the user. I know... (2 Replies)
Discussion started by: jaysunn
2 Replies

8. UNIX for Dummies Questions & Answers

AIX bash history recall

Is it possible to use the keyboard UP ARROW in place of k to recall history? If so, how/what do I need to do change terminal emulation, etc.? TIA, George (7 Replies)
Discussion started by: gwfay
7 Replies

9. UNIX for Dummies Questions & Answers

bash history - each session in different file

Hello How to configure, or where to have each session history in different file Example: someone is connecting as root and at this time is creating file in which we have history of executed command to server is connecting another user and is created another file with command executed by... (1 Reply)
Discussion started by: vikus
1 Replies

10. Shell Programming and Scripting

Mimic bash history behavior

Does anyone know of a way to mimic the up arrow/down arrow type bash behavior within a shell script? Say I have a scripted menu, and would like to be able to up arrow to bring up the last X number of lines of user input? Thanks to anybody with a suggestion. :) (0 Replies)
Discussion started by: sysera
0 Replies
Login or Register to Ask a Question