switched to starship
This commit is contained in:
parent
c70f2b0e6b
commit
a36f20bb50
14 changed files with 659 additions and 169 deletions
159
starship/.config/starship.toml
Normal file
159
starship/.config/starship.toml
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
# Get editor completions based on the config schema
|
||||
"$schema" = 'https://starship.rs/config-schema.json'
|
||||
|
||||
add_newline = false
|
||||
palette = "solarized_light"
|
||||
command_timeout = 1000
|
||||
|
||||
# Customize your prompt to ensure everything is on a single line
|
||||
format = """\
|
||||
$directory\
|
||||
$git_branch\
|
||||
$git_status\
|
||||
$container\
|
||||
$conda\
|
||||
$character\
|
||||
"""
|
||||
|
||||
right_format = """\
|
||||
$cmd_duration\
|
||||
"""
|
||||
|
||||
# Git branch configuration
|
||||
[git_branch]
|
||||
format = "[$branch(:$remote_branch)]($style)"
|
||||
style = "bold red"
|
||||
|
||||
# Git status configuration
|
||||
[git_status]
|
||||
format = '[$all_status]($style)'
|
||||
style = "bold green"
|
||||
|
||||
# Git metric configuration
|
||||
[git_metrics]
|
||||
format = '([$added]($added_style) )([$deleted]($deleted_style))'
|
||||
added_style = "green"
|
||||
deleted_style = "red"
|
||||
disabled = false
|
||||
|
||||
# Configure the overall look of the prompt
|
||||
[character]
|
||||
success_symbol = "[ ❯](bold green)"
|
||||
error_symbol = "[ ✗](bold red)"
|
||||
|
||||
# Directory
|
||||
[directory]
|
||||
style = "bright-cyan"
|
||||
truncation_length = 3
|
||||
truncation_symbol = "…/"
|
||||
|
||||
[line_break]
|
||||
disabled = true
|
||||
|
||||
[jobs]
|
||||
symbol = '+ '
|
||||
number_threshold = 4
|
||||
symbol_threshold = 0
|
||||
|
||||
[cmd_duration]
|
||||
format = "[$duration]($style)"
|
||||
style = "yellow"
|
||||
|
||||
# Package version
|
||||
[package]
|
||||
style = "purple"
|
||||
|
||||
# Container
|
||||
[container]
|
||||
format = '[$name]'
|
||||
style = "orange"
|
||||
|
||||
# Conda
|
||||
[conda]
|
||||
format = "[$environment]"
|
||||
style = "green"
|
||||
|
||||
# Python
|
||||
[python]
|
||||
pyenv_version_name = true
|
||||
format = "[$version]($style)"
|
||||
style = "blue"
|
||||
|
||||
# Golang
|
||||
[golang]
|
||||
format = "[$version]($style)"
|
||||
style = "blue"
|
||||
|
||||
# Rust
|
||||
[rust]
|
||||
format = "[$version]($style)"
|
||||
style = "purple"
|
||||
|
||||
# Lua
|
||||
[lua]
|
||||
format = "[$version]($style)"
|
||||
style = "purple"
|
||||
|
||||
# Directory substitutions
|
||||
[directory.substitutions]
|
||||
"Documents/projects" = "proj"
|
||||
".config" = "config"
|
||||
|
||||
# Monokai Pro palette
|
||||
[palettes.monokai_pro]
|
||||
rosewater = "#f1ebeb"
|
||||
flamingo = "#dc2566"
|
||||
pink = "#fa2772"
|
||||
mauve = "#9358fe"
|
||||
red = "#dc2566"
|
||||
maroon = "#8fc029"
|
||||
peach = "#d4c96e"
|
||||
yellow = "#e7db75"
|
||||
green = "#a7e22e"
|
||||
teal = "#56b7a5"
|
||||
sky = "#66d9ee"
|
||||
sapphire = "#66efd5"
|
||||
blue = "#55bcce"
|
||||
lavender = "#ae82ff"
|
||||
text = "#f8f8f2"
|
||||
subtext1 = "#acada1"
|
||||
subtext0 = "#76715e"
|
||||
overlay2 = "#cfd0c2"
|
||||
overlay1 = "#76715e"
|
||||
overlay0 = "#48483e"
|
||||
surface2 = "#272822"
|
||||
surface1 = "#48483e"
|
||||
surface0 = "#272822"
|
||||
base = "#272822"
|
||||
mantle = "#272822"
|
||||
crust = "#272822"
|
||||
|
||||
# Solarized light palette
|
||||
[palettes.solarized_light]
|
||||
rosewater = "#fdf6e3"
|
||||
flamingo = "#dc322f"
|
||||
pink = "#dc322f"
|
||||
mauve = "#6c71c4"
|
||||
red = "#dc322f"
|
||||
maroon = "#b58900"
|
||||
peach = "#b58900"
|
||||
yellow = "#b58900"
|
||||
green = "#859900"
|
||||
teal = "#2aa198"
|
||||
sky = "#268bd2"
|
||||
sapphire = "#268bd2"
|
||||
blue = "#268bd2"
|
||||
lavender = "#6c71c4"
|
||||
text = "#586e75"
|
||||
subtext1 = "#657b83"
|
||||
subtext0 = "#93a1a1"
|
||||
overlay2 = "#93a1a1"
|
||||
overlay1 = "#657b83"
|
||||
overlay0 = "#002b36"
|
||||
surface2 = "#fdf6e3"
|
||||
surface1 = "#fdf6e3"
|
||||
surface0 = "#fdf6e3"
|
||||
base = "#fdf6e3"
|
||||
mantle = "#fdf6e3"
|
||||
crust = "#fdf6e3"
|
||||
|
||||
74
wezterm/.config/wezterm/domains/docker.lua
Normal file
74
wezterm/.config/wezterm/domains/docker.lua
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
local wezterm = require("wezterm")
|
||||
local config = wezterm.config_builder()
|
||||
|
||||
local function list_docker_cont()
|
||||
local docker_list = {}
|
||||
local success, stdout, stderr = wezterm.run_child_process({
|
||||
"docker",
|
||||
"container",
|
||||
"ls",
|
||||
"--format",
|
||||
"{{.ID}}:{{.Names}}",
|
||||
})
|
||||
for _, line in ipairs(wezterm.split_by_newlines(stdout)) do
|
||||
local id, name = line:match("(.-):(.+)")
|
||||
if id and name then
|
||||
docker_list[id] = name
|
||||
end
|
||||
end
|
||||
return docker_list
|
||||
end
|
||||
|
||||
-- @param id: string
|
||||
local function make_docker_label_func(id)
|
||||
return function(name)
|
||||
local success, stdout, stderr = wezterm.run_child_process({
|
||||
"docker",
|
||||
"inspect",
|
||||
"--format",
|
||||
"{{.State.Running}}",
|
||||
id,
|
||||
})
|
||||
local running = stdout == "true\n"
|
||||
local color = running and "Green" or "Red"
|
||||
return wezterm.format({
|
||||
{ Foreground = { AnsiColor = color } },
|
||||
{ Text = "docker container named " .. name },
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- @param id: string
|
||||
local function make_docker_fixup_func(id)
|
||||
return function(cmd)
|
||||
cmd.args = cmd.args or { "/bin/sh" }
|
||||
local wrapped = {
|
||||
"docker",
|
||||
"exec",
|
||||
"-it",
|
||||
id,
|
||||
}
|
||||
for _, arg in ipairs(cmd.args) do
|
||||
table.insert(wrapped, arg)
|
||||
end
|
||||
|
||||
cmd.args = wrapped
|
||||
return cmd
|
||||
end
|
||||
end
|
||||
|
||||
local function compute_exec_domains()
|
||||
local exec_domains = {}
|
||||
for id, name in pairs(list_docker_cont()) do
|
||||
table.insert(
|
||||
exec_domains,
|
||||
wezterm.exec_domain("docker:" .. name, make_docker_fixup_func(id), make_docker_label_func(id))
|
||||
)
|
||||
end
|
||||
return exec_domains
|
||||
end
|
||||
|
||||
config.exec_domains = compute_exec_domains()
|
||||
|
||||
return config
|
||||
|
||||
47
wezterm/.config/wezterm/history.lua
Normal file
47
wezterm/.config/wezterm/history.lua
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
local wezterm = require 'wezterm'
|
||||
|
||||
-- Function to get the FZF theme from the shell script
|
||||
-- @return string: The FZF theme
|
||||
local function get_fzf_theme()
|
||||
local handle = io.popen(os.getenv("HOME") .. "/.local/bin/script/fzf_theme")
|
||||
if not handle then
|
||||
return ""
|
||||
end
|
||||
local fzf_theme = handle:read("*a")
|
||||
handle:close()
|
||||
return fzf_theme
|
||||
end
|
||||
|
||||
-- Function to display command history with fuzzy finder
|
||||
local function show_command_history()
|
||||
local fzf_theme = get_fzf_theme()
|
||||
local command_history = "history | awk '{$1=\"\"; print substr($0,2)}'"
|
||||
|
||||
-- Determine if skim (sk) is installed
|
||||
local fuzzy_command = "fzf"
|
||||
if wezterm.run_child_process({ "command", "-v", "sk" }) then
|
||||
fuzzy_command = "sk"
|
||||
end
|
||||
|
||||
-- Combine the commands
|
||||
local full_command = command_history .. " | " .. fuzzy_command .. " " .. fzf_theme
|
||||
|
||||
-- Run the command and get the selected history entry
|
||||
local handle = io.popen(full_command)
|
||||
if not handle then
|
||||
return
|
||||
end
|
||||
local selected_command = handle:read("*a")
|
||||
handle:close()
|
||||
|
||||
-- Execute the selected command
|
||||
if selected_command and #selected_command > 0 then
|
||||
wezterm.run_child_process({ "bash", "-c", selected_command })
|
||||
end
|
||||
end
|
||||
|
||||
-- Bind key to show command history
|
||||
return {
|
||||
show_command_history = show_command_history,
|
||||
}
|
||||
|
||||
|
|
@ -5,9 +5,7 @@ M.alert_popup_before_seconds = 15
|
|||
M.alert_if_in_next_minutes = 30
|
||||
M.theme_bg = "#2c323c"
|
||||
M.theme_red = "#f92572"
|
||||
M.nerd_font_free = ""
|
||||
M.nerd_font_meeting = ""
|
||||
M.nerd_font_separator = ""
|
||||
|
||||
M.ical_buddy = "/usr/local/bin/icalBuddy"
|
||||
M.ignored_cal = "Birthdays, Family, Contacts, School, Home, Canadian Holidays, Canadiens, Jours fériés au Canada"
|
||||
|
|
@ -22,10 +20,6 @@ local function execute_command(command)
|
|||
return result
|
||||
end
|
||||
|
||||
-- local function execute_command(command)
|
||||
-- return mock_execute_cmd(command)
|
||||
-- end
|
||||
|
||||
local function check_ical_buddy()
|
||||
local result = execute_command("test -f " .. M.ical_buddy)
|
||||
if result == "" then
|
||||
|
|
@ -114,42 +108,52 @@ local function update_tab_bar(times, meeting)
|
|||
},
|
||||
})
|
||||
|
||||
wezterm.on("update-right-status", function(window)
|
||||
window:set_right_status(status)
|
||||
end)
|
||||
|
||||
if times.epoc_diff <= M.alert_popup_before_seconds then
|
||||
display_popup(meeting)
|
||||
end
|
||||
|
||||
return status
|
||||
end
|
||||
|
||||
-- local function mock_execute_cmd(command)
|
||||
-- return [[
|
||||
-- Sample meeting
|
||||
-- Thuesday 10:00 - 11:00
|
||||
-- attendees: John Doe, Jane Doe
|
||||
-- ]]
|
||||
-- end
|
||||
|
||||
function M.main()
|
||||
print("here")
|
||||
if not check_ical_buddy() then
|
||||
return
|
||||
return ""
|
||||
end
|
||||
|
||||
local next_meeting = get_next_meeting()
|
||||
if not next_meeting then
|
||||
return
|
||||
return ""
|
||||
end
|
||||
|
||||
local meeting = parse_result(next_meeting)
|
||||
local times = calculate_times(meeting.start_time)
|
||||
if not times then
|
||||
return
|
||||
return ""
|
||||
end
|
||||
|
||||
update_tab_bar(times, meeting)
|
||||
return update_tab_bar(times, meeting)
|
||||
end
|
||||
|
||||
wezterm.time.call_after(M.alert_popup_before_seconds, M.main)
|
||||
function M.setup_update_timer(interval_seconds)
|
||||
interval_seconds = interval_seconds or 60 -- Default interval is 60 seconds
|
||||
|
||||
local function update()
|
||||
local meeting_status = M.main()
|
||||
if meeting_status ~= "" then
|
||||
wezterm.on("update-right-status", function(window)
|
||||
window:set_right_status(wezterm.format({
|
||||
{ Text = meeting_status },
|
||||
}))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- Initially update
|
||||
update()
|
||||
|
||||
-- Set up periodic update timer
|
||||
wezterm.update_built_in_timer("meeting_notifier_update", interval_seconds, update)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
local wezterm = require('wezterm')
|
||||
local wezterm = require("wezterm")
|
||||
|
||||
local M = {}
|
||||
|
||||
local function is_found(str, pattern)
|
||||
return string.find(str, pattern) ~= nil
|
||||
return string.find(str, pattern) ~= nil
|
||||
end
|
||||
|
||||
local function platform()
|
||||
local is_win = is_found(wezterm.target_triple, 'windows')
|
||||
local is_linux = is_found(wezterm.target_triple, 'linux')
|
||||
local is_mac = is_found(wezterm.target_triple, 'darwin')
|
||||
local os = is_win and 'windows' or is_linux and 'linux' or is_mac and 'mac' or 'unknown'
|
||||
return {
|
||||
os = os,
|
||||
is_win = is_win,
|
||||
is_linux = is_linux,
|
||||
is_mac = is_mac,
|
||||
}
|
||||
function M.platform()
|
||||
local is_win = is_found(wezterm.target_triple, "windows")
|
||||
local is_linux = is_found(wezterm.target_triple, "linux")
|
||||
local is_mac = is_found(wezterm.target_triple, "darwin")
|
||||
local os = is_win and "windows" or is_linux and "linux" or is_mac and "mac" or "unknown"
|
||||
return {
|
||||
os = os,
|
||||
is_win = is_win,
|
||||
is_linux = is_linux,
|
||||
is_mac = is_mac,
|
||||
}
|
||||
end
|
||||
|
||||
print(Platform.os)
|
||||
|
||||
return platform
|
||||
return M
|
||||
|
|
|
|||
34
wezterm/.config/wezterm/profiler.lua
Normal file
34
wezterm/.config/wezterm/profiler.lua
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
local wezterm = require("wezterm")
|
||||
|
||||
local startup = function(env_var, base_project_module)
|
||||
local project = os.getenv(env_var)
|
||||
|
||||
if project == nil then
|
||||
wezterm.log_error("Environment variable " .. env_var .. " is not set")
|
||||
return
|
||||
end
|
||||
|
||||
local status, project_module = pcall(function()
|
||||
return require(base_project_module .. "." .. project)
|
||||
end)
|
||||
|
||||
if not status then
|
||||
wezterm.log_error("Failed to load project config: " .. tostring(project_module))
|
||||
return
|
||||
end
|
||||
|
||||
local project_startup = project_module.startup
|
||||
|
||||
if project_startup == nil or type(project_startup) ~= "function" then
|
||||
wezterm.log_error(
|
||||
"Project " .. project .. " has no exported 'startup' function (type is " .. type(project_startup) .. ")"
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
project_startup(wezterm)
|
||||
end
|
||||
|
||||
return {
|
||||
startup = startup,
|
||||
}
|
||||
25
wezterm/.config/wezterm/profiles/infra.lua
Normal file
25
wezterm/.config/wezterm/profiles/infra.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
local wezterm = require("wezterm")
|
||||
|
||||
local function startup()
|
||||
local mux = wezterm.mux
|
||||
local project_dir = wezterm.home_dir .. "/Documents/projects/infra"
|
||||
|
||||
-- Spawn a new window with the specified project directory as the working directory
|
||||
local tab, main_pane, window = mux.spawn_window({
|
||||
cwd = project_dir,
|
||||
})
|
||||
main_pane:send_text("vim .\n")
|
||||
|
||||
-- Split the main pane to the right and start ipython
|
||||
local ssh_pane = main_pane:split({
|
||||
direction = "Right",
|
||||
cwd = project_dir,
|
||||
})
|
||||
ssh_pane:send_text("wezterm ssh ansible@jfraeys.com\n")
|
||||
|
||||
-- Split the ipython pane downward for running other commands
|
||||
end
|
||||
|
||||
return {
|
||||
startup = startup,
|
||||
}
|
||||
29
wezterm/.config/wezterm/profiles/job_req.lua
Normal file
29
wezterm/.config/wezterm/profiles/job_req.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
local wezterm = require("wezterm")
|
||||
|
||||
local function startup()
|
||||
local mux = wezterm.mux
|
||||
local project_dir = wezterm.home_dir .. "/Documents/projects/job-req"
|
||||
|
||||
-- Spawn a new window with the specified project directory as the working directory
|
||||
local tab, main_pane, window = mux.spawn_window({
|
||||
cwd = project_dir,
|
||||
})
|
||||
main_pane:send_text("vim .\n")
|
||||
|
||||
-- Split the main pane to the right and start ipython
|
||||
local ipython_pane = main_pane:split({
|
||||
direction = "Right",
|
||||
cwd = project_dir,
|
||||
})
|
||||
ipython_pane:send_text("python\n")
|
||||
|
||||
-- Split the ipython pane downward for running other commands
|
||||
local run_pane = ipython_pane:split({
|
||||
direction = "Bottom",
|
||||
cwd = project_dir,
|
||||
})
|
||||
end
|
||||
|
||||
return {
|
||||
startup = startup,
|
||||
}
|
||||
41
wezterm/.config/wezterm/profiles/neovim.lua
Normal file
41
wezterm/.config/wezterm/profiles/neovim.lua
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
local wezterm = require("wezterm")
|
||||
|
||||
local function start_nvim_with_dir(dir)
|
||||
local mux = wezterm.mux
|
||||
local project_dir = wezterm.home_dir .. dir
|
||||
|
||||
-- Spawn a new window with Neovim in the specified project directory
|
||||
local tab, main_pane, window = mux.spawn_window({
|
||||
cwd = project_dir,
|
||||
args = { "nvim", project_dir }
|
||||
})
|
||||
|
||||
-- Split the main pane downward for the terminal
|
||||
local terminal_pane = main_pane:split({
|
||||
direction = "Bottom",
|
||||
size = 0.3, -- Adjust this value to control the height of the terminal pane
|
||||
cwd = project_dir,
|
||||
})
|
||||
terminal_pane:send_text("ipython\n")
|
||||
end
|
||||
|
||||
return {
|
||||
start_nvim_with_dir = start_nvim_with_dir,
|
||||
|
||||
-- Neovim-specific settings
|
||||
font = wezterm.font_with_fallback({
|
||||
"JetBrains Mono",
|
||||
"Noto Color Emoji",
|
||||
}),
|
||||
font_size = 12.0,
|
||||
enable_tab_bar = false,
|
||||
window_padding = {
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0,
|
||||
},
|
||||
animation_fps = 30,
|
||||
enable_wayland = false, -- Disable Wayland for better performance (if applicable)
|
||||
}
|
||||
|
||||
23
wezterm/.config/wezterm/sessionizer.lua
Executable file → Normal file
23
wezterm/.config/wezterm/sessionizer.lua
Executable file → Normal file
|
|
@ -1,8 +1,10 @@
|
|||
-- sessionizer.lua
|
||||
-- .config/wezterm/sessionizer.lua
|
||||
|
||||
-- Pull in the wezterm API
|
||||
local wezterm = require("wezterm")
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Define utility functions
|
||||
local function run_command(command)
|
||||
local f = io.popen(command)
|
||||
|
|
@ -31,30 +33,25 @@ local function create_or_attach_session(selected_name, selected)
|
|||
end
|
||||
|
||||
-- Main sessionizer function
|
||||
local function run_sessionizer()
|
||||
-- Use fzf to select a directory
|
||||
function M.run(window, pane)
|
||||
wezterm.log_info("Selecting a directory...")
|
||||
local selected = run_command(
|
||||
"fzf --preview 'tree -C {}' --preview-window=right:50%:wrap --height=100% --border --prompt='Select a directory: ' --bind='enter:accept,ctrl-c:abort' --query='' --no-mouse"
|
||||
)
|
||||
|
||||
-- Check if no directory was selected
|
||||
if not selected then
|
||||
print("No directory selected. Exiting.")
|
||||
wezterm.log_error("No directory selected. Exiting.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Trim leading/trailing whitespace from the selected directory
|
||||
selected = selected:gsub("^%s*(.-)%s*$", "%1")
|
||||
|
||||
local selected_name = selected:gsub("%.", "_")
|
||||
|
||||
-- Check if the directory is valid
|
||||
if not is_directory_valid(selected) then
|
||||
print("Invalid directory: " .. selected)
|
||||
wezterm.log_error("Invalid directory: " .. selected)
|
||||
return
|
||||
end
|
||||
|
||||
-- Check if the session already exists
|
||||
local sessions = wezterm.mux.get_sessions()
|
||||
local found = false
|
||||
for _, session in ipairs(sessions) do
|
||||
|
|
@ -65,13 +62,9 @@ local function run_sessionizer()
|
|||
end
|
||||
end
|
||||
|
||||
-- If session doesn't exist, spawn a new one
|
||||
if not found then
|
||||
create_or_attach_session(selected_name, selected)
|
||||
end
|
||||
end
|
||||
|
||||
-- Export the sessionizer function
|
||||
return {
|
||||
run_sessionizer = run_sessionizer,
|
||||
}
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
local wezterm = require("wezterm")
|
||||
local os = require("os")
|
||||
local platform = require("platform")
|
||||
|
||||
local M = {}
|
||||
|
||||
|
|
@ -28,7 +30,6 @@ local color_schemes = {
|
|||
-- Define custom tab bar colors for light and dark themes
|
||||
local tab_bar_colors = {
|
||||
dark = {
|
||||
-- background = "#2c323c",
|
||||
active_tab = {
|
||||
bg_color = "#1c1f24",
|
||||
fg_color = "#f8f8f2",
|
||||
|
|
@ -51,7 +52,6 @@ local tab_bar_colors = {
|
|||
},
|
||||
},
|
||||
light = {
|
||||
-- background = "#fdf6e3",
|
||||
active_tab = {
|
||||
bg_color = "#eee8d5",
|
||||
fg_color = "#073642",
|
||||
|
|
@ -75,12 +75,62 @@ local tab_bar_colors = {
|
|||
},
|
||||
}
|
||||
|
||||
local function is_command_available(cmd)
|
||||
-- Use os.execute with a command that checks for command existence
|
||||
local result = os.execute('command -v ' .. cmd)
|
||||
return result
|
||||
end
|
||||
|
||||
-- Function to update the Starship palette in the starship.toml file using sed
|
||||
local function update_starship_palette(palette_name)
|
||||
local starship_config_path = os.getenv("HOME") .. "/.dotfiles/starship/.config/starship.toml"
|
||||
|
||||
if not is_command_available("starship") then
|
||||
wezterm.log_info("Starship is not installed")
|
||||
return
|
||||
end
|
||||
|
||||
-- Get platform information
|
||||
local plat = platform.platform()
|
||||
|
||||
local sed_command
|
||||
if plat.is_mac then
|
||||
-- macOS sed command
|
||||
sed_command = string.format(
|
||||
'sed -i \'\' \'s/palette = .*/palette = "%s"/\' %s',
|
||||
palette_name,
|
||||
starship_config_path
|
||||
)
|
||||
elseif plat.is_linux then
|
||||
-- Linux sed command
|
||||
sed_command = string.format(
|
||||
'sed -i \'s/palette = .*/palette = "%s"/\' %s',
|
||||
palette_name,
|
||||
starship_config_path
|
||||
)
|
||||
else
|
||||
wezterm.log_info("Unsupported operating system: " .. plat.os)
|
||||
return
|
||||
end
|
||||
|
||||
os.execute(sed_command)
|
||||
end
|
||||
|
||||
-- Apply the configuration and update the Starship palette
|
||||
function M.apply_to_config(config)
|
||||
local appearance = get_appearance()
|
||||
config.color_scheme = scheme_for_appearance(appearance, color_schemes)
|
||||
config.colors = {
|
||||
tab_bar = scheme_for_appearance(appearance, tab_bar_colors),
|
||||
}
|
||||
|
||||
-- Update the Starship palette based on the appearance
|
||||
if appearance:find("Dark") then
|
||||
update_starship_palette("monokai_pro")
|
||||
else
|
||||
update_starship_palette("solarized_light")
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
|
|
|
|||
|
|
@ -1,39 +1,61 @@
|
|||
-- Import required modules
|
||||
local wezterm = require "wezterm"
|
||||
local wezterm = require("wezterm")
|
||||
|
||||
-- Function to create or attach to a session
|
||||
-- Define the module table
|
||||
local M = {}
|
||||
|
||||
-- Private function to create or attach to a session
|
||||
local function create_or_attach_session(branch_name, command)
|
||||
-- Get the current WezTerm window's session
|
||||
local session = wezterm.target_window().parent
|
||||
-- Get the current WezTerm window's session
|
||||
local window = wezterm.target_window()
|
||||
|
||||
-- Clean branch name to use as window name
|
||||
local clean_name = branch_name:gsub("[./]", "__")
|
||||
-- Clean branch name to use as window name
|
||||
local clean_name = branch_name:gsub("[./]", "__")
|
||||
|
||||
-- Check if the window exists and select it, otherwise create a new window
|
||||
local window = session:find_window_by_name(clean_name)
|
||||
if not window then
|
||||
window = session:new_tab(wezterm.term_muxed_pane_with_default { pane_title = clean_name })
|
||||
else
|
||||
window:activate()
|
||||
end
|
||||
-- Check if the tab exists and select it, otherwise create a new tab
|
||||
local tab
|
||||
for _, t in ipairs(window:tabs()) do
|
||||
if t:get_title() == clean_name then
|
||||
tab = t
|
||||
break
|
||||
end
|
||||
end
|
||||
if not tab then
|
||||
tab = window:spawn_tab({ cwd = wezterm.home_dir })
|
||||
tab:set_title(clean_name)
|
||||
end
|
||||
|
||||
-- Send command to the selected window if provided
|
||||
if command then
|
||||
window:send_string(command .. "\n")
|
||||
end
|
||||
-- Activate the tab
|
||||
window:activate_tab(tab)
|
||||
|
||||
-- Send command to the selected tab if provided
|
||||
if command then
|
||||
local pane = tab:active_pane()
|
||||
pane:send_text(command .. "\n")
|
||||
end
|
||||
end
|
||||
|
||||
-- Extract branch name from the first argument
|
||||
local branch_name = arg[1]
|
||||
|
||||
-- Extract command to send to WezTerm from the remaining arguments
|
||||
local command = table.concat(arg, " ", 2)
|
||||
|
||||
-- Check if branch name is provided
|
||||
if not branch_name then
|
||||
print("Branch name not provided. Exiting.")
|
||||
return
|
||||
function M.apply_to_config(config)
|
||||
config.windownizer_enabled = true
|
||||
end
|
||||
|
||||
-- Call function to create or attach to session
|
||||
create_or_attach_session(branch_name, command)
|
||||
-- Function to process input arguments and call the create_or_attach_session function
|
||||
function M.run(args)
|
||||
-- Extract branch name from the first argument
|
||||
local branch_name = args[1]
|
||||
|
||||
-- Extract command to send to WezTerm from the remaining arguments
|
||||
local command = table.concat(args, " ", 2)
|
||||
|
||||
-- Check if branch name is provided
|
||||
if not branch_name then
|
||||
print("Branch name not provided. Exiting.")
|
||||
return
|
||||
end
|
||||
|
||||
-- Call private function to create or attach to session
|
||||
create_or_attach_session(branch_name, command)
|
||||
end
|
||||
|
||||
-- Return the module table
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -2,19 +2,9 @@ if [[ -z "$XDG_CONFIG_HOME" ]]; then
|
|||
export XDG_CONFIG_HOME="$HOME/.config"
|
||||
fi
|
||||
|
||||
if [[ -z "$XDG_CACHE_HOME" ]]; then
|
||||
export XDG_CACHE_HOME="$HOME/.cache"
|
||||
fi
|
||||
export PAGER="less -i -N -S -R"
|
||||
|
||||
if [[ -z "$XDG_DATA_HOME" ]]; then
|
||||
export XDG_DATA_HOME="$HOME/.local/share"
|
||||
fi
|
||||
|
||||
if [[ -z "$XDG_STATE_HOME" ]]; then
|
||||
export XDG_STATE_HOME="$HOME/.local/state"
|
||||
fi
|
||||
|
||||
export ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX=YES
|
||||
# export ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX=YES
|
||||
|
||||
if [[ -n $SSH_CONNECTION ]]; then
|
||||
export EDITOR='vim'
|
||||
|
|
@ -32,7 +22,10 @@ if [ -d "$HOME/.local/bin" ] ; then
|
|||
fi
|
||||
|
||||
chmod -R ug+rwx "$HOME/.local/bin/"
|
||||
export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
|
||||
if [ -f fzf_theme ]; then
|
||||
source fzf_theme > /dev/null 2>&1
|
||||
fi
|
||||
source <(fzf --zsh)
|
||||
|
||||
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
|
||||
export PATH="$PATH:$HOME/.rvm/bin"
|
||||
|
|
@ -55,13 +48,37 @@ activate_python_env() {
|
|||
alias act='activate_python_env'
|
||||
|
||||
alias python="python3"
|
||||
alias vim="nvim"
|
||||
alias v="nvim"
|
||||
# alias docker="$HOME/.local/bin/docker_check.sh"
|
||||
alias tn="tmux new -s $(pwd | sed 's/.*\///g')"
|
||||
# alias tn="tmux new -s $(pwd | sed 's/.*\///g')"
|
||||
alias cat="bat --paging=never"
|
||||
alias grep="grep --color=auto"
|
||||
alias ll="ls -alF"
|
||||
|
||||
# Basic `ls` replacement with `eza`, grouping directories first
|
||||
alias ls='eza --group-directories-first --color=auto'
|
||||
|
||||
# List all files, including hidden ones, in long format with grouped directories
|
||||
alias la='eza -la --group-directories-first --color=auto'
|
||||
|
||||
# List files in long format with grouped directories
|
||||
alias ll='eza -l --group-directories-first --color=auto'
|
||||
|
||||
# List files sorted by modification time, newest first, in long format with grouped directories
|
||||
alias lt='eza -lt modified --sort newest'
|
||||
|
||||
# List files sorted by size, largest first, in long format with grouped directories
|
||||
alias lS='eza -lS --group-directories-first --color=auto'
|
||||
|
||||
# Display directory tree with a depth limit of 3 levels
|
||||
alias tree='eza --tree --level=3'
|
||||
|
||||
# Display git status alongside files
|
||||
alias lg='eza --git'
|
||||
|
||||
# Add eza completions to FPATH
|
||||
export FPATH="/usr/local/bin/eza/completions/zsh:$FPATH"
|
||||
|
||||
# set bat to highlight --help messages
|
||||
alias bathelp='bat --plain --language=help'
|
||||
help() {
|
||||
|
|
@ -69,6 +86,9 @@ help() {
|
|||
}
|
||||
|
||||
# overwriting -h and --help with bat highlights
|
||||
alias -g -- -h='-h 2>&1 | bat --language=help --style=plain'
|
||||
alias -g -- --help='--help 2>&1 | bat --language=help --style=plain'
|
||||
alias -g :h='-h 2>&1 | bat --language=help --style=plain'
|
||||
alias -g :help='--help 2>&1 | bat --language=help --style=plain'
|
||||
|
||||
# Initialize zoxide
|
||||
eval "$(zoxide init --cmd cd zsh)"
|
||||
|
||||
|
|
|
|||
126
zsh/.zshrc
126
zsh/.zshrc
|
|
@ -1,33 +1,36 @@
|
|||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||
# Load p10k instant prompt if it exists
|
||||
# if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||
# source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||
# fi
|
||||
|
||||
DISABLE_UPDATE_PROMPT=true
|
||||
|
||||
# Add custom paths to $PATH
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
# Homebrew Configuration
|
||||
# Add Homebrew's installation directory to the PATH
|
||||
if [[ -d /opt/homebrew ]]; then
|
||||
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
|
||||
elif [[ -d /usr/local ]]; then
|
||||
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
|
||||
fi
|
||||
|
||||
# If you come from bash you might have to change your $PATH.
|
||||
# export PATH=$HOME/bin:/usr/local/bin:$PATH
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
# Path to your oh-my-zsh installation.
|
||||
export ZSH="$HOME/.oh-my-zsh"
|
||||
|
||||
export UPDATE_ZSH_DAYS=1
|
||||
|
||||
# Set name of the theme to load --- if set to "random", it will
|
||||
# load a random theme each time oh-my-zsh is loaded, in which case,
|
||||
# to know which specific one was loaded, run: echo $RANDOM_THEME
|
||||
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
|
||||
ZSH_THEME="powerlevel10k/powerlevel10k"
|
||||
# Set name of the theme to loading
|
||||
# ZSH_THEME="powerlevel10k/powerlevel10k"
|
||||
# ZSH_THEME="robbyrussell"
|
||||
|
||||
# Set list of themes to pick from when loading at random
|
||||
# Setting this variable when ZSH_THEME=random will cause zsh to load
|
||||
# a theme from this variable instead of looking in $ZSH/themes/
|
||||
# If set to an empty array, this variable will have no effect.
|
||||
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
|
||||
|
||||
# Uncomment the following line to use case-sensitive completion.
|
||||
# Uncomment to use case-sensitive completion
|
||||
# CASE_SENSITIVE="true"
|
||||
|
||||
# Uncomment the following line to use hyphen-insensitive completion.
|
||||
# Case-sensitive completion must be off. _ and - will be interchangeable.
|
||||
# Uncomment to use hyphen-insensitive completion
|
||||
# HYPHEN_INSENSITIVE="true"
|
||||
|
||||
# Uncomment one of the following lines to change the auto-update behavior
|
||||
|
|
@ -35,33 +38,29 @@ ZSH_THEME="powerlevel10k/powerlevel10k"
|
|||
# zstyle ':omz:update' mode auto # update automatically without asking
|
||||
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
|
||||
|
||||
# Uncomment the following line to change how often to auto-update (in days).
|
||||
# Uncomment to change how often to auto-update (in days)
|
||||
# zstyle ':omz:update' frequency 13
|
||||
|
||||
# Uncomment the following line if pasting URLs and other text is messed up.
|
||||
# Uncomment if pasting URLs and other text is messed up
|
||||
# DISABLE_MAGIC_FUNCTIONS="true"
|
||||
|
||||
# Uncomment the following line to disable colors in ls.
|
||||
# Uncomment to disable colors in ls
|
||||
# DISABLE_LS_COLORS="true"
|
||||
|
||||
# Uncomment the following line to disable auto-setting terminal title.
|
||||
# Uncomment to disable auto-setting terminal title
|
||||
# DISABLE_AUTO_TITLE="true"
|
||||
|
||||
# Uncomment the following line to enable command auto-correction.
|
||||
# Uncomment to enable command auto-correction
|
||||
# ENABLE_CORRECTION="true"
|
||||
|
||||
# Uncomment the following line to display red dots whilst waiting for completion.
|
||||
# You can also set it to another string to have that shown instead of the default red dots.
|
||||
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
|
||||
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
|
||||
# Uncomment to display red dots whilst waiting for completion
|
||||
# COMPLETION_WAITING_DOTS="true"
|
||||
|
||||
# Uncomment the following line if you want to disable marking untracked files
|
||||
# under VCS as dirty. This makes repository status check for large repositories
|
||||
# much, much faster.
|
||||
# Uncomment to disable marking untracked files under VCS as dirty
|
||||
# DISABLE_UNTRACKED_FILES_DIRTY="true"
|
||||
|
||||
# autoload -Uz add-zsh-hook
|
||||
# Load zsh hooks
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
# move_curor_to_bottom() {
|
||||
# [[ -n ${PIN_PROMPT_NEWLINE+1} ]] && echo
|
||||
|
|
@ -71,29 +70,26 @@ ZSH_THEME="powerlevel10k/powerlevel10k"
|
|||
# move_curor_to_bottom
|
||||
# add-zsh-hook preexec move_curor_to_bottom
|
||||
|
||||
# Uncomment the following line if you want to change the command execution time
|
||||
# stamp shown in the history command output.
|
||||
# You can set one of the optional three formats:
|
||||
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
|
||||
# or set a custom format using the strftime function format specifications,
|
||||
# see 'man strftime' for details.
|
||||
# Uncomment to change the command execution time stamp shown in history command output
|
||||
# HIST_STAMPS="mm/dd/yyyy"
|
||||
|
||||
# Would you like to use another custom folder than $ZSH/custom?
|
||||
HISTFILE=~/.zsh_history
|
||||
HISTSIZE=1000
|
||||
SAVEHIST=10000
|
||||
|
||||
# Set custom folder for oh-my-zsh, if desired
|
||||
ZSH_CUSTOM=$HOME/.oh-my-zsh/custom
|
||||
|
||||
# Which plugins would you like to load?
|
||||
# Standard plugins can be found in $ZSH/plugins/
|
||||
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
|
||||
# Example format: plugins=(rails git textmate ruby lighthouse)
|
||||
# Add wisely, as too many plugins slow down shell startup.
|
||||
# Plugins to load
|
||||
plugins=(
|
||||
git
|
||||
docker
|
||||
zsh-syntax-highlighting
|
||||
zsh-autosuggestions
|
||||
macos
|
||||
autoupdate
|
||||
git
|
||||
docker
|
||||
zsh-syntax-highlighting
|
||||
zsh-autosuggestions
|
||||
macos
|
||||
autoupdate
|
||||
zoxide
|
||||
eza
|
||||
)
|
||||
|
||||
export ZSH_AUTOSUGGEST_STRATEGY=(
|
||||
|
|
@ -101,16 +97,14 @@ export ZSH_AUTOSUGGEST_STRATEGY=(
|
|||
completion
|
||||
)
|
||||
|
||||
# Source oh-my-zsh.sh
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
# User configuration
|
||||
source ~/.zprofile
|
||||
# export MANPATH="/usr/local/man:$MANPATH"
|
||||
|
||||
# You may need to manually set your language environment
|
||||
# export LANG=en_US.UTF-8
|
||||
|
||||
# Preferred editor for local and remote sessions
|
||||
# Set preferred editor for local and remote sessions
|
||||
# if [[ -n $SSH_CONNECTION ]]; then
|
||||
# export EDITOR='vim'
|
||||
# else
|
||||
|
|
@ -120,20 +114,17 @@ source ~/.zprofile
|
|||
# Compilation flags
|
||||
# export ARCHFLAGS="-arch x86_64"
|
||||
|
||||
# Set personal aliases, overriding those provided by oh-my-zsh libs,
|
||||
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
|
||||
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
|
||||
# For a full list of active aliases, run `alias`.
|
||||
#
|
||||
# Set personal aliases
|
||||
# Example aliases
|
||||
# alias zshconfig="mate ~/.zshrc"
|
||||
# alias ohmyzsh="mate ~/.oh-my-zsh"
|
||||
# alias firefox="/Applications/Firefox.app/Contents/MacOS/firefox-bin -P profileName"
|
||||
|
||||
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||
# Customize prompt, if .p10k.zsh exists
|
||||
# [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||
|
||||
(( ! ${+functions[p10k]} )) || p10k finalize
|
||||
# Finalize p10k configuration if p10k function exists
|
||||
# (( ! ${+functions[p10k]} )) || p10k finalize
|
||||
|
||||
# >>> conda initialize >>>
|
||||
# !! Contents within this block are managed by 'conda init' !!
|
||||
|
|
@ -148,14 +139,15 @@ else
|
|||
fi
|
||||
fi
|
||||
unset __conda_setup
|
||||
|
||||
if [ -f "/usr/local/Caskroom/miniforge/base/etc/profile.d/mamba.sh" ]; then
|
||||
. "/usr/local/Caskroom/miniforge/base/etc/profile.d/mamba.sh"
|
||||
fi
|
||||
# <<< conda initialize <<<
|
||||
|
||||
eval "$(zoxide init --cmd cd zsh)"
|
||||
# Load completion scripts
|
||||
autoload -Uz compinit && compinit
|
||||
|
||||
# To customize prompt, run `p10k configure` or edit ~/.dotfiles/p10k/.p10k.zsh.
|
||||
[[ ! -f ~/.dotfiles/p10k/.p10k.zsh ]] || source ~/.dotfiles/p10k/.p10k.zsh
|
||||
# # Customize prompt, if .p10k.zsh in .dotfiles exists
|
||||
# [[ ! -f ~/.dotfiles/p10k/.p10k.zsh ]] || source ~/.dotfiles/p10k/.p10k.zsh
|
||||
|
||||
# Initialize Starship
|
||||
eval "$(starship init zsh)"
|
||||
export STARSHIP_CONFIG=~/.config/starship.toml
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue