Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2014, 03:31 PM
CyrilMtl CyrilMtl is offline
Registered User
 
Join Date: Oct 2010
Posts: 7
Unhappy escape sequence to save and restore cursor position

I try to use the ESC[s to save the cursor position and ESC[u to restore it in my fancy unix prompt. It work on my linux terminal rxvt, on putty on windows, but not in securecrt (7.2.0 on linux).

Those ESC code are supported ? is a bug or a new feature I should request ?

Thanks

Cyril
Reply With Quote
  #2  
Old 01-21-2014, 03:52 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Cyril,

Would you post your fancy prompt so I can run some tests?

What Linux operating system are you using?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 01-21-2014, 04:04 PM
CyrilMtl CyrilMtl is offline
Registered User
 
Join Date: Oct 2010
Posts: 7
my PS1 is :
$ echo $PS1
\[\e]1;\u@\h:\w\007\e]2;\u@\h:\w\007\]\[\033[1m\]\[\033[s\]\[\033[400C\033[16D\]\[\033[38;5;59m\]\[[\]\[\033[38;5;173m\]\[\D{%m/%d} \]\[\033[38;5;167m\]\[\t\]\[\033[38;5;59m\]\[]\]\[\033[u\]\[\033[38;5;221m\]\u\[\033[38;5;59m\]@\[\033[38;5;81m\]\h \[\033[0m\]\[\033[38;5;188m\]\w\[\033[1m\]\[\033[38;5;47m\]\$ \[\033[0m\]

save the cursor position, it put the cursor on the right, back 16 spaces, put the date/time, restore the cursor position, write the basic prompt user, server, parh

On securecrt the cursor position isn't restored to the begin of the line so the prompt is put at the end of the date/time.

(it's on a RHEL6 server, my desktop where I run securecrt is a centos 6)

here is the little bash script if you want to do it :

function prompt_command {
local RETURN_CODE="$?"

local COLOR_P="\033[38;5;"
local COLOR_A="m"
if [ "$TERM" == "fbterm" ] ; then
COLOR_P="\033[1;"
COLOR_A="}"
fi
local SOFT_YELLOW="\[${COLOR_P}221$COLOR_A\]"
local MEDIUM_GRAY="\[${COLOR_P}59$COLOR_A\]"
local SOFT_BLUE="\[${COLOR_P}81$COLOR_A\]"
local LIGHT_GRAY="\[${COLOR_P}188$COLOR_A\]"
local LIGHT_GOLD="\[${COLOR_P}222$COLOR_A\]"
local MEDIUM_ORANGE="\[${COLOR_P}173$COLOR_A\]"
local MEDIUM_RED="\[${COLOR_P}167$COLOR_A\]"
local MEDIUM_GREEN="\[${COLOR_P}47$COLOR_A\]"
local BRIGHT_RED="\[${COLOR_P}196$COLOR_A\]"
local LIGHT_PURPLE="\[${COLOR_P}177$COLOR_A\]"
local RESET="\[\033[0m\]"
local BOLD="\[\033[1m\]"
local SAVE="\[\033[s\]"
local RESTORE="\[\033[u\]"

if [ "$TERM" == "linux" ] ; then
SOFT_YELLOW="\[\033[1;33m\]"
MEDIUM_GRAY="\[\033[1;30m\]"
SOFT_BLUE="\[\033[1;34m\]"
LIGHT_GRAY="\[\033[1;30m\]"
LIGHT_GOLD="\[\033[1;33m\]"
MEDIUM_ORANGE="\[\033[1;33m\]"
MEDIUM_RED="\[\033[1;31m\]"
MEDIUM_GREEN="\[\033[1;32m\]"
BRIGHT_RED="\[\033[1;31m\]"
LIGHT_PURPLE="\[\033[1;35m\]"
fi

local ALIGN_LEFT="\033[1G"
local ALIGN_RIGHT="\033[400C"
local MAKE_SPACE="\033[16D"

local DATE_STRING="\D{%m/%d}"
local TIME_STRING="\t"

local CURRENT_PATH="\w"
if [ -e ~/bin/shorten_pwd ] ; then
CURRENT_PATH=`~/bin/shorten_pwd`
fi

local TITLEBAR=""
case $TERM in
xterm*|*rxvt*|cygwin|interix|Eterm|mlterm|kterm|aterm|putty*)
if [ "${STY}" ] ; then
TITLEBAR="\[\ek\u@\h:$CURRENT_PATH\e\134\]"
else
TITLEBAR="\[\e]1;\u@\h:$CURRENT_PATH\007\e]2;\u@\h:$CURRENT_PATH\007\]"
fi
;;
toaru*)
TITLEBAR="\[\e]1;\u@\h:$CURRENT_PATH\007\]"
;;
screen*)
TITLEBAR="\[\ek\u@\h:$CURRENT_PATH\e\134\]"
;;
esac

local PROMPT_COLOR="$MEDIUM_GREEN"
if [[ ${EUID} == 0 ]] ; then
PROMPT_COLOR="$BRIGHT_RED"
fi

local PROMPT="$BOLD"
PROMPT="$PROMPT$SAVE\[$ALIGN_RIGHT$MAKE_SPACE\]" # Ram the cursor to the right, then back 16 spaces
PROMPT="$PROMPT$MEDIUM_GRAY\[[\]$MEDIUM_ORANGE\[$DATE_STRING \]$MEDIUM_RED\[$TIME_STRING\]$MEDIUM_GRAY\[]\]"
PROMPT="$PROMPT$RESTORE" # Reset the cursor to the left side
PROMPT="$PROMPT$SOFT_YELLOW\u$MEDIUM_GRAY@$SOFT_BLUE\h "

if [[ $RETURN_CODE != 0 ]] ; then
PROMPT="$PROMPT$MEDIUM_RED$RETURN_CODE "
fi

PROMPT="$PROMPT$RESET$LIGHT_GRAY$CURRENT_PATH$BOLD$PROMPT_COLOR\\\$ $RESET"
PS1="$TITLEBAR$PROMPT"
}

export PROMPT_COMMAND=prompt_command
Reply With Quote
  #4  
Old 01-21-2014, 04:46 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Thanks for the information Cyril.

Can you post a screenshot of how the prompt should appear, and how SecureCRT displays it?
NOTICE: The requested troubleshooting data may include sensitive information (usernames, passwords, publicly-accessible host names or IP addresses, etc.).

Please redact sensitive information that would not be appropriate for a public forum prior to posting the requested information.

If there is sensitive information that must be conveyed in order to provide a complete picture of the scenario you're facing, please let us know and we will set up a secure upload mechanism that can be used.
Additionally, what emulation are you using in SecureCRT?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #5  
Old 01-21-2014, 07:16 PM
CyrilMtl CyrilMtl is offline
Registered User
 
Join Date: Oct 2010
Posts: 7
on the first screenshot (8.06.26pm), it's my securecrt on my mac, local shell with linux terminal emulation where I did an ssh to a linux box and set the PS1.
You can see the date/time on the right, but instead of going back to the left border for the prompt, the curosr stay after the date/time, the prompt is put on the right of the time, the first letter 'c' , the other part of the prompt is on the next line on the left.

configuring securecrt as a xterm terminal doesn't change anything.

(the local osx terminal has the same behavior).

The second screenshot 8.08.48pm, is the screenshot of the linux terminal of the linux box on xwindows (xterm), the date/time is on the right and the prompt is on the same line on the left.

I try iTerm terminal emulation on osx instead of securecrt or the osx terminal app, and I have the correct prompt with date/time on the right and prompt on the left on the same line. (configured a xterm or linux terminal mode).
Attached Images
File Type: png Screen Shot 2014-01-21 at 8.06.26 PM.png (16.6 KB, 265 views)
File Type: png Screen Shot 2014-01-21 at 8.08.48 PM.png (41.0 KB, 260 views)
Reply With Quote
  #6  
Old 01-22-2014, 09:03 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Cyril,

Thanks for the screenshots. I have created a feature request in our SecureCRT enhancement database to add support for ANSI_SC and ANSI_RC to our Xterm emulation. Should we do so in a future SecureCRT release, we will post to this forum thread.

If you would like to be notified directly, please complete and submit the form at the following location:
Submit Feature Request
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #7  
Old 11-25-2019, 02:12 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 942
Support for the ANSI_SC (save cursor) and ANSI_RC (restore cursor) sequences have been added to SecureCRT's Xterm emulation in SecureCRT version 8.7.0.20285 and newer.

If you want to try out a version of SecureCRT 8.7.x that has this support, please send email to support@vandyke.com with a subject of: "ATTN: Forum thread #11365, post #7".
  • Please send the email from your VanDyke Software download account email address (or in the body of the message, include a reference to the email account you use for downloading installers from our web site).

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 04:35 AM.