Поправил zshrc и neovim
This commit is contained in:
parent
458d6c6fff
commit
0f55d7e47d
6 changed files with 151 additions and 129 deletions
|
@ -16,3 +16,4 @@ require("keymaps")
|
||||||
require("autocommands")
|
require("autocommands")
|
||||||
require("lsp")
|
require("lsp")
|
||||||
require("dap")
|
require("dap")
|
||||||
|
require("colors")
|
||||||
|
|
|
@ -76,24 +76,6 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "FileReadPost" }, {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("BufEnter", {
|
|
||||||
pattern = "*",
|
|
||||||
callback = function()
|
|
||||||
vim.defer_fn(function()
|
|
||||||
vim.cmd("normal! zR")
|
|
||||||
end, 100)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("BufWinEnter", {
|
|
||||||
pattern = "*",
|
|
||||||
callback = function()
|
|
||||||
vim.schedule(function()
|
|
||||||
vim.cmd("normal! zR")
|
|
||||||
end)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("BufEnter", {
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
callback = function()
|
callback = function()
|
||||||
if vim.bo.filetype == "NvimTree" or vim.fn.expand("%") == "" then
|
if vim.bo.filetype == "NvimTree" or vim.fn.expand("%") == "" then
|
||||||
|
@ -117,6 +99,22 @@ vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Автоматический вход в insert mode при открытии терминала
|
||||||
|
vim.api.nvim_create_autocmd({ "BufWinEnter", "WinEnter" }, {
|
||||||
|
pattern = "term://*",
|
||||||
|
callback = function()
|
||||||
|
vim.cmd("startinsert")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Автоматический выход из insert mode при уходе с терминала
|
||||||
|
vim.api.nvim_create_autocmd("BufLeave", {
|
||||||
|
pattern = "term://*",
|
||||||
|
callback = function()
|
||||||
|
vim.cmd("stopinsert")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- vim.api.nvim_create_autocmd("InsertEnter", {
|
-- vim.api.nvim_create_autocmd("InsertEnter", {
|
||||||
-- pattern = "*",
|
-- pattern = "*",
|
||||||
-- command = "set norelativenumber",
|
-- command = "set norelativenumber",
|
||||||
|
|
39
nvim/lua/colors.lua
Normal file
39
nvim/lua/colors.lua
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
require("onedark").setup({
|
||||||
|
style = "darker",
|
||||||
|
transparent = false, -- Show/hide background
|
||||||
|
term_colors = true, -- Change terminal color as per the selected theme style
|
||||||
|
ending_tildes = true, -- Show the end-of-buffer tildes. By default they are hidden
|
||||||
|
cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu
|
||||||
|
|
||||||
|
-- toggle theme style ---
|
||||||
|
toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
|
||||||
|
toggle_style_list = { "dark", "darker", "cool", "deep", "warm", "warmer", "light" }, -- List of styles to toggle between
|
||||||
|
|
||||||
|
-- Change code style ---
|
||||||
|
-- Options are italic, bold, underline, none
|
||||||
|
-- You can configure multiple style with comma separated, For e.g., keywords = 'italic,bold'
|
||||||
|
code_style = {
|
||||||
|
comments = "italic",
|
||||||
|
keywords = "none",
|
||||||
|
functions = "none",
|
||||||
|
strings = "none",
|
||||||
|
variables = "none",
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Lualine options --
|
||||||
|
lualine = {
|
||||||
|
transparent = false, -- lualine center bar transparency
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Custom Highlights --
|
||||||
|
colors = {}, -- Override default colors
|
||||||
|
highlights = {}, -- Override highlight groups
|
||||||
|
|
||||||
|
-- Plugins Config --
|
||||||
|
diagnostics = {
|
||||||
|
darker = true, -- darker colors for diagnostic
|
||||||
|
undercurl = true, -- use undercurl instead of underline for diagnostics
|
||||||
|
background = true, -- use background color for virtual text
|
||||||
|
},
|
||||||
|
})
|
||||||
|
require("onedark").load()
|
|
@ -15,13 +15,19 @@ map("i", "<End>", "<C-o>$", { noremap = true, silent = true })
|
||||||
-- Фикс для визуального режима
|
-- Фикс для визуального режима
|
||||||
map("v", "i", "<S-i>", { noremap = true, silent = true })
|
map("v", "i", "<S-i>", { noremap = true, silent = true })
|
||||||
map("v", "a", "<S-a>", { noremap = true, silent = true })
|
map("v", "a", "<S-a>", { noremap = true, silent = true })
|
||||||
|
map("v", "J", ":m '>+1<CR>gv=gv", { noremap = true, silent = true })
|
||||||
|
map("v", "K", ":m '<-2<CR>gv=gv", { noremap = true, silent = true })
|
||||||
|
map("v", "<", "<gv", { noremap = true, silent = true })
|
||||||
|
map("v", ">", ">gv", { noremap = true, silent = true })
|
||||||
|
|
||||||
-- Управление буферами --
|
-- Управление буферами --
|
||||||
kmap("n", "<leader>bn", "<cmd>bnext<CR>", { noremap = true, silent = true, desc = "Next buffer" })
|
kmap("n", "<leader>bn", "<cmd>bnext<CR>", { noremap = true, silent = true, desc = "Next buffer" })
|
||||||
kmap("n", "<leader>bp", "<cmd>bprevious<CR>", { noremap = true, silent = true, desc = "Previous buffer" })
|
kmap("n", "<leader>bp", "<cmd>bprevious<CR>", { noremap = true, silent = true, desc = "Previous buffer" })
|
||||||
kmap("n", "<leader>bd", "<cmd>bdelete<CR>", { noremap = true, silent = true, desc = "Delete buffer" })
|
kmap("n", "<leader>bd", "<cmd>bdelete<CR>", { noremap = true, silent = true, desc = "Delete buffer" })
|
||||||
kmap("n", "<leader>w", "<cmd>wa<CR>", { noremap = true, silent = true, desc = "Save all files" })
|
kmap("n", "<leader>w", "<cmd>wa<CR>", { noremap = true, silent = true, desc = "Save all files" })
|
||||||
kmap("n", "qq", "<cmd>q<CR>")
|
kmap("n", "qq", "<cmd>q<CR>", { noremap = true, silent = true, desc = "Exit" })
|
||||||
|
kmap("n", "<leader>vs", "<cmd>vsplit<CR>", { noremap = true, silent = true, desc = "Vertical split" })
|
||||||
|
|
||||||
-- Управление вкладками --
|
-- Управление вкладками --
|
||||||
kmap("n", "<A-Right>", ":tabnext<CR>", { noremap = true, silent = true, desc = "Next tab" })
|
kmap("n", "<A-Right>", ":tabnext<CR>", { noremap = true, silent = true, desc = "Next tab" })
|
||||||
kmap("n", "<A-Left>", ":tabprevious<CR>", { noremap = true, silent = true, desc = "Previous tab" })
|
kmap("n", "<A-Left>", ":tabprevious<CR>", { noremap = true, silent = true, desc = "Previous tab" })
|
||||||
|
@ -35,19 +41,20 @@ end
|
||||||
|
|
||||||
-- Файловый менеджер --
|
-- Файловый менеджер --
|
||||||
kmap("n", "<F3>", ":NvimTreeToggle<CR>", { noremap = true, silent = true, desc = "Toggle file tree" })
|
kmap("n", "<F3>", ":NvimTreeToggle<CR>", { noremap = true, silent = true, desc = "Toggle file tree" })
|
||||||
kmap("n", "<leader>tt", ":NvimTreeToggle<CR>", { noremap = true, silent = true, desc = "Toggle file tree" })
|
-- kmap("n", "<leader>tt", ":NvimTreeToggle<CR>", { noremap = true, silent = true, desc = "Toggle file tree" })
|
||||||
|
|
||||||
|
kmap("n", "<leader>tt", ":split<CR>:terminal<CR>:startinsert<CR>", { noremap = true, silent = true })
|
||||||
|
|
||||||
-- Поиск с Telescope --
|
-- Поиск с Telescope --
|
||||||
kmap("n", "<leader>ff", "<cmd>Telescope find_files<CR>", { noremap = true, silent = true, desc = "Find files" })
|
kmap("n", "<leader>ff", "<cmd>Telescope find_files<CR>", { noremap = true, silent = true, desc = "Find files" })
|
||||||
kmap("n", "<leader>fg", "<cmd>Telescope live_grep<CR>", { noremap = true, silent = true, desc = "Live grep" })
|
kmap("n", "<leader>fg", "<cmd>Telescope live_grep<CR>", { noremap = true, silent = true, desc = "Live grep" })
|
||||||
kmap("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { noremap = true, silent = true, desc = "Find buffers" })
|
kmap("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { noremap = true, silent = true, desc = "Find buffers" })
|
||||||
|
kmap("n", "<leader>fe", "<cmd>Telescope file_browser<CR>", { noremap = true, silent = true, desc = "File browser" })
|
||||||
|
|
||||||
-- LSP функции --
|
-- LSP функции --
|
||||||
kmap("n", "<leader>e", vim.diagnostic.open_float, { noremap = true, silent = true, desc = "Show diagnostics" })
|
kmap("n", "<leader>e", vim.diagnostic.open_float, { noremap = true, silent = true, desc = "Show diagnostics" })
|
||||||
kmap("n", "[d", vim.diagnostic.goto_prev, { noremap = true, silent = true, desc = "Previous diagnostic" })
|
kmap("n", "d[", vim.diagnostic.goto_prev, { noremap = true, silent = true, desc = "Previous diagnostic" })
|
||||||
kmap("n", "]d", vim.diagnostic.goto_next, { noremap = true, silent = true, desc = "Next diagnostic" })
|
kmap("n", "d]", vim.diagnostic.goto_next, { noremap = true, silent = true, desc = "Next diagnostic" })
|
||||||
kmap("n", "<leader>q", vim.diagnostic.setloclist, { noremap = true, silent = true, desc = "Add to location list" })
|
|
||||||
|
|
||||||
kmap("n", "gD", vim.lsp.buf.declaration, { noremap = true, silent = true, desc = "Go to declaration" })
|
kmap("n", "gD", vim.lsp.buf.declaration, { noremap = true, silent = true, desc = "Go to declaration" })
|
||||||
kmap("n", "gd", vim.lsp.buf.definition, { noremap = true, silent = true, desc = "Go to definition" })
|
kmap("n", "gd", vim.lsp.buf.definition, { noremap = true, silent = true, desc = "Go to definition" })
|
||||||
|
@ -88,7 +95,12 @@ end)
|
||||||
kmap("n", "<F12>", function()
|
kmap("n", "<F12>", function()
|
||||||
require("dap").step_out()
|
require("dap").step_out()
|
||||||
end)
|
end)
|
||||||
kmap("n", "<leader>dt", "<cmd>lua require'dapui'.toggle()<CR>", { noremap = true, silent = true, desc = "Toggle debug UI" })
|
kmap(
|
||||||
|
"n",
|
||||||
|
"<leader>dt",
|
||||||
|
"<cmd>lua require'dapui'.toggle()<CR>",
|
||||||
|
{ noremap = true, silent = true, desc = "Toggle debug UI" }
|
||||||
|
)
|
||||||
kmap("n", "<leader>dc", function()
|
kmap("n", "<leader>dc", function()
|
||||||
require("dap").continue()
|
require("dap").continue()
|
||||||
end)
|
end)
|
||||||
|
@ -102,7 +114,6 @@ kmap("n", "<leader>st", function()
|
||||||
require("dap").step_out()
|
require("dap").step_out()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
kmap("n", "<Leader>b", function()
|
kmap("n", "<Leader>b", function()
|
||||||
require("dap").toggle_breakpoint()
|
require("dap").toggle_breakpoint()
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -3,15 +3,7 @@ return require("packer").startup({
|
||||||
use("wbthomason/packer.nvim")
|
use("wbthomason/packer.nvim")
|
||||||
use("nvim-lua/plenary.nvim")
|
use("nvim-lua/plenary.nvim")
|
||||||
use("neovim/nvim-lspconfig")
|
use("neovim/nvim-lspconfig")
|
||||||
use({
|
use("navarasu/onedark.nvim")
|
||||||
"srt0/codescope.nvim",
|
|
||||||
config = function()
|
|
||||||
require("codescope").setup({
|
|
||||||
transparent = false, -- Set to true for transparency
|
|
||||||
})
|
|
||||||
vim.cmd.colorscheme("codescope")
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
use("Snyssfx/goerr-nvim")
|
use("Snyssfx/goerr-nvim")
|
||||||
use({
|
use({
|
||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
|
@ -22,26 +14,6 @@ return require("packer").startup({
|
||||||
use({
|
use({
|
||||||
"rcarriga/nvim-dap-ui",
|
"rcarriga/nvim-dap-ui",
|
||||||
requires = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
|
requires = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
|
||||||
config = function()
|
|
||||||
local dap, dapui = require("dap"), require("dapui")
|
|
||||||
dapui.setup()
|
|
||||||
dap.listeners.before.attach.dapui_config = function()
|
|
||||||
dapui.open()
|
|
||||||
vim.cmd(":NvimTreeClose<CR>")
|
|
||||||
end
|
|
||||||
dap.listeners.before.launch.dapui_config = function()
|
|
||||||
dapui.open()
|
|
||||||
vim.cmd(":NvimTreeClose<CR>")
|
|
||||||
end
|
|
||||||
dap.listeners.before.event_terminated.dapui_config = function()
|
|
||||||
dapui.close()
|
|
||||||
vim.cmd(":NvimTreeOpen<CR>")
|
|
||||||
end
|
|
||||||
dap.listeners.before.event_exited.dapui_config = function()
|
|
||||||
dapui.close()
|
|
||||||
vim.cmd(":NvimTreeOpen<CR>")
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
use({
|
use({
|
||||||
"leoluz/nvim-dap-go",
|
"leoluz/nvim-dap-go",
|
||||||
|
@ -76,11 +48,13 @@ return require("packer").startup({
|
||||||
require("plugins.treesitter")
|
require("plugins.treesitter")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
use({ "nvim-telescope/telescope-file-browser.nvim" })
|
||||||
use({
|
use({
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("plugins.telescope")
|
require("plugins.telescope")
|
||||||
end,
|
end,
|
||||||
|
requires = "nvim-lua/plenary.nvim",
|
||||||
})
|
})
|
||||||
use({
|
use({
|
||||||
"nvim-tree/nvim-tree.lua",
|
"nvim-tree/nvim-tree.lua",
|
||||||
|
|
149
zsh/zshrc
149
zsh/zshrc
|
@ -49,7 +49,7 @@ alias cp="cp -i"
|
||||||
alias gitpush="git add . && git commit --amend --no-edit && git push -f"
|
alias gitpush="git add . && git commit --amend --no-edit && git push -f"
|
||||||
alias yu="ssh-add -e /usr/lib/x86_64-linux-gnu/libykcs11.so; ssh-add -s /usr/lib/x86_64-linux-gnu/libykcs11.so"
|
alias yu="ssh-add -e /usr/lib/x86_64-linux-gnu/libykcs11.so; ssh-add -s /usr/lib/x86_64-linux-gnu/libykcs11.so"
|
||||||
alias n="nvim"
|
alias n="nvim"
|
||||||
alias n.="nvim ."
|
alias nv="nvim ."
|
||||||
alias cp="cp -i"
|
alias cp="cp -i"
|
||||||
alias df="df -h"
|
alias df="df -h"
|
||||||
alias free="free -m"
|
alias free="free -m"
|
||||||
|
@ -104,14 +104,84 @@ WORDCHARS=${WORDCHARS//\/[&.;]}
|
||||||
autoload -U compinit colors zcalc
|
autoload -U compinit colors zcalc
|
||||||
compinit -d
|
compinit -d
|
||||||
|
|
||||||
|
# Runs before showing the prompt
|
||||||
|
function mzc_termsupport_precmd {
|
||||||
|
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||||
|
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
|
||||||
|
}
|
||||||
|
|
||||||
|
# Runs before executing the command
|
||||||
|
function mzc_termsupport_preexec {
|
||||||
|
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||||
|
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
# split command into array of arguments
|
||||||
|
local -a cmdargs
|
||||||
|
cmdargs=("${(z)2}")
|
||||||
|
# if running fg, extract the command from the job description
|
||||||
|
if [[ "${cmdargs[1]}" = fg ]]; then
|
||||||
|
# get the job id from the first argument passed to the fg command
|
||||||
|
local job_id jobspec="${cmdargs[2]#%}"
|
||||||
|
# logic based on jobs arguments:
|
||||||
|
# http://zsh.sourceforge.net/Doc/Release/Jobs-_0026-Signals.html#Jobs
|
||||||
|
# https://www.zsh.org/mla/users/2007/msg00704.html
|
||||||
|
case "$jobspec" in
|
||||||
|
<->) # %number argument:
|
||||||
|
# use the same <number> passed as an argument
|
||||||
|
job_id=${jobspec} ;;
|
||||||
|
""|%|+) # empty, %% or %+ argument:
|
||||||
|
# use the current job, which appears with a + in $jobstates:
|
||||||
|
# suspended:+:5071=suspended (tty output)
|
||||||
|
job_id=${(k)jobstates[(r)*:+:*]} ;;
|
||||||
|
-) # %- argument:
|
||||||
|
# use the previous job, which appears with a - in $jobstates:
|
||||||
|
# suspended:-:6493=suspended (signal)
|
||||||
|
job_id=${(k)jobstates[(r)*:-:*]} ;;
|
||||||
|
[?]*) # %?string argument:
|
||||||
|
# use $jobtexts to match for a job whose command *contains* <string>
|
||||||
|
job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;;
|
||||||
|
*) # %string argument:
|
||||||
|
# use $jobtexts to match for a job whose command *starts with* <string>
|
||||||
|
job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# override preexec function arguments with job command
|
||||||
|
if [[ -n "${jobtexts[$job_id]}" ]]; then
|
||||||
|
1="${jobtexts[$job_id]}"
|
||||||
|
2="${jobtexts[$job_id]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# cmd name only, or if this is sudo or ssh, the next cmd
|
||||||
|
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
|
||||||
|
local LINE="${2:gs/%/%%}"
|
||||||
|
|
||||||
|
title '$CMD' '%100>...>$LINE%<<'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Emits the control sequence to notify many terminal emulators
|
||||||
|
# of the cwd
|
||||||
|
#
|
||||||
|
# Identifies the directory using a file: URI scheme, including
|
||||||
|
# the host name to disambiguate local vs. remote paths.
|
||||||
|
function mzc_termsupport_cwd {
|
||||||
|
# Percent-encode the host and path names.
|
||||||
|
local URL_HOST URL_PATH
|
||||||
|
URL_HOST="$(zsh_urlencode -P $HOST)" || return 1
|
||||||
|
URL_PATH="$(zsh_urlencode -P $PWD)" || return 1
|
||||||
|
|
||||||
|
# common control sequence (OSC 7) to set current host and path
|
||||||
|
printf "\e]7;%s\a" "file://${URL_HOST}${URL_PATH}"
|
||||||
|
}
|
||||||
|
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
#add-zsh-hook precmd mzc_termsupport_precmd
|
add-zsh-hook precmd mzc_termsupport_precmd
|
||||||
#add-zsh-hook preexec mzc_termsupport_preexec
|
add-zsh-hook preexec mzc_termsupport_preexec
|
||||||
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
|
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
|
||||||
# i.e. when a script or function changes directory without `cd -q`, chpwd
|
# i.e. when a script or function changes directory without `cd -q`, chpwd
|
||||||
# will be called the output may be swallowed by the script or function.
|
# will be called the output may be swallowed by the script or function.
|
||||||
#add-zsh-hook precmd mzc_termsupport_cwd
|
add-zsh-hook precmd mzc_termsupport_cwd
|
||||||
|
|
||||||
source ~/.config/zsh/conf.d/*.zsh
|
source ~/.config/zsh/conf.d/*.zsh
|
||||||
|
|
||||||
|
@ -223,62 +293,6 @@ function title {
|
||||||
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
|
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
|
||||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
|
ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
|
||||||
|
|
||||||
# Runs before showing the prompt
|
|
||||||
function mzc_termsupport_precmd {
|
|
||||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
|
||||||
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
|
|
||||||
}
|
|
||||||
|
|
||||||
# Runs before executing the command
|
|
||||||
function mzc_termsupport_preexec {
|
|
||||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
|
||||||
|
|
||||||
emulate -L zsh
|
|
||||||
|
|
||||||
# split command into array of arguments
|
|
||||||
local -a cmdargs
|
|
||||||
cmdargs=("${(z)2}")
|
|
||||||
# if running fg, extract the command from the job description
|
|
||||||
if [[ "${cmdargs[1]}" = fg ]]; then
|
|
||||||
# get the job id from the first argument passed to the fg command
|
|
||||||
local job_id jobspec="${cmdargs[2]#%}"
|
|
||||||
# logic based on jobs arguments:
|
|
||||||
# http://zsh.sourceforge.net/Doc/Release/Jobs-_0026-Signals.html#Jobs
|
|
||||||
# https://www.zsh.org/mla/users/2007/msg00704.html
|
|
||||||
case "$jobspec" in
|
|
||||||
<->) # %number argument:
|
|
||||||
# use the same <number> passed as an argument
|
|
||||||
job_id=${jobspec} ;;
|
|
||||||
""|%|+) # empty, %% or %+ argument:
|
|
||||||
# use the current job, which appears with a + in $jobstates:
|
|
||||||
# suspended:+:5071=suspended (tty output)
|
|
||||||
job_id=${(k)jobstates[(r)*:+:*]} ;;
|
|
||||||
-) # %- argument:
|
|
||||||
# use the previous job, which appears with a - in $jobstates:
|
|
||||||
# suspended:-:6493=suspended (signal)
|
|
||||||
job_id=${(k)jobstates[(r)*:-:*]} ;;
|
|
||||||
[?]*) # %?string argument:
|
|
||||||
# use $jobtexts to match for a job whose command *contains* <string>
|
|
||||||
job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;;
|
|
||||||
*) # %string argument:
|
|
||||||
# use $jobtexts to match for a job whose command *starts with* <string>
|
|
||||||
job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# override preexec function arguments with job command
|
|
||||||
if [[ -n "${jobtexts[$job_id]}" ]]; then
|
|
||||||
1="${jobtexts[$job_id]}"
|
|
||||||
2="${jobtexts[$job_id]}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# cmd name only, or if this is sudo or ssh, the next cmd
|
|
||||||
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
|
|
||||||
local LINE="${2:gs/%/%%}"
|
|
||||||
|
|
||||||
title '$CMD' '%100>...>$LINE%<<'
|
|
||||||
}
|
|
||||||
|
|
||||||
# URL-encode a string
|
# URL-encode a string
|
||||||
#
|
#
|
||||||
# Encodes a string using RFC 2396 URL-encoding (%-escaped).
|
# Encodes a string using RFC 2396 URL-encoding (%-escaped).
|
||||||
|
@ -352,21 +366,6 @@ function zsh_urlencode() {
|
||||||
echo -E "$url_str"
|
echo -E "$url_str"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Emits the control sequence to notify many terminal emulators
|
|
||||||
# of the cwd
|
|
||||||
#
|
|
||||||
# Identifies the directory using a file: URI scheme, including
|
|
||||||
# the host name to disambiguate local vs. remote paths.
|
|
||||||
function mzc_termsupport_cwd {
|
|
||||||
# Percent-encode the host and path names.
|
|
||||||
local URL_HOST URL_PATH
|
|
||||||
URL_HOST="$(zsh_urlencode -P $HOST)" || return 1
|
|
||||||
URL_PATH="$(zsh_urlencode -P $PWD)" || return 1
|
|
||||||
|
|
||||||
# common control sequence (OSC 7) to set current host and path
|
|
||||||
printf "\e]7;%s\a" "file://${URL_HOST}${URL_PATH}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -f env.sh ]; then
|
if [ -f env.sh ]; then
|
||||||
source ./env.sh
|
source ./env.sh
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue