Tag Archives: shell

Emacs with Tramp using zsh

First off, I recommend reading the relevant parts of the user manual, you might find the answer there.

Now, to the issue.

I installed tramp and added this to ~/.emacs:

(require 'tramp)
(setq tramp-default-method "scp")

Nothing special here, except it didn’t work. (The message was something like “waiting 60s for local shell”. Of course, I didn’t write it down, and it got lost in the browsing cache.)

So I turned on more verbose debugging, in ~/.emacs also:

(setq tramp-debug-buffer t)
(setq tramp-verbose 10)

The “logs”, mind you, are written into buffers: *debug/scp remotehost* are the messages and *tramp/scp remotehost* is the medium-rare (as compared to raw) data received.

If you open the latter and see characters like ^]]C4 or ^M, then it might be due to the shell prompt setting on the remote host. The manual advises wisely as to what should be considered.

One solution found floating on the internets is checking for the terminal type. Add this to the remote host’s .zshenv:

if [ "$TERM" = "dumb" ]
unsetopt zle
unsetopt prompt_cr
unsetopt prompt_subst
# unfunction precmd # these two are not
# unfunction preexec # working for me
PS1='$ '

Also, make sure you’re not re-setting it somewhere else later, say .zshrc. A check should be enough even if you do:

if [ "$TERM" != "dumb" ]; then
# Set prompts
PROMPT='%m%# '


csh: Cannot open /etc/termcap

Upon logging into my remote server with ssh, I started getting:

csh: Cannot open /etc/termcap.
csh: using dumb terminal settings.

There is no rxvt-unicode entry in /etc/termcap. You should specify one, but if you’re lazy, you can just

setenv TERM xterm

in your ~/.cshrc.

P.S. Nah, this doesn’t help. You have to put that line in /etc/csh.cshrc (via).

Copying music to USB flash from command line, fast

Thanks to this post.

EDIT: This doesn’t work well.

# Script to copy music to media player (USB).

# remove the last character
var=`echo $*|sed s/.$//`

echo "Copying: $var"

# now copy
cp -R "$var" /mnt/player/ &


Here’s something annoying: when you have to copy/move some files to another directory, and then cd there yourself. Written scripts to do that faster: grab:



for item in `echo $@`; do
	echo $dir/$item >> ~/tmp/grab

And drop:



echo "" > $tempfile				# create if missing

for item in `cat ~/tmp/grab`; do
	mv $item . 2> /dev/null
	if [ $? -ne 0 ]; then			# was some trouble
		echo $item >> $tempfile
		echo "Cannot move: $item"

mv $tempfile $grabfile

Also, added a lose script, which merely deletes ~/tmp/grab for now.