Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write eshell script?

Tags:

emacs

eshell

there. I'm new to eshell,and now i come to a problem that how can i script it. i've tried (rm ~/somefile) and it worked.so is every command like this?how should i write conditional code and loop?and what should i customize to make the system execute my script using eshell other than others ,like bash,by default? i'm not very good at english,and i hope you can understand what i mean.i'll also appreciate any correction to my english expression?

like image 776
hq.wrong Avatar asked Feb 10 '11 05:02

hq.wrong


People also ask

Is shell Scripting easy?

A shell script have syntax just like any other programming language. If you have any prior experience with any programming language like Python, C/C++ etc. it would be very easy to get started with it.

What is shell script with example?

A shell script is a list of commands in a computer program that is run by the Unix shell which is a command line interpreter. A shell script usually has comments that describe the steps. The different operations performed by shell scripts are program execution, file manipulation and text printing.

How do I write a shell script in Windows?

Open Command Prompt and navigate to the folder where the script file is available. Type Bash script-filename.sh and hit the enter key. It will execute the script, and depending on the file, you should see an output.


1 Answers

You can call any elisp command/function/operator from eshell; I suppose that means you can script it using elisp (See GNU Emacs Lisp Reference manual). Example:

Welcome to the Emacs shell

~ $ (defun foo (n) (if (= 0 (mod n 2)) "Even." "Odd!"))
foo
~ $ foo 2
Even.
~ $ foo 3
Odd!
~ $ 
like image 158
huaiyuan Avatar answered Oct 02 '22 16:10

huaiyuan