I use tramp to connect to my company's servers. I would like to customize my functions to work differently if I am accessing local files vs remote ones.
Is there a variable I could check if the buffer I am accessing is on a remote server or my local machine?
Something like:
if(TRAMP_CONNECTED)
Do this
else
Do that
First option - use command line to "query user /server:SERVERNAME" (or "quser.exe" - same thing). This shows User name, Session name, Session Id, Session state, Idle Time and Logon Time for all logged in users.
A ping from outside the remote network to the public IP address will tell you if the internet is up and the remote firewall is working. A ping from inside the remote network will tell you if the intranet is up and if the server is responding. If you can't ping it, then the server or the network is down.
The most robust check is likely default-directory
. This variable is always set buffer local. If (file-remote-p default-directory)
returns non-nil, your buffer is under Tramp control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With