Bug 23394

Summary: tune shells for term.el
Product: Branch 4.1 Reporter: Ivan Zakharyaschev <imz>
Component: emacs22-commonAssignee: Nobody's working on this, feel free to take it <nobody>
Status: CLOSED WONTFIX QA Contact: qa-4.1 <qa-4.1>
Severity: enhancement    
Priority: P3    
Version: unspecified   
Hardware: all   
OS: Linux   

Description Ivan Zakharyaschev 2010-04-28 06:16:06 MSD
emacs22-common-22.2-alt5


The commentaries in term.el.bz2 describe how shells could be tuned to work better with term. An independent package with this shell startup setup could be made: not dependent on the Emacs package, so that it could be used on remote systems accessed through Emacs.

The commentaries:

;;;  With this enhanced ansi-term.el you will get a reliable mechanism of
;;; directory/username/host tracking: the only drawback is that you will
;;; have to modify your shell start-up script.  It's worth it, believe me :).
;;;
;;; When you rlogin/su/telnet and the account you access has a modified
;;; startup script, you will be able to access the remote files as usual
;;; with C-x C-f, if it's needed you will have to enter a password,
;;; otherwise the file should get loaded straight away.
;;;
;;; This is useful even if you work only on one host: it often happens that,
;;; for maintenance reasons, you have to edit files 'as root': before
;;; patching term.el, I su-ed in a term.el buffer and used vi :), now I
;;; simply do a C-x C-f and, via ange-ftp, the file is automatically loaded
;;; 'as-root'.

....


;;;  Notice: for directory/host/user tracking you need to have something
;;; like this in your shell startup script ( this is for tcsh but should
;;; be quite easy to port to other shells )
;;;
;;;             ----------------------------------------
;;;
;;;
;;;  	 set os = `uname`
;;;  	 set host = `hostname`
;;;  	 set date = `date`
;;;
;;;  # su does not change this but I'd like it to
;;;
;;;  	 set user = `whoami`
;;;
;;;  # ...
;;;
;;;  	 if ( eterm =~ $TERM ) then
;;;
;;;  		echo --------------------------------------------------------------
;;;  		echo Hello $user
;;;  		echo Today is $date
;;;  		echo We are on $host running $os under Emacs term mode
;;;  		echo --------------------------------------------------------------
;;;
;;;  		setenv EDITOR emacsclient
;;;
;;;   # Notice: $host and $user have been set before to 'hostname' and 'whoami'
;;;   # this is necessary because, f.e., certain versions of 'su' do not change
;;;   # $user, YMMV: if you don't want to fiddle with them define a couple
;;;   # of new variables and use these instead.
;;;   # NOTICE that there is a space between "AnSiT?" and $whatever NOTICE
;;;
;;;   # These are because we want the real cwd in the messages, not the login
;;;   # time one !
;;;
;;; 		set cwd_hack='$cwd'
;;; 		set host_hack='$host'
;;; 		set user_hack='$user'
;;;
;;;   # Notice that the ^[ character is an ESC, not two chars.  You can
;;;   # get it in various ways, for example by typing
;;;   # echo -e '\033' > escape.file
;;;   # or by using your favourite editor
;;;
;;; 		foreach temp (cd pushd)
;;; 			alias $temp "$temp \!* ; echo 'AnSiTc' $cwd_hack"
;;; 		end
;;;   		alias popd 'popd ;echo "AnSiTc" $cwd'
;;;
;;;   # Every command that can modify the user/host/directory should be aliased
;;;   # as follows for the tracking mechanism to work.
;;;
;;; 		foreach temp ( rlogin telnet rsh sh ksh csh tcsh zsh bash tcl su )
;;; 			alias $temp "$temp \!* ; echo 'AnSiTh' $host_hack ; \
;;; 					echo 'AnSiTu' $user_hack ;echo 'AnSiTc' $cwd_hack"
;;; 		end
;;;
;;;   # Start up & use color ls
;;;
;;; 		echo "AnSiTh" $host
;;; 		echo "AnSiTu" $user
;;; 		echo "AnSiTc" $cwd
;;;
;;;   # some housekeeping
;;;
;;; 		unset cwd_hack
;;; 		unset host_hack
;;; 		unset user_hack
;;; 		unset temp
;;;
;;; 		eval `/bin/dircolors /home/marco/.emacs_dircolors`
;;;    endif
;;;
;;;  # ...
;;;
;;;  # Let's not clutter user space
;;;
;;;  	 unset os
;;;  	 unset date
;;;
;;;
Comment 1 Michael Shigorin 2014-11-05 20:43:19 MSK
В 4.1/branch исправления не будут вноситься уже технически (заглушена очередь на сборку), поэтому прошу ошибки, актуальные для sisyphus/p7/t7, перевесить на текущие ветки или сизиф.