|
| 1 | +import type { Template } from './index.js'; |
| 2 | +import { colorSetToVariants, FullVariant } from '../color-set/index.js'; |
| 3 | +import { source } from 'common-tags'; |
| 4 | + |
| 5 | +type Layout = 'block' | 'default' | 'double'; |
| 6 | + |
| 7 | +const renderLayout = ( |
| 8 | + layoutName: Layout, |
| 9 | + colorSet: FullVariant, |
| 10 | + index: number, |
| 11 | +) => { |
| 12 | + const layouts = { |
| 13 | + block: (colors: FullVariant, i: number) => source` |
| 14 | + # Powerline Themer Block - Tmux Theme |
| 15 | + set -g status-interval 1 |
| 16 | + set -g status-fg "${colors.shade3}" |
| 17 | + set -g status-bg "${colors.shade1}" |
| 18 | + set -g status-left "#[fg=${colors.shade0},bg=${ |
| 19 | + colors[`accent${i * 2}` as keyof FullVariant] |
| 20 | + },bold] #S #[fg=${colors[`accent${i * 2}` as keyof FullVariant]},bg=${ |
| 21 | + colors.shade4 |
| 22 | + },nobold]" |
| 23 | + set -g status-right "#[fg=${colors.shade2},bg=${colors.shade1}]#[fg=${ |
| 24 | + colors.shade4 |
| 25 | + },bg=${colors.shade2}] %H:%M:%S" |
| 26 | + `, |
| 27 | + default: (colors: FullVariant, i: number) => source` |
| 28 | + # Powerline Default - Tmux Theme |
| 29 | + set -g status-interval 1 |
| 30 | + set -g status-fg "${colors.shade3}" |
| 31 | + set -g status-bg "${colors.shade1}" |
| 32 | + set -g status-left "#[fg=${colors.shade0},bg=${ |
| 33 | + colors[`accent${i * 2}` as keyof FullVariant] |
| 34 | + },bold] #S #[fg=${colors[`accent${i * 2}` as keyof FullVariant]},bg=${ |
| 35 | + colors.shade4 |
| 36 | + },nobold]" |
| 37 | + set -g status-right "#[fg=${colors.shade2},bg=${colors.shade1}]#[fg=${ |
| 38 | + colors.shade4 |
| 39 | + },bg=${colors.shade2}] %H:%M:%S" |
| 40 | + `, |
| 41 | + double: (colors: FullVariant, i: number) => source` |
| 42 | + # Powerline Double - Tmux Theme |
| 43 | + set -g status-interval 1 |
| 44 | + set -g status-fg "${colors.shade3}" |
| 45 | + set -g status-bg "${colors.shade1}" |
| 46 | + set -g status-left "#[fg=${colors.shade0},bg=${ |
| 47 | + colors[`accent${i * 2}` as keyof FullVariant] |
| 48 | + },bold] #S #[fg=${colors[`accent${i * 2}` as keyof FullVariant]},bg=${ |
| 49 | + colors.shade4 |
| 50 | + },nobold]" |
| 51 | + set -g status-right "#[fg=${colors.shade2},bg=${colors.shade1}]#[fg=${ |
| 52 | + colors.shade4 |
| 53 | + },bg=${colors.shade2}] %H:%M:%S" |
| 54 | + `, |
| 55 | + }; |
| 56 | + |
| 57 | + return layouts[layoutName](colorSet, index); |
| 58 | +}; |
| 59 | + |
| 60 | +const template: Template = { |
| 61 | + name: 'tmux', |
| 62 | + render: async function* (colorSet) { |
| 63 | + const variants = colorSetToVariants(colorSet); |
| 64 | + for (const variant of variants) { |
| 65 | + const { colors, name } = variant; |
| 66 | + for (const layoutName of ['block', 'default', 'double'] as Layout[]) { |
| 67 | + for (let i = 0; i < Math.floor(Object.keys(colors).length / 4); i++) { |
| 68 | + yield { |
| 69 | + path: `themer-tmux.${name}.${layoutName}.v${i}.tmuxtheme`, |
| 70 | + content: renderLayout(layoutName, colors, i), |
| 71 | + }; |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + }, |
| 76 | + renderInstructions: (paths) => source` |
| 77 | + Generated tmux themes: |
| 78 | +
|
| 79 | + ${paths.map((path) => ` - ${path}`).join('\n')} |
| 80 | +
|
| 81 | + Copy or symlink these files to your tmux configuration directory, and include them in your \`.tmux.conf\` like so: |
| 82 | +
|
| 83 | + \`\`\` |
| 84 | + source-file path/to/theme-file |
| 85 | + \`\`\` |
| 86 | + `, |
| 87 | +}; |
| 88 | + |
| 89 | +export default template; |
0 commit comments