Zshrc fixes for mac

This commit is contained in:
2026-03-12 19:26:49 +05:30
parent 8284d6b522
commit 7ad4baa14c
3 changed files with 6 additions and 224 deletions

12
.zshrc
View File

@@ -70,7 +70,7 @@ COMPLETION_WAITING_DOTS="true"
# Custom plugins may be added to $ZSH_CUSTOM/plugins/ # Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse) # Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup. # Add wisely, as too many plugins slow down shell startup.
plugins=(git zsh-autosuggestions starship) plugins=(git starship)
source $ZSH/oh-my-zsh.sh source $ZSH/oh-my-zsh.sh
@@ -82,11 +82,11 @@ source $ZSH/oh-my-zsh.sh
# export LANG=en_US.UTF-8 # export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions # Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim' export EDITOR='vim'
# else else
# export EDITOR='nvim' export EDITOR='nvim'
# fi fi
# Compilation flags # Compilation flags
# export ARCHFLAGS="-arch $(uname -m)" # export ARCHFLAGS="-arch $(uname -m)"

174
2q
View File

@@ -1,174 +0,0 @@
local map = vim.keymap.set
local opts = { noremap = true, silent = true }
map("n", "<Esc>", "<cmd>nohlsearch<CR>")
-- Diagnostic keymaps
-- map("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
-- is not what someone will guess without a bit more experience.
--
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
-- or just use <C-\><C-n> to exit terminal mode
map("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
map("n", "<leader>-", "<cmd>Oil <CR>", { desc = "Open parent directory" })
-- Create a new buffer
map("n", "<leader>b", "<cmd> enew <CR>", { desc = "new buffer" })
map("n", "<leader>U", "<cmd> Telescope undo<CR>", { desc = "Telescope Undo" })
-- Toggle comment
map("n", "<leader>/", function()
require("Comment.api").toggle.linewise.current()
end, { desc = "Toggle comment line" })
map("n", "<leader>cb", function()
require("Comment.api").toggle.blockwise.current()
end, { desc = "Toggle comment block" })
map(
"v",
"<leader>/",
"<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
{ desc = "Toggle comment line" }
)
-- ============================================
-- GitHub Copilot Keybindings
-- ============================================
-- Copilot suggestions (in insert mode)
-- Note: These are handled by the plugin config above, but listed here for reference
-- <M-l> Accept suggestion (Alt+l)
-- <M-]> Next suggestion (Alt+])
-- <M-[> Previous suggestion (Alt+[)
-- <C-]> Dismiss suggestion (Ctrl+])
-- Copilot Chat - Quick Actions
map("n", "<leader>jj", "<cmd>CopilotChatToggle<CR>", { desc = "Toggle Copilot Chat" })
map("n", "<leader>jo", "<cmd>CopilotChat<CR>", { desc = "Open Copilot Chat" })
map("n", "<leader>jx", "<cmd>CopilotChatClose<CR>", { desc = "Close Copilot Chat" })
map("n", "<leader>jr", "<cmd>CopilotChatReset<CR>", { desc = "Reset Chat History" })
-- Copilot Chat - Code Actions (work in normal and visual mode)
map({ "n", "v" }, "<leader>je", "<cmd>CopilotChatExplain<CR>", { desc = "Explain Code" })
map({ "n", "v" }, "<leader>jt", "<cmd>CopilotChatTests<CR>", { desc = "Generate Tests" })
map({ "n", "v" }, "<leader>jf", "<cmd>CopilotChatFix<CR>", { desc = "Fix Code" })
map({ "n", "v" }, "<leader>jO", "<cmd>CopilotChatOptimize<CR>", { desc = "Optimize Code" })
map({ "n", "v" }, "<leader>jd", "<cmd>CopilotChatDocs<CR>", { desc = "Generate Documentation" })
map({ "n", "v" }, "<leader>jv", "<cmd>CopilotChatReview<CR>", { desc = "Review Code" })
-- Copilot Chat - Git Integration
map("n", "<leader>jc", "<cmd>CopilotChatCommit<CR>", { desc = "Generate Commit Message" })
map("n", "<leader>jC", "<cmd>CopilotChatCommitStaged<CR>", { desc = "Commit Message (Staged)" })
-- Copilot Chat - Quick Question
map("n", "<leader>jq", function()
local input = vim.fn.input("Quick Chat: ")
if input ~= "" then
require("CopilotChat").ask(input)
end
end, { desc = "Quick Question to Copilot" })
-- Copilot Chat - Visual Mode
map("v", "<leader>jv", ":CopilotChatVisual ", { desc = "Chat with Selection" })
map("v", "<leader>ji", ":CopilotChatInline<CR>", { desc = "Inline Chat" })
-- Copilot Chat - Buffer Context
map("n", "<leader>jb", function()
local input = vim.fn.input("Ask Copilot (Buffer Context): ")
if input ~= "" then
require("CopilotChat").ask(input, { selection = require("CopilotChat.select").buffer })
end
end, { desc = "Ask About Entire Buffer" })
-- Copilot Chat - Diagnostic Help
map("n", "<leader>jD", function()
require("CopilotChat").ask("Help with diagnostics", {
selection = require("CopilotChat.select").diagnostics,
})
end, { desc = "Fix Diagnostics with Copilot" })
-- Copilot Panel Toggle (alternative suggestion view)
map("n", "<leader>jp", "<cmd>Copilot panel<CR>", { desc = "Open Copilot Panel" })
-- line numbers
map("n", "<leader>nn", "<cmd> set nu! <CR>", { desc = "Toggle line number" })
map("n", "<leader>nr", "<cmd> set rnu! <CR>", { desc = "Toggle relative number" })
-- TIP: Disable arrow keys in normal mode
map("n", "<left>", '<cmd>echo "Use h to move!!"<CR>')
map("n", "<right>", '<cmd>echo "Use l to move!!"<CR>')
map("n", "<up>", '<cmd>echo "Use k to move!!"<CR>')
map("n", "<down>", '<cmd>echo "Use j to move!!"<CR>')
map("n", "<leader>wk", "<cmd>WhichKey<CR>", { desc = "Which-Key all keymaps" })
map("n", "<leader>wK", function()
local input = vim.fn.input("WhichKey: ")
vim.cmd("WhichKey" .. input)
end, { desc = "Which-Key query lookup" })
map("n", "<leader>gs", "<cmd>Git status<CR>", { desc = "Git status" })
-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
--
-- See `:help wincmd` for a list of all window commands
map("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
map("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
map("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
map("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
map("n", "<S-tab>", function()
require("nvchad.tabufline").prev()
end, opts)
map("n", "<tab>", function()
require("nvchad.tabufline").next()
end, opts)
map("n", "<leader>q", function()
require("nvchad.tabufline").close_buffer()
end, opts)
map("n", "<A-j>", "<cmd>:m .+1<CR>==", opts)
map("n", "<A-k>", "<cmd>:m .-2<CR>==", opts)
map("i", "<A-j>", "<ESC><cmd>:m .+1<CR>==gi", opts)
map("i", "<A-k>", "<ESC><cmd>:m .-2<CR>==gi", opts)
map("v", "<A-j>", ":m '>+1<CR>gv=gv", opts)
map("v", "<A-k>", ":m '<-2<CR>gv=gv", opts)
map("n", "<leader>cc", function()
local ok, start = require("indent_blankline.utils").get_current_context(
vim.g.indent_blankline_context_patterns,
vim.g.indent_blankline_use_treesitter_scope
)
if ok then
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 })
vim.cmd([[normal! _]])
end
end, { desc = "Jump to current context" })
map("n", "<leader>cr, "<cmd>cc -o % %.c <CR>", {desc = "Run C program"})
-- greatest remap ever
map("x", "<leader>p", [["_dP]])
map("n", "<leader>xx", "<cmd>!chmod +x %<CR>", { silent = true })
map("i", "<C-c>", "<Esc>", opts)
-- next greatest remap ever : asbjornHaland
map({ "n", "v" }, "<leader>y", [["+y]])
vim.keymap.set("n", "Q", "<nop>")
vim.keymap.set("n", "Q!", "<nop>")
vim.keymap.set("n", "Wq", "<nop>")
map("n", "<leader>Y", [["+Y]])
map("n", "<leader>C", "<cmd> Cheat <CR>")
map("n", "<leader>fa", "<cmd> lua require('fzf-lua').files() <CR>", { desc = "FZF find files" })
map("n", "<leader>ff", "<cmd> lua require('fzf-lua').files() <CR>", { desc = "FZF find files" })
map("n", "<leader>fq", "<cmd> lua require('fzf-lua').quickfix() <CR>", { desc = "FZF quickfix" })
map("n", "<leader>fb", "<cmd> lua require('fzf-lua').buffers() <CR>", { desc = "FZF find buffers" })
map("n", "<leader>fZ", "<cmd> lua require('fzf-lua').lgerp_curbuf() <CR>", { desc = "FZF Live grep current buffer" })
map("n", "<leader>fd", "<cmd> lua require('fzf-lua').oldfiles() <CR>", { desc = "FZF opened files history" })
map("n", "<leader>fm", "<cmd> lua require('fzf-lua').marks() <CR>", { desc = "FZF marks" })
map("n", "<leader>fw", "<cmd> lua require('fzf-lua').live_grep() <CR>", { desc = "FZF live grep" })
map("n", "<leader>fg", "<cmd> lua require('fzf-lua').git_Commits() <CR>", { desc = "FZF Git commits" })
map("n", "<leader>fG", "<cmd> lua require('fzf-lua').git_bcommits() <CR>", { desc = "FZF Git commits" })
map("n", "<leader>fs", "<cmd> lua require('fzf-lua').git_status() <CR>", { desc = "FZF Git commits" })
map("n", "<leader>fp", "<cmd> lua require('fzf-lua').manpages() <CR>", { desc = "FZF Manpages" })

View File

@@ -42,50 +42,6 @@ case "$TERM" in
xterm-color|*-256color) color_prompt=yes;; xterm-color|*-256color) color_prompt=yes;;
esac esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors # colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'