daxim
daxim

Reputation: 39158

How do you automatically run commands for interactive shells?

I am looking for the rc file. I want to execute

chcp 65001 > nul
cd %TEMP%

each time a new interactive shell is started. System info:

Clink v0.4.8 [git:d565ad] Copyright (c) 2012-2016 Martin Ridgers
http://mridgers.github.io/clink

Microsoft Windows [Version 10.0.16299.125]

myuser@MYHOST C:\Users\myuser
$ choco info conemu | rg -i ^^conemu
ConEmu 18.4.29.0 [Approved] Downloads cached for licensed users

myuser@MYHOST C:\Users\myuser
$ █

Upvotes: 1

Views: 602

Answers (1)

mnistic
mnistic

Reputation: 11010

When you install Clink, it adds itself to the shell's autorun registry entry. The way it does this is by registering the .bat file used to run it. This way, every time you start a new shell, this file is run. Therefore all you have to do is open clink.bat and add your commands to the launch section at the end of the file, before clink is spawned:

:launch
chcp 65001 > nul
cd %TEMP%
start /b "Clink" cmd.exe /s /k ""%~dpnx0" inject %clink_profile_arg%"
exit /b 0

(Notice I use start /b so it preserves your new code page)

Upvotes: 1

Related Questions