Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portable theme #5

Open
RomelSan opened this issue Nov 25, 2020 · 4 comments
Open

Portable theme #5

RomelSan opened this issue Nov 25, 2020 · 4 comments

Comments

@RomelSan
Copy link

RomelSan commented Nov 25, 2020

Nord theme for Putty / Kitty portable

To use the Nord theme you must edit your session file.
The sessions files are located inside your portable folder ex: D:\Kitty\Sessions

Colour0\216,222,233\
Colour1\216,222,233\
Colour2\46,52,64\
Colour3\46,52,64\
Colour4\46,52,64\
Colour5\216,222,233\
Colour6\59,66,82\
Colour7\76,86,106\
Colour8\191,97,106\
Colour9\191,97,106\
Colour10\163,190,140\
Colour11\163,190,140\
Colour12\235,203,139\
Colour13\235,203,139\
Colour14\129,161,193\
Colour15\129,161,193\
Colour16\180,142,173\
Colour17\180,142,173\
Colour18\136,192,208\
Colour19\143,188,187\
Colour20\229,233,240\
Colour21\236,239,244\

Replace the Colour entries with the ones above.

@azlux
Copy link

azlux commented May 7, 2021

Do you think a batch script can do the job ? Especially if you already have multiple sessions already configuration.

@RomelSan
Copy link
Author

RomelSan commented May 7, 2021

Yes, if you have a lot of session files then it is a must.
I don't have more than 5 session files so i do it manually.
In a batch file you will have to use regex.
Should look something like this.

FINDSTR /i /r /c:"Colour0.*" /c:"Colour0\\216,222,233\\" sessionFile
FINDSTR /i /r /c:"Colour2.*" /c:"Colour2\\46,52,64\\" sessionFile

mmm... will try to do it myself later on free time.
Will post here once it is done.

@RomelSan
Copy link
Author

RomelSan commented May 9, 2021

@azlux
It was easier to do this in Powershell.
Here is the code. It is not 100% optimized but it will work fine.
Filename: SetTheme.ps1

# SetTheme.ps1
# For Kitty Portable
# By Romel Vera - @RomelSan

# Function.- Set a color theme inside all the Kitty Portable session files.
# Put this file inside Kitty "Sessions" Folder, and execute it using powershell.
# This will not overwrite your files, the output will be the filename plus _theme suffix.

# You must set your execution policy to RemoteSigned
# In Powershell as administrator type: Set-ExecutionPolicy RemoteSigned
# After usage you can revert the execution policy configuration, the default is: Set-ExecutionPolicy Restricted

# Set Your Color theme here:
# This is "Nord Theme"
$col00 = "Colour0\216,222,233\"
$col01 = "Colour1\216,222,233\"
$col02 = "Colour2\46,52,64\"
$col03 = "Colour3\46,52,64\"
$col04 = "Colour4\46,52,64\"
$col05 = "Colour5\216,222,233\"
$col06 = "Colour6\59,66,82\"
$col07 = "Colour7\76,86,106\"
$col08 = "Colour8\191,97,106\"
$col09 = "Colour9\191,97,106\"
$col10 = "Colour10\163,190,140\"
$col11 = "Colour11\163,190,140\"
$col12 = "Colour12\235,203,139\"
$col13 = "Colour13\235,203,139\"
$col14 = "Colour14\129,161,193\"
$col15 = "Colour15\129,161,193\"
$col16 = "Colour16\180,142,173\"
$col17 = "Colour17\180,142,173\"
$col18 = "Colour18\136,192,208\"
$col19 = "Colour19\143,188,187\"
$col20 = "Colour20\229,233,240\"
$col21 = "Colour21\236,239,244\"

# Change Color Process
$filelist = get-childitem -Exclude *.ps1
foreach ($targetFile in $filelist) {
    $fileContent = (gc $targetFile) 
    $fileOut = $fileContent -replace "Colour0\\.*",$col00
    $fileOut = $fileOut -replace "Colour1\\.*",$col01
    $fileOut = $fileOut -replace "Colour2\\.*",$col02
    $fileOut = $fileOut -replace "Colour3\\.*",$col03
    $fileOut = $fileOut -replace "Colour4\\.*",$col04
    $fileOut = $fileOut -replace "Colour5\\.*",$col05
    $fileOut = $fileOut -replace "Colour6\\.*",$col06
    $fileOut = $fileOut -replace "Colour7\\.*",$col07
    $fileOut = $fileOut -replace "Colour8\\.*",$col08
    $fileOut = $fileOut -replace "Colour9\\.*",$col09
    $fileOut = $fileOut -replace "Colour10\\.*",$col10
    $fileOut = $fileOut -replace "Colour11\\.*",$col11
    $fileOut = $fileOut -replace "Colour12\\.*",$col12
    $fileOut = $fileOut -replace "Colour13\\.*",$col13
    $fileOut = $fileOut -replace "Colour14\\.*",$col14
    $fileOut = $fileOut -replace "Colour15\\.*",$col15
    $fileOut = $fileOut -replace "Colour16\\.*",$col16
    $fileOut = $fileOut -replace "Colour17\\.*",$col17
    $fileOut = $fileOut -replace "Colour18\\.*",$col18
    $fileOut = $fileOut -replace "Colour19\\.*",$col19
    $fileOut = $fileOut -replace "Colour20\\.*",$col20
    $fileOut = $fileOut -replace "Colour21\\.*",$col21

    $newFileName = "$targetFile" + "_theme"
    Set-Content $newFileName -Value $fileOut
}

# Local testing
# (gc .\Winter%20Soldier) -replace "Colour0.*","Colour0\216,222,233\" | Out-File .\Winter%20Soldier_theme -encoding utf8

@azlux
Copy link

azlux commented May 9, 2021

Ho,
It's a good script you've done here.
Thank a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants