diff options
| -rw-r--r-- | bash/.bashrc | 3 | ||||
| -rw-r--r-- | bootstrap.sh | 2 | ||||
| -rwxr-xr-x | deploy.py | 83 | ||||
| -rw-r--r-- | directoryinfo | 10 | ||||
| -rw-r--r-- | git/.gitconfig | 8 | ||||
| -rw-r--r-- | git/.gitconfig-macos | 5 | ||||
| -rw-r--r-- | info.yml | 95 | ||||
| -rw-r--r-- | nvim/init.vim | 12 | ||||
| -rw-r--r-- | requirements.txt | 2 | ||||
| -rw-r--r-- | tmux/.tmux.conf | 43 | ||||
| -rw-r--r-- | util/__pycache__/exceptions.cpython-310.pyc | bin | 0 -> 308 bytes | |||
| -rw-r--r-- | util/__pycache__/exceptions.cpython-39.pyc | bin | 0 -> 304 bytes | |||
| -rw-r--r-- | util/__pycache__/helpers.cpython-39.pyc | bin | 0 -> 369 bytes | |||
| -rw-r--r-- | util/__pycache__/runners.cpython-310.pyc | bin | 0 -> 402 bytes | |||
| -rw-r--r-- | util/__pycache__/runners.cpython-39.pyc | bin | 0 -> 1002 bytes | |||
| -rw-r--r-- | util/exceptions.py | 2 | ||||
| -rw-r--r-- | util/helpers.py | 13 | ||||
| -rw-r--r-- | util/runners.py | 29 | ||||
| -rw-r--r-- | vim/.vimrc | 4 | ||||
| -rw-r--r-- | vim/nvim/init.lua | 218 | ||||
| -rw-r--r-- | vim/nvim/lua/plugins.lua | 24 | ||||
| -rw-r--r-- | zsh/.zprofile | 6 | ||||
| -rw-r--r-- | zsh/.zshrc | 70 | ||||
| -rw-r--r-- | zsh/config/aliases.zsh | 18 | ||||
| -rw-r--r-- | zsh/config/environment.zsh | 12 | ||||
| -rw-r--r-- | zsh/config/prompt.zsh | 42 | ||||
| -rw-r--r-- | zsh/oh-my-zsh/iTerm2-ssh.zsh | 28 |
27 files changed, 581 insertions, 148 deletions
diff --git a/bash/.bashrc b/bash/.bashrc deleted file mode 100644 index cd973c3..0000000 --- a/bash/.bashrc +++ /dev/null @@ -1,3 +0,0 @@ -alias vim="nvim" -alias vi="nvim" -alias vimdiff="nvim -d" diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..05a7907 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,2 @@ +#!/bin/bash + @@ -1,45 +1,60 @@ #!/usr/bin/python3 -from os import listdir -from os.path import isfile, join, abspath -from shutil import copy2 -from pathlib import Path +import os -home = str(Path.home()) -contents = dict() -directory = dict() +from util.runners import run_step +from util.exceptions import StepFailedError +from util.helpers import check_preconditions -with open('directoryinfo') as f: - lines = f.readlines() - for line in lines: - line = line.replace('%HOME', home) +import yaml +from termcolor import colored - if (line.isspace()): +CWD = os.getcwd() + + +def get_sections_meeting_preconditions(yaml): + sections = {} + for key, section in yaml["sections"].items(): + if not check_preconditions(section): continue - if (line.startswith('#')): + sections[key] = section + + return sections + + +def run_section(title, section): + os.chdir(CWD) + if "directory" in section: + os.chdir(section["directory"]) + elif os.path.exists(title): + os.chdir(title) + + for step in section["steps"]: + if not check_preconditions(step): continue - parts = line.split() - if parts[0] == 'copycontent': - contents[parts[1]] = parts[2] - elif parts[0] == 'copyfulldir': - directory[parts[1]] = parts[2] - else: - print(f'directoryinfo: unknown directive \'{parts[0]}\'') + run_step(step) + + +with open("info.yml", "r") as f: + yaml = yaml.safe_load(f) -# Directive: copycontent -for d, t in contents.items(): - files = [f for f in listdir(d) if isfile(join(d, f))] - for file in files: - print(f'Copying {abspath(join(d, file))} to {abspath(join(t, file))}') - copy2(abspath(join(d, file)), join(t, file)) +sections = get_sections_meeting_preconditions(yaml) -# Directive: copyfulldir -for d, t in directory.items(): - files = [f for f in listdir(d) if isfile(join(d, f))] - print(f'Creating {t}') - Path(t).mkdir(parents=True, exist_ok=True) - for file in files: - print(f'Copying {abspath(join(d, file))} to {join(t, file)}') - copy2(abspath(join(d, file)), join(t, file)) +print("Sections to run: " + ", ".join( + map(lambda x: colored(x, "green"), sections.keys()) +)) +print() +section_count = 0 +total = len(sections.keys()) +for key, section in sections.items(): + section_count += 1 + print(colored(f"[{section_count}/{total}] ", "white", attrs=["bold"]) + + "Section " + + colored(key, "green")) + try: + run_section(key, section) + except StepFailedError as e: + print(colored("Step failed: ", "red") + str(e)) + print() diff --git a/directoryinfo b/directoryinfo deleted file mode 100644 index c6c08a0..0000000 --- a/directoryinfo +++ /dev/null @@ -1,10 +0,0 @@ -# ~ dotfiles -copycontent zsh %HOME -copycontent zsh/oh-my-zsh %HOME/.oh-my-zsh/custom -copycontent vim %HOME -copycontent git %HOME -copycontent bash %HOME - -# Directories -copyfulldir iterm2 %HOME/.iterm2 -copyfulldir nvim %HOME/.config/nvim diff --git a/git/.gitconfig b/git/.gitconfig deleted file mode 100644 index e509f48..0000000 --- a/git/.gitconfig +++ /dev/null @@ -1,8 +0,0 @@ -[user] - name = LMBishop - email = 13875753+LMBishop@users.noreply.github.com - signingkey = CBC4F221D82C72F9 -[gpg] - program = gpg -[core] - excludesfile = /Users/leonardo/.gitignore_global diff --git a/git/.gitconfig-macos b/git/.gitconfig-macos new file mode 100644 index 0000000..a2e5f31 --- /dev/null +++ b/git/.gitconfig-macos @@ -0,0 +1,5 @@ +[gpg] + program = gpg +[core] + excludesfile = /Users/leonardo/.gitignore_global + diff --git a/info.yml b/info.yml new file mode 100644 index 0000000..b182d9a --- /dev/null +++ b/info.yml @@ -0,0 +1,95 @@ +sections: + + # Installs brew on macOS + install-brew: + preconditions: + os: "macos" + not-installed: + - "brew" + steps: + - ==: run + command: "/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"" + + # Install oh-my-zsh + install-oh-my-zsh: + tags: ["config"] + preconditions: + not-present: + - ~/.oh-my-zsh + steps: + - ==: run + command: "sh -c \"$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)\"" + + # Copy zsh configurations + configure-zsh: + tags: ["config"] + directory: "zsh" + steps: + - ==: link + from: .zshrc + to: ~/.zshrc + - ==: run + command: "mkdir -p ~/.config/zsh" + - ==: link + from: config/aliases.zsh + to: ~/.config/zsh/aliases.zsh + - ==: link + from: config/environment.zsh + to: ~/.config/zsh/environment.zsh + - ==: link + from: config/prompt.zsh + to: ~/.config/zsh/prompt.zsh + notes: + - "Remember to change shell to zsh" + + # Copy vim configurations + configure-vim: + directory: "vim" + tags: ["config"] + steps: + - ==: run + command: "mkdir -p ~/.config/nvim/" + - ==: run + command: "mkdir -p ~/.config/nvim/lua" + - ==: link + from: .vimrc + to: ~/.vimrc + - ==: link + from: nvim/init.lua + to: ~/.config/nvim/init.lua + - ==: link + from: nvim/lua/plugins.lua + to: ~/.config/nvim/lua/plugins.lua + notes: + - "For nvim, run :PackerInstall" + + # Copy iterm2 configurations for macOS + configure-iterm2: + directory: "iterm2" + tags: ["config"] + preconditions: + os: "macos" + + # Copy iterm2 configurations for macOS + configure-git: + directory: "git" + tags: ["config"] + steps: + - ==: link + preconditions: + os: "macos" + from: .gitconfig-macos + to: ~/.gitconfig + - ==: link + from: .gitignore_global + to: ~/.gitignore_global + + # Copy tmux configurations + configure-tmux: + directory: "tmux" + tags: ["config"] + steps: + - ==: link + from: tmux.conf + to: ~/.tmux.conf + diff --git a/nvim/init.vim b/nvim/init.vim deleted file mode 100644 index d21d51e..0000000 --- a/nvim/init.vim +++ /dev/null @@ -1,12 +0,0 @@ -set runtimepath^=~/.vim runtimepath+=~/.vim/after -let &packpath = &runtimepath -source ~/.vimrc - -call plug#begin('~/.vim/plugged') - -Plug 'vim-airline/vim-airline' -Plug 'mfussenegger/nvim-lint' -Plug 'airblade/vim-gitgutter' - -call plug#end() - diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a6e4c4f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +PyYAML==6.0 +termcolor==2.1.1 diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf new file mode 100644 index 0000000..ee7985f --- /dev/null +++ b/tmux/.tmux.conf @@ -0,0 +1,43 @@ +bind-key Up select-pane -U +bind-key Down select-pane -D +bind-key Left select-pane -L +bind-key Right select-pane -R + +color_status_text="colour245" +color_window_off_status_bg="colour238" +color_light="white" #colour015 +color_dark="colour232" # black= colour232 +color_window_off_status_current_bg="colour254" + +bind -T root F12 \ + set prefix None \;\ + set key-table off \;\ + set status-style "fg=$color_status_text,bg=$color_window_off_status_bg" \;\ + if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\ + refresh-client -S \;\ + +bind -T off F12 \ + set -u prefix \;\ + set -u key-table \;\ + set -u status-style \;\ + set -u window-status-current-style \;\ + set -u window-status-current-format \;\ + refresh-client -S + +wg_is_keys_off="#[fg=$color_light,bg=$color_window_off_indicator]#([ $(tmux show-option -qv key-table) = 'off' ] && echo 'OFF')#[default]" + +set -g status-right " \"#{=21:pane_title}\" %H:%M %d-%b-%y" +set -g window-status-current-style "fg=$color_dark,bold,bg=$color_window_off_status_current_bg" +set -g window-status-current-format "#[fg=$color_window_off_status_bg,bg=$color_window_off_status_current_bg]$separator_powerline_right#[default] #I:#W* #[fg=$color_window_off_status_current_bg,bg=$color_window_off_status_bg]$separator_powerline_right#[default]" + +set -sg escape-time 10 + +set-option -g renumber-windows on +set -g base-index 1 +setw -g pane-base-index 1 + +set-window-option -g mode-keys vi + +set -g mouse on + +set-option -g history-limit 60000 diff --git a/util/__pycache__/exceptions.cpython-310.pyc b/util/__pycache__/exceptions.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..f00abf6 --- /dev/null +++ b/util/__pycache__/exceptions.cpython-310.pyc diff --git a/util/__pycache__/exceptions.cpython-39.pyc b/util/__pycache__/exceptions.cpython-39.pyc Binary files differnew file mode 100644 index 0000000..3e6ee44 --- /dev/null +++ b/util/__pycache__/exceptions.cpython-39.pyc diff --git a/util/__pycache__/helpers.cpython-39.pyc b/util/__pycache__/helpers.cpython-39.pyc Binary files differnew file mode 100644 index 0000000..2522a13 --- /dev/null +++ b/util/__pycache__/helpers.cpython-39.pyc diff --git a/util/__pycache__/runners.cpython-310.pyc b/util/__pycache__/runners.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..81b112d --- /dev/null +++ b/util/__pycache__/runners.cpython-310.pyc diff --git a/util/__pycache__/runners.cpython-39.pyc b/util/__pycache__/runners.cpython-39.pyc Binary files differnew file mode 100644 index 0000000..6e66aae --- /dev/null +++ b/util/__pycache__/runners.cpython-39.pyc diff --git a/util/exceptions.py b/util/exceptions.py new file mode 100644 index 0000000..b14896d --- /dev/null +++ b/util/exceptions.py @@ -0,0 +1,2 @@ +class StepFailedError(Exception): + pass diff --git a/util/helpers.py b/util/helpers.py new file mode 100644 index 0000000..5f970df --- /dev/null +++ b/util/helpers.py @@ -0,0 +1,13 @@ +import os + +OS_TYPE = os.getenv("OS_TYPE") + + +# Returns True if all preconditions pass +def check_preconditions(obj): + if "preconditions" in obj: + if ("os" in obj["preconditions"] + and obj["preconditions"]["os"] != OS_TYPE): + return False + + return True diff --git a/util/runners.py b/util/runners.py new file mode 100644 index 0000000..9252d86 --- /dev/null +++ b/util/runners.py @@ -0,0 +1,29 @@ +import os +import re +from util.exceptions import StepFailedError + +HOME = os.getenv("HOME") + + +def run_step(step): + step_type = step["=="] + + if step_type == "run": + do_run(step["command"]) + elif step_type == "link": + do_link(step["from"], step["to"]) + + +def do_run(command): + print(f"! {command}") + if not os.system(command) == 0: + raise StepFailedError("Non-zero return code") + + +def do_link(source, destination): + destination = re.sub(r"^~/", HOME + "/", destination) + print(f"Linking {source} -> {destination}") + try: + os.link(source, destination) + except Exception as e: + raise StepFailedError("Link raised exeption: " + str(e)) from e @@ -3,3 +3,7 @@ syntax on set number highlight LineNr ctermfg=darkgrey +filetype plugin indent on +set tabstop=4 +set shiftwidth=4 +set expandtab diff --git a/vim/nvim/init.lua b/vim/nvim/init.lua new file mode 100644 index 0000000..4d252b8 --- /dev/null +++ b/vim/nvim/init.lua @@ -0,0 +1,218 @@ + +require('plugins') + +vim.api.nvim_exec( +[[ +syntax on + +set number +highlight LineNr ctermfg=darkgrey + +filetype plugin indent on +set tabstop=4 +set shiftwidth=4 +set expandtab + +set signcolumn=number +let g:airline_theme='lucius' +]], +false) + +local capabilities = require("cmp_nvim_lsp").default_capabilities() + +-- Mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +local opts = { noremap=true, silent=true } +vim.keymap.set('n', '<space>e', "<cmd>TroubleToggle<cr>", opts) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) +vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts) + +-- Use an on_attach function to only map the following keys +-- after the language server attaches to the current buffer +local on_attach = function(client, bufnr) + -- Enable completion triggered by <c-x><c-o> + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap=true, silent=true, buffer=bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', '<space>wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts) +end + + +local lsp_flags = { + -- This is the default in Nvim 0.7+ + debounce_text_changes = 150, +} +require('lspconfig')['hls'].setup{ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, +} +require('lspconfig')['tsserver'].setup{ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, +} +require('lspconfig')['quick_lint_js'].setup{ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, +} +require('clangd_extensions').setup() +require('lspconfig')['pylsp'].setup{ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, +} + +require('lspconfig')['yamlls'].setup{ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, +} +require('lspconfig')['bashls'].setup{ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, +} + +vim.diagnostic.config({ + underline = true, + signs = true, + virtual_text = false, + float = { + show_header = true, + source = 'if_many', + border = 'rounded', + focusable = false, + }, + update_in_insert = true, -- default to false + severity_sort = false, -- default to false +}) + +vim.api.nvim_exec([[ autocmd InsertEnter * :lua vim.diagnostic.config({virtual_text = true}) ]], false) +vim.api.nvim_exec([[ autocmd InsertLeave * :lua vim.diagnostic.config({virtual_text = false}) ]], false) +vim.api.nvim_exec([[ autocmd CursorMoved * :lua vim.diagnostic.open_float({ silent=true }) ]], false) + +vim.api.nvim_set_hl(0, 'FloatBorder', {bg='None', fg='#FFFFFF'}) +vim.api.nvim_set_hl(0, 'NormalFloat', {bg='#3B4252'}) +vim.api.nvim_set_hl(0, 'TelescopeNormal', {bg='#3B4252'}) +vim.api.nvim_set_hl(0, 'TelescopeBorder', {bg='#3B4252'}) + +local luasnip = require 'luasnip' + +local lspkind = require('lspkind') + +-- nvim-cmp setup +local cmp = require 'cmp' +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + ['<C-d>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<CR>'] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + ['<Tab>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + ['<S-Tab>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }), + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, + formatting = { + format = lspkind.cmp_format({ + mode = 'symbol_text', -- show only symbol annotations + maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) + }) + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered() + }, +} + +local api = require('cmp.utils.api') +local types = require('cmp.types') +local highlight = require('cmp.utils.highlight') +local autocmd = require('cmp.utils.autocmd') + +vim.api.nvim_set_hl(0, 'CmpItemAbbr', { link = 'CmpItemAbbrDefault', default = true }) +vim.api.nvim_set_hl(0, 'CmpItemAbbrDeprecated', { link = 'CmpItemAbbrDeprecatedDefault', default = true }) +vim.api.nvim_set_hl(0, 'CmpItemAbbrMatch', { link = 'CmpItemAbbrMatchDefault', default = true }) +vim.api.nvim_set_hl(0, 'CmpItemAbbrMatchFuzzy', { link = 'CmpItemAbbrMatchFuzzyDefault', default = true }) +vim.api.nvim_set_hl(0, 'CmpItemKind', { link = 'CmpItemKindDefault', default = true }) +vim.api.nvim_set_hl(0, 'CmpItemMenu', { link = 'CmpItemMenuDefault', default = true }) +for kind in pairs(types.lsp.CompletionItemKind) do + if type(kind) == 'string' then + local name = ('CmpItemKind%s'):format(kind) + vim.api.nvim_set_hl(0, name, { link = ('%sDefault'):format(name), default = true }) + end +end + +autocmd.subscribe('ColorScheme', function() + highlight.inherit('CmpItemAbbrDefault', 'Pmenu', { bg = 'NONE', default = false }) + highlight.inherit('CmpItemAbbrDeprecatedDefault', 'Comment', { bg = 'NONE', default = false }) + highlight.inherit('CmpItemAbbrMatchDefault', 'Pmenu', { bg = 'NONE', default = false }) + highlight.inherit('CmpItemAbbrMatchFuzzyDefault', 'Pmenu', { bg = 'NONE', default = false }) + highlight.inherit('CmpItemKindDefault', 'Special', { bg = 'NONE', default = false }) + highlight.inherit('CmpItemMenuDefault', 'Pmenu', { bg = 'NONE', default = false }) + for name in pairs(types.lsp.CompletionItemKind) do + if type(name) == 'string' then + vim.api.nvim_set_hl(0, ('CmpItemKind%sDefault'):format(name), { link = 'CmpItemKind', default = false }) + end + end +end) +autocmd.emit('ColorScheme') + + +vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + update_in_insert = true, + } +) + +local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +end diff --git a/vim/nvim/lua/plugins.lua b/vim/nvim/lua/plugins.lua new file mode 100644 index 0000000..a9d98c9 --- /dev/null +++ b/vim/nvim/lua/plugins.lua @@ -0,0 +1,24 @@ +return require('packer').startup(function(use) + use 'wbthomason/packer.nvim' + use 'vim-airline/vim-airline' + use 'vim-airline/vim-airline-themes' + use 'neovim/nvim-lspconfig' + use {'quick-lint/quick-lint-js', rtp = 'plugin/vim/quick-lint-js.vim', tag = '2.10.0', opt = true} + use 'hrsh7th/nvim-cmp' -- Autocompletion plugin + use 'hrsh7th/cmp-nvim-lsp' -- LSP source for nvim-cmp + use 'saadparwaiz1/cmp_luasnip' -- Snippets source for nvim-cmp + use 'onsails/lspkind.nvim' + use 'L3MON4D3/LuaSnip' -- Snippets plugin + use { + "folke/trouble.nvim", + requires = "kyazdani42/nvim-web-devicons", + config = function() + require("trouble").setup { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + end + } + use "p00f/clangd_extensions.nvim" +end) diff --git a/zsh/.zprofile b/zsh/.zprofile deleted file mode 100644 index 95d30b4..0000000 --- a/zsh/.zprofile +++ /dev/null @@ -1,6 +0,0 @@ -eval "$(/opt/homebrew/bin/brew shellenv)" - -# Setting PATH for Python 3.9 -# The original version is saved in .zprofile.pysave -PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}" -export PATH @@ -1,54 +1,30 @@ -export ZSH="/Users/leonardo/.oh-my-zsh" +# Source environment +source $HOME/.config/zsh/environment.zsh -DEFAULT_USER="leonardo" +# Load plugins +plugins=(git zsh-autosuggestions zsh-syntax-highlighting) -autoload -Uz vcs_info - -directory() { - echo "%{$fg_bold[magenta]%}%~%{$reset_color%}" -} - -current_time() { - echo "%{$fg[white]%}[%*]" -} - -return_status() { - local LAST_EXIT_CODE=$? - if [[ $LAST_EXIT_CODE -ne 0 ]]; then - local EXIT_CODE_PROMPT=' ' - EXIT_CODE_PROMPT+="%{$fg_bold[red]%}$LAST_EXIT_CODE%{$reset_color%}" - echo "$EXIT_CODE_PROMPT " - fi -} +source $ZSH/oh-my-zsh.sh -precmd() { - vcs_info - VCS_STATUS="" - if [[ -n ${vcs_info_msg_0_} ]]; then - STATUS=$(command git status --porcelain 2> /dev/null | tail -n1) - if [[ -n $STATUS ]]; then - VCS_STATUS="(%F{yellow}${vcs_info_msg_0_}%f) " - else - VCS_STATUS="(%F{green}${vcs_info_msg_0_}%f) " - fi +# Source configurations +typeset -ga sources +sources+="$ZSH_CONFIG/environment.zsh" +sources+="$ZSH_CONFIG/prompt.zsh" +sources+="$ZSH_CONFIG/aliases.zsh" + +foreach file (`echo $sources`) + if [[ -a $file ]]; then + source $file fi - PROMPT='%B$(directory)%b %# ' - RPROMPT='$(return_status)${VCS_STATUS}$(current_time)' -} +end -zstyle ':vcs_info:*' check-for-changes true -zstyle ':vcs_info:git*' formats "%b%u%c" -zstyle ':vcs_info:git*' actionformats "%b|%a%u%c" -zstyle ':vcs_info:*' unstagedstr ' *' -zstyle ':vcs_info:*' stagedstr ' +' +# =============================== +export NVM_DIR="$HOME/.nvm" +[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" +[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" -setopt prompt_subst - -plugins=(git zsh-autosuggestions) - -source $ZSH/oh-my-zsh.sh +export PYENV_ROOT="$HOME/.pyenv" +command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" +eval "$(pyenv init -)" +eval "$(pyenv virtualenv-init -)" -export PATH="/opt/homebrew/opt/python@3.10/bin:$PATH" -alias vim="nvim" -alias vi="nvim" -alias vimdiff="nvim -d" diff --git a/zsh/config/aliases.zsh b/zsh/config/aliases.zsh new file mode 100644 index 0000000..261161f --- /dev/null +++ b/zsh/config/aliases.zsh @@ -0,0 +1,18 @@ +# Neovim +alias vim="nvim" +alias vi="nvim" +alias vimdiff="nvim -d" + +# Python version +alias python="python3" + +# Ls to exa +alias ls="exa --icons" +alias ll="exa -lbhF --icons --git" +alias llm="exa -lbhd --icons --git --sort=modified" +alias la="exa -lbahF --icons --git" +alias lA="exa -lbhHigUmuSa --icons --time-style=long-iso --git --color-scale" +alias lx="exa -lbhHigUmuSa@ --icons --time-style=long-iso --git --color-scale" +alias lS="exa -1" +alias lt="exa --tree --level=2" + diff --git a/zsh/config/environment.zsh b/zsh/config/environment.zsh new file mode 100644 index 0000000..fdea1da --- /dev/null +++ b/zsh/config/environment.zsh @@ -0,0 +1,12 @@ +DEFAULT_USER="leonardo" + +ZSH_CONFIG=$HOME/.config/zsh + +# Oh-my-zsh +export ZSH="$HOME/.oh-my-zsh" + +# User /bin +export PATH="$HOME/bin:$PATH" + +# Exa colours +export EXA_COLORS="uu=37:un=37:gu=37:gn=37:da=37" diff --git a/zsh/config/prompt.zsh b/zsh/config/prompt.zsh new file mode 100644 index 0000000..1a9776b --- /dev/null +++ b/zsh/config/prompt.zsh @@ -0,0 +1,42 @@ +autoload -Uz vcs_info + +directory() { + echo "%{$fg_bold[magenta]%}%~%{$reset_color%}" +} + +current_time() { + echo "%{$fg[white]%}[%*]" +} + +return_status() { + local LAST_EXIT_CODE=$? + if [[ $LAST_EXIT_CODE -ne 0 ]]; then + local EXIT_CODE_PROMPT=' ' + EXIT_CODE_PROMPT+="%{$fg_bold[red]%}$LAST_EXIT_CODE%{$reset_color%}" + echo "$EXIT_CODE_PROMPT " + fi +} + +precmd() { + vcs_info + VCS_STATUS="" + if [[ -n ${vcs_info_msg_0_} ]]; then + STATUS=$(command git status --porcelain 2> /dev/null | tail -n1) + if [[ -n $STATUS ]]; then + VCS_STATUS="(%F{yellow}${vcs_info_msg_0_}%f) " + else + VCS_STATUS="(%F{green}${vcs_info_msg_0_}%f) " + fi + fi + PROMPT='%B$(directory)%b %# %f' + RPROMPT='$(return_status)${VCS_STATUS}$(current_time)%f' +} + +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:git*' formats "%b%u%c" +zstyle ':vcs_info:git*' actionformats "%b|%a%u%c" +zstyle ':vcs_info:*' unstagedstr ' *' +zstyle ':vcs_info:*' stagedstr ' +' + +setopt prompt_subst + diff --git a/zsh/oh-my-zsh/iTerm2-ssh.zsh b/zsh/oh-my-zsh/iTerm2-ssh.zsh deleted file mode 100644 index 6f19818..0000000 --- a/zsh/oh-my-zsh/iTerm2-ssh.zsh +++ /dev/null @@ -1,28 +0,0 @@ -function tabc() { - NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi - echo -e "\033]50;SetProfile=$NAME\a" -} - -function tab-reset() { - NAME="Default" - echo -e "\033]50;SetProfile=$NAME\a" -} - -function colorssh() { - if [[ -n "$ITERM_SESSION_ID" ]]; then - trap "tab-reset" INT EXIT - if [[ "$*" =~ "ceres" ]]; then - tabc "SSH - Ceres" - elif [[ "$*" =~ "ug04" || "$*" =~ "tw" ]]; then - tabc "SSH - SoCS" - else - tabc "SSH - Unknown" - fi -# tabc SSH - fi - ssh $* -} -compdef _ssh tabc=ssh - -alias ssh="colorssh" - |
