#Variables for A Session

7 messages · Page 1 of 1 (latest)

primal beacon
#

I don't know if this is more of a Warp or a PowerShell question, but I would like to define values, like a file path string, that I can use in PS commands without retyping the same long string every time I use the command. My current use case is where I'm testing a new CLI app, and this is its usage:

srcrep read [--json] [--help] sln json-path

I'm currently calling it with something like .\srcrep.exe read C:\Development\contactable_v5_current\Contactable_2019.sln, but I don't want to have to copy and paste that path every time I run the app. I want to have it in either a Warp or a PS variable so I can do this: .\srcrep.exe read <myPathVariable>

shrewd meteorBOT
#

Hi @primal beacon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

This is a great question about using variables in your terminal sessions. In Warp, there are a few approaches you can take to store and reuse values like file paths.

Environment Variables in Warp

Warp has a feature called Environment Variables that allows you to save variables and load them into your terminal sessions. Here's how you can use it:

  1. You can create environment variables through Warp Drive or the Command Palette
  2. Once created, you can load these variables into your current session with a click
  3. Then use them in your commands

However, it's important to note that these environment variables aren't automatically loaded when you start a new session - you need to manually load them each time as mentioned in the documentation.

PowerShell Variables

Since you're using PowerShell, you can also set variables directly in your session:

$myPathVariable = "C:\Development\contactable_v5_current\Contactable_2019.sln"
.\srcrep.exe read $myPathVariable

This variable will persist for your current session, but will be lost when you close the session.

For Persistent Variables

If you want these variables to persist across sessions, you have a few options:

  1. Add them to your PowerShell profile
  2. Create a Warp Environment Variable as mentioned above and load it when needed
  3. There's an open feature request (GitHub Issue #5771) to allow managing environment variables locally like workflows, but this isn't implemented yet
#

For your specific use case with PowerShell, setting the variable in your PowerShell profile might be the most convenient option if you want it to be automatically available in every new session.

Would you like more details on any of these approaches?

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@primal beacon Kapa.ai is still learning and improving, please let me know how I did by reacting below.

primal beacon
#

Windows equivalent of source so I can re-read my PS profile without restarting the terminal

kind dagger