When autocomplete feature is enabled, Termius will execute a script on every session connection. This script is needed to set up a shell integration.
if [ "$_t_orig_ps1" = "" ]; then
_t_orig_ps1="$PS1" _t_set_cwd() { printf '\001\033]4545;P;Cwd=$(pwd)\007\002' ; } PS1="$(_t_set_cwd)$_t_orig_ps1" fi
The following script provides access for Termius to a current user path. It modifies the command prompt by adding the current working directory to it. Find the full explanation of this script bellow:
- if [ "$_t_orig_ps1" = "" ]; then: Checks if the variable _t_orig_ps1 is empty. This variable is used to store the original value of PS1 before it is modified.
- _t_orig_ps1="$PS1": If _t_orig_ps1 is empty (meaning the script has not been sourced before), store the current value of PS1 in _t_orig_ps1.
- _t_set_cwd() { printf '\001\033]4545;P;Cwd=$(pwd)\007\002' ; }: Defines a function called _t_set_cwd, which uses the printf command to output a special sequence of characters with the current working directory $(pwd). This sequence can be interpreted by some terminal emulators to display the working directory.
- PS1="$(_t_set_cwd)$_t_orig_ps1": Sets the new value of PS1 by calling the _t_set_cwd function and appending the original value of PS1 stored in _t_orig_ps1. This adds the current working directory to the command prompt without losing the original appearance.
- fi: Closes the if statement, marking the end of the code snippet.
In summary, this code snippet checks if the original PS1 variable has been saved. If not, it saves it, defines a function to add the current working directory to the prompt, and then modifies the `PS1` variable to include the current working directory while retaining the original appearance of the command prompt.
8
-2
Was this article helpful?
3 out of 8 found this helpful
Articles in this section
- I can't find the local terminal option in the desktop app
- Autocomplete integration script explained
- Some symbols in the terminal are rendered as question marks, how can I fix it?
- I get a "Couldn't load reCAPTCHA" error
- I can't use the iOS app in the background
- I can't log in or synchronize data
- I can't connect to a local device on iPhone
- I can't use Termius for Android in the background
- I see double / none of my characters in a Telnet session
- My App Store subscription is not active
Add comment
Please sign in to leave a comment.