unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* hostname and filename as frame title
@ 2010-02-12  8:46 Suvayu Ali
  0 siblings, 0 replies; 6+ messages in thread
From: Suvayu Ali @ 2010-02-12  8:46 UTC (permalink / raw)
  To: Emacs mailing list

Hi everyone,

I do a lot of remote editing on several remote machines. I recently came 
across the variable `frame-title-format' and was wondering if there is a 
way to set the hostname of the file being edited and the file name as 
the frame title? Something like file@remote-host.

I don't even know where to start looking, any pointers would be awesome. :)

-- 
Suvayu

Open source is the future. It sets us free.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hostname and filename as frame title
       [not found] <mailman.1118.1265964419.14305.help-gnu-emacs@gnu.org>
@ 2010-02-12  9:35 ` Michael Albinus
  2010-02-12 10:50   ` Suvayu Ali
  2010-02-14 21:01   ` Suvayu Ali
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Albinus @ 2010-02-12  9:35 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: Emacs mailing list

Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:

> Hi everyone,

Hi,

>
> I do a lot of remote editing on several remote machines. I recently
> came across the variable `frame-title-format' and was wondering if
> there is a way to set the hostname of the file being edited and the
> file name as the frame title? Something like file@remote-host.
>
> I don't even know where to start looking, any pointers would be awesome. :)

What about this:

(setq-default
 frame-title-format
 '(:eval
   (format "%s@%s:%s"
	   (or (file-remote-p default-directory 'user) user-login-name)
	   (or (file-remote-p default-directory 'host) system-name)
	   (file-name-nondirectory (or (buffer-file-name) default-directory)))))

It needs Emacs 23.1, due to the parameters of file-remote-p.

Best regards, Michael.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hostname and filename as frame title
  2010-02-12  9:35 ` hostname and filename as frame title Michael Albinus
@ 2010-02-12 10:50   ` Suvayu Ali
  2010-02-12 11:58     ` Michael Albinus
  2010-02-14 21:01   ` Suvayu Ali
  1 sibling, 1 reply; 6+ messages in thread
From: Suvayu Ali @ 2010-02-12 10:50 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Emacs mailing list

Hi Michael,

On Friday 12 February 2010 01:35 AM, Michael Albinus wrote:
> Suvayu Ali<fatkasuvayu+linux@gmail.com>  writes:
>>
>> I do a lot of remote editing on several remote machines. I recently
>> came across the variable `frame-title-format' and was wondering if
>> there is a way to set the hostname of the file being edited and the
>> file name as the frame title? Something like file@remote-host.
>>
>> I don't even know where to start looking, any pointers would be awesome. :)
>
> What about this:
>
> (setq-default
>   frame-title-format
>   '(:eval
>     (format "%s@%s:%s"
> 	   (or (file-remote-p default-directory 'user) user-login-name)
> 	   (or (file-remote-p default-directory 'host) system-name)
> 	   (file-name-nondirectory (or (buffer-file-name) default-directory)))))

Works wonders! I am on Emacs 23.1. ;)

However because of all the different machines and different usernames, I 
rely on my ~/.ssh/config to specify the username on the remote machine. 
So I open a remote file like this,

`/ssh:remote-host-alias:/path/to/file'

Probably that is why the frame title shows up as,

`local-user@remote-host:file'

But I think I can live with that. Thanks a lot Michael. :)

>
> Best regards, Michael.

-- 
Suvayu

Open source is the future. It sets us free.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hostname and filename as frame title
  2010-02-12 10:50   ` Suvayu Ali
@ 2010-02-12 11:58     ` Michael Albinus
  2010-02-12 17:17       ` Suvayu Ali
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Albinus @ 2010-02-12 11:58 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: Emacs mailing list

Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:

> Hi Michael,

Hi,

> However because of all the different machines and different usernames, I 
> rely on my ~/.ssh/config to specify the username on the remote machine. 
> So I open a remote file like this,
>
> `/ssh:remote-host-alias:/path/to/file'
>
> Probably that is why the frame title shows up as,
>
> `local-user@remote-host:file'

Yes. Tramp does not know the application specific configuration.

> But I think I can live with that. Thanks a lot Michael. :)

So either you obmit the user part in the frame title (it is of no use
for you then), or you write your own small function which extracts it
from ~/.ssh/config.

Best regards, Michael.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hostname and filename as frame title
  2010-02-12 11:58     ` Michael Albinus
@ 2010-02-12 17:17       ` Suvayu Ali
  0 siblings, 0 replies; 6+ messages in thread
From: Suvayu Ali @ 2010-02-12 17:17 UTC (permalink / raw)
  To: Michael Albinus; +Cc: Emacs mailing list

On Friday 12 February 2010 03:58 AM, Michael Albinus wrote:
> Suvayu Ali<fatkasuvayu+linux@gmail.com>  writes:
>
>> Hi Michael,
>
> Hi,
>
>> However because of all the different machines and different usernames, I
>> rely on my ~/.ssh/config to specify the username on the remote machine.
>> So I open a remote file like this,
>>
>> `/ssh:remote-host-alias:/path/to/file'
>>
>> Probably that is why the frame title shows up as,
>>
>> `local-user@remote-host:file'
>
> Yes. Tramp does not know the application specific configuration.
>
>> But I think I can live with that. Thanks a lot Michael. :)
>
> So either you obmit the user part in the frame title (it is of no use
> for you then), or you write your own small function which extracts it
> from ~/.ssh/config.

Yes I ended up commenting that one out. :) Trying to write a function to 
extract the username from ~/.ssh/config would be a good exercise in lisp 
for a newbie like me. Thanks, I appreciate the help.

>
> Best regards, Michael.


-- 
Suvayu

Open source is the future. It sets us free.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hostname and filename as frame title
  2010-02-12  9:35 ` hostname and filename as frame title Michael Albinus
  2010-02-12 10:50   ` Suvayu Ali
@ 2010-02-14 21:01   ` Suvayu Ali
  1 sibling, 0 replies; 6+ messages in thread
From: Suvayu Ali @ 2010-02-14 21:01 UTC (permalink / raw)
  To: Emacs mailing list

On Friday 12 February 2010 01:35 AM, Michael Albinus wrote:
> Suvayu Ali<fatkasuvayu+linux@gmail.com>  writes:
>
>> Hi everyone,
>
> Hi,
>
>>
>> I do a lot of remote editing on several remote machines. I recently
>> came across the variable `frame-title-format' and was wondering if
>> there is a way to set the hostname of the file being edited and the
>> file name as the frame title? Something like file@remote-host.
>>
>> I don't even know where to start looking, any pointers would be awesome. :)
>
> What about this:
>
> (setq-default
>   frame-title-format
>   '(:eval
>     (format "%s@%s:%s"
> 	   (or (file-remote-p default-directory 'user) user-login-name)
> 	   (or (file-remote-p default-directory 'host) system-name)
> 	   (file-name-nondirectory (or (buffer-file-name) default-directory)))))
>

I ended up using something like this. This sets the frame-title to just 
the buffer-name for special buffers and uses the buffer name as set by 
uniquify when visiting files with same names. Maybe some one else will 
find this useful.

> (setq-default
>  frame-title-format
>  '(:eval
>    (if (string-match-p "^\\*.+\\*$" (buffer-name))
>        "%b"
>      (format "%s:%s"
> 	     (or (file-remote-p default-directory 'host) system-name)
> 	     (buffer-name)))))

:)
-- 
Suvayu

Open source is the future. It sets us free.




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-02-14 21:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1118.1265964419.14305.help-gnu-emacs@gnu.org>
2010-02-12  9:35 ` hostname and filename as frame title Michael Albinus
2010-02-12 10:50   ` Suvayu Ali
2010-02-12 11:58     ` Michael Albinus
2010-02-12 17:17       ` Suvayu Ali
2010-02-14 21:01   ` Suvayu Ali
2010-02-12  8:46 Suvayu Ali

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).