diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1895c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +zsh/zsh_history +zsh/cache +config/nvim/plugin diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..eb2a1aa --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ssh/conf.d"] + path = ssh/conf.d + url = git@git.preisner.eu:preisi/ssh-config.git diff --git a/Xresources b/Xresources index 231b600..116ceb7 100644 --- a/Xresources +++ b/Xresources @@ -1,5 +1,11 @@ -URxvt.font: xft:Monospace:size=9:antialias=true -URxvt.boldFont: xft:Monospace:style=bold:size=9:antialias=true +! beryllium is arch-based with easy access to source code pro, let's use it +#if defined(SRVR_beryllium) || defined(SRVR_oxygen) + URxvt.font: xft:Source Code Pro:size=9:antialias=true + URxvt.boldFont: xft:Source Code Pro:style=bold:size=9:antialias=true +#else + URxvt.font: xft:Monospace:size=9:antialias=true + URxvt.boldFont: xft:Monospace:style=bold:size=9:antialias=true +#endif URxvt.foreground: white URxvt.background: black URxvt.letterSpace: -1 @@ -15,7 +21,7 @@ URxvt.shading: 20 URxvt.iso14755: false URxvt.iso14755_52: false -#if defined(SRVR_falcon) || defined(SRVR_warthog) || defined(SRVR_cipbuero4) +#if defined(SRVR_beryllium) || defined(SRVR_cipbuero4) || defined(SRVR_oxygen) Xft.dpi: 192 #endif @@ -49,7 +55,7 @@ Xft.rgba: rgb *.color11: #fffd00 ! blue -*.color4: #0026ff +*.color4: #0086ff *.color12: #8470ff !*.color12: #0000ff diff --git a/config/barpyrus/config.py b/config/barpyrus/config.py index 24dd93c..c2b6735 100644 --- a/config/barpyrus/config.py +++ b/config/barpyrus/config.py @@ -16,8 +16,7 @@ monitor = sys.argv[1] if len(sys.argv) >= 2 else 0 (x, y, monitor_w, monitor_h) = hc.monitor_rect(monitor) HiDPIHosts = set() -HiDPIHosts.add('falcon') -HiDPIHosts.add('warthog') +HiDPIHosts.add('beryllium') HiDPIHosts.add('cipbuero4') HiDPI = os.uname().nodename in HiDPIHosts diff --git a/config/herbstluftwm/autostart b/config/herbstluftwm/autostart index 73a1aca..50327af 100755 --- a/config/herbstluftwm/autostart +++ b/config/herbstluftwm/autostart @@ -72,7 +72,7 @@ case "$HOSTNAME" in ;; esac -if [ "$HOSTNAME" = warthog ] || [ "$HOSTNAME" = falcon ]; then +if [ "$HOSTNAME" = beryllium ]; then hc keybind $Mod-d spawn /usr/bin/dmenu_run_hlwm -fn "Monospace-9" hc keybind XF86MonBrightnessDown spawn xbacklight -4 hc keybind XF86MonBrightnessUp spawn xbacklight +4 diff --git a/config/herbstluftwm/panel.sh_backup b/config/herbstluftwm/panel.sh_backup index ff9adf5..eadf2d9 100755 --- a/config/herbstluftwm/panel.sh_backup +++ b/config/herbstluftwm/panel.sh_backup @@ -11,7 +11,7 @@ fi x=${geometry[0]} y=${geometry[1]} panel_width=${geometry[2]} -if [ "$HOSTNAME" = warthog ]; then +if [ "$HOSTNAME" = beryllium ]; then panel_height=30 font="-*-fixed-medium-*-*-*-26-*-*-*-*-*-*-*" iconpath=${HOME}/.config/herbstluftwm/icons_large @@ -90,7 +90,7 @@ function cpu() { # BATTERY function battery() { - if [ "$HOSTNAME" != warthog ]; then + if [ "$HOSTNAME" != beryllium ]; then return fi diff --git a/config/i3/config b/config/i3/config index 774056e..8b5ec6a 100644 --- a/config/i3/config +++ b/config/i3/config @@ -6,7 +6,7 @@ set $mod Mod4 # Font for window titles. Will also be used by the bar unless a different font # is used in the bar {} block below. -font pango:monospace 8 +font pango:DejaVu Sans, FontAwesome 7 # This font is widely installed, provides lots of unicode glyphs, right-to-left # text rendering and scalability on retina/hidpi displays (thanks to pango). @@ -24,7 +24,7 @@ floating_modifier $mod # start a terminal #bindsym $mod+Return exec i3-sensible-terminal -bindsym $mod+Return exec urxvt +bindsym $mod+Return exec alacritty bindsym $mod+b exec chromium @@ -89,7 +89,10 @@ bindsym $mod+a focus parent #bindsym $mod+d focus child # custom bind for pass dmenu wrapper -bindsym $mod+p exec ~/bin/passmenu --type +bindsym $mod+p exec passmenu --type + +# custom bind for flameshot screenshot tool +bindsym $mod+Shift+s exec flameshot gui # do not focus container behind mouse focus_follows_mouse no @@ -105,7 +108,7 @@ set $ws6 "6" set $ws7 "7" set $ws8 "8" set $ws9 "9" -set $ws10 "10" +set $ws10 "A" # switch to workspace bindsym $mod+1 [workspace=$ws1] move workspace to output current, workspace $ws1 @@ -136,7 +139,7 @@ bindsym $mod+Alt+c reload # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) bindsym $mod+Shift+r restart # exit i3 (logs you out of your X session) -bindsym $mod+q exec i3lock +bindsym $mod+q exec i3lock --nofork --show-failed-attempts bindsym $mod+Shift+q exit # resize window (you can also use the mouse for that) @@ -170,19 +173,21 @@ bindsym $mod+r mode "resize" bindsym XF86AudioMute exec "pactl set-sink-mute @DEFAULT_SINK@ toggle" bindsym XF86AudioLowerVolume exec "pactl set-sink-mute @DEFAULT_SINK@ false && pactl set-sink-volume @DEFAULT_SINK@ '-5%'" bindsym XF86AudioRaiseVolume exec "pactl set-sink-mute @DEFAULT_SINK@ false && pactl set-sink-volume @DEFAULT_SINK@ '+5%'" -bindsym XF86AudioMicMute exec "pactl set-source-mute 1 toggle" +bindsym XF86AudioMicMute exec "pactl set-source-mute @DEFAULT_SOURCE@ toggle" -bindsym XF86MonBrightnessDown exec "xbacklight -4" -bindsym XF86MonBrightnessUp exec "xbacklight +4" +bindsym XF86MonBrightnessDown exec "brightnessctl set 4%-" +bindsym XF86MonBrightnessUp exec "brightnessctl set 4%+" # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) bar { position top status_command i3status - font pango:DejaVu Sans, FontAwesome 8 + font pango:DejaVu Sans, FontAwesome 7 } exec --no-startup-id redshift exec --no-startup-id nm-applet exec --no-startup-id dunst +exec --no-startup-id blueman-applet +exec --no-startup-id signal-desktop --start-in-tray diff --git a/config/i3status/config b/config/i3status/config index 93c34f4..4498675 100644 --- a/config/i3status/config +++ b/config/i3status/config @@ -11,11 +11,15 @@ general { interval = 5 } +order += "memory" order += "cpu_temperature 0" order += "cpu_usage" order += "battery all" order += "tztime local" +memory { + format = " %percentage_used" +} cpu_temperature 0 { format = " %degrees°C" @@ -33,6 +37,7 @@ battery all { status_unk = " UNK" status_full = " FULL" low_threshold = 10 + last_full_capacity = true } tztime local { diff --git a/config/nvim/init.lua b/config/nvim/init.lua new file mode 100644 index 0000000..dbfc04f --- /dev/null +++ b/config/nvim/init.lua @@ -0,0 +1,3 @@ +require('general') +require('keybindings') +require('plugins') diff --git a/config/nvim/lua/general.lua b/config/nvim/lua/general.lua new file mode 100644 index 0000000..162e26f --- /dev/null +++ b/config/nvim/lua/general.lua @@ -0,0 +1,81 @@ +-- reduce boilerplate by defining some shortcuts +local opt = vim.opt +local cmd = vim.cmd +local autocmd = vim.api.nvim_create_autocmd + +-------------------- +-- General +-------------------- +opt.mouse = 'n' -- enable mouse support in normal mode +opt.clipboard = 'unnamedplus' -- copy/paste to and from system clipboard + +opt.wildmode = 'list:longest,full' +opt.wildignorecase = true +-- ignore C/C++ objects and other build files +opt.wildignore = '*.o,*.so,*.out' +-- ignore java classes +opt.wildignore:append '*.class' +-- ignore python cache files +opt.wildignore:append '*.pyc' +-- ignore tex-related build files +opt.wildignore:append '*.aux,*.bcf,*.lof,*.lol,*.lot,*.rubbercache,*.toc,*.pdf' + +opt.fileformats = 'unix,dos' -- use identical lineendings for all platforms +opt.secure = true -- disable autocmd for security reasons + +-------------------- +-- Tabs +-------------------- +opt.tabstop = 4 -- 1 tab == N spaces +opt.shiftwidth = 4 -- shift N spaces when pressing tab +opt.smartindent = true -- take syntax into account for applying indentation + +-------------------- +-- Search +-------------------- +opt.ignorecase = true -- ignore capitalization on search +opt.smartcase = true -- ignore capitalication unless word contains a capital + +opt.iskeyword:append '-' -- treat hyphenated words as a single word + +-------------------- +-- Neovim UI +-------------------- +opt.number = true -- line numbers +opt.ruler = true -- cursor position in statusbar +opt.showtabline = 2 -- always show vim tabs +opt.showcmd = true -- display currently typed command +opt.termguicolors = true -- enable 24-bit RGB color + +-- highlight line at which the cursor is positioned +opt.cursorline = true +cmd 'highlight CursorLine term=bold cterm=bold' +cmd 'highlight CursorLineNR term=bold cterm=bold ctermbg=darkgrey' + +-- display warning column at 81 and 121 +opt.colorcolumn = '81,121' +cmd 'highlight ColorColumn ctermbg=235 guibg=#2d2d2d' + +opt.splitright = true -- horizontal split to the right +opt.splitbelow = true -- vertical split to the bottom + +-- define characters to display when using 'set list' +opt.listchars = 'tab:→ ,trail:∙,eol:¬,extends:❯,precedes:❮,nbsp:␣' + +-------------------- +-- Performance +-------------------- +opt.hidden = true -- allow buffers with changes to be hidden +opt.updatetime = 300 -- delay (in ms) to wait before triggering event +opt.timeoutlen = 500 -- time (in ms) to wait for event to complete +opt.history = 10000 -- remember N lines of history + +-------------------- +-- Misc +-------------------- + +-- remove redundant whitespaces on save +autocmd('BufWritePre', { + pattern = '*', + command = ':%s/\\s\\+$//e' +}) diff --git a/config/nvim/lua/keybindings.lua b/config/nvim/lua/keybindings.lua new file mode 100644 index 0000000..0b0dc5a --- /dev/null +++ b/config/nvim/lua/keybindings.lua @@ -0,0 +1,8 @@ +local map = require('utils').map -- import map + +-- redefine leader key +vim.g.mapleader = ' ' + +-- allow switching between buffers using tab and Shift-tab +map('n', '', ':bnext') +map('n', '', ':bprevious') diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua new file mode 100644 index 0000000..29cdd27 --- /dev/null +++ b/config/nvim/lua/plugins.lua @@ -0,0 +1,173 @@ +-------------------- +-- Packer Bootstrap +-------------------- +local packer_installed, _ = pcall(require, 'packer') +local packer_bootstrap = false +if (not packer_installed) then + -- ask user whether packer should be bootstrapped + packer_bootstrap = require('utils').prompt( + 'Plugin manager packer not found. Install it now?', + 'Bootstrapping packer now...', + 'Skipping setup of packer and plugins.') + + if (not packer_bootstrap) then + return + end + + -- perform actual bootstrap + local fn = vim.fn + local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' + fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) + vim.cmd('packadd packer.nvim') +end + +-- helper function to be used `config` parameter of packer's use to externalize +-- plugin configuration, expects the name of the config file +function load_config(name) + return string.format('require("plugins/%s")', name) +end + +return require('packer').startup({ + function(use) + use 'wbthomason/packer.nvim' + + -------------------- + -- Visuals + -------------------- + use { -- colorblind-friendly colorscheme + 'projekt0n/github-nvim-theme', + config = load_config('github-nvim-theme'), + } + use { -- color highlighter + 'norcalli/nvim-colorizer.lua', + config = function() require('colorizer').setup() end, + } + + -------------------- + -- Package Manager + -------------------- + use { -- portable package manager + 'williamboman/mason.nvim', + config = load_config('mason'), + } + use { -- update helper for mason + 'WhoIsSethDaniel/mason-tool-installer.nvim', + after = { 'mason.nvim' }, + config = function() require('mason-tool-installer').setup({}) end, + } + + -------------------- + -- LSP Setup + -------------------- + use { -- compatibility layer between mason and lspconfig + autoinstaller + 'williamboman/mason-lspconfig.nvim', + after = { 'mason.nvim' }, + requires = { + 'neovim/nvim-lspconfig', + }, + } + use { -- configuration layer for neovim LSP client + 'neovim/nvim-lspconfig', + after = { + 'mason-lspconfig.nvim', + 'cmp-nvim-lsp', + }, + config = load_config('lspconfig'), + } + + -------------------- + -- Linter/Formatter + -------------------- + use { -- linter and formatter manager + 'jose-elias-alvarez/null-ls.nvim', + after = { + 'mason.nvim', + 'plenary.nvim', + }, + requires = { 'nvim-lua/plenary.nvim' }, + } + use { -- compatibility layer between mason and null-ls + 'jayp0521/mason-null-ls.nvim', + after = { 'null-ls.nvim' }, + config = load_config('null-ls') + } + + -------------------- + -- Snippets + -------------------- + use { -- snippet engine + 'L3MON4D3/LuaSnip', + requires = { + 'saadparwaiz1/cmp_luasnip', + 'rafamadriz/friendly-snippets', + }, + } + use { -- various snippets + 'rafamadriz/friendly-snippets', + after = { 'LuaSnip' }, + config = load_config('friendly-snippets'), + } + + -------------------- + -- Completion + -------------------- + use { -- nvim-cmp source for nvim-lsp + 'hrsh7th/cmp-nvim-lsp', + requires = { 'hrsh7th/nvim-cmp' }, + } + use { -- nvim-cmp source for LuaSnip + 'saadparwaiz1/cmp_luasnip', + requires = { 'hrsh7th/nvim-cmp' }, + after = { 'LuaSnip' }, + } + use { -- nvim-cmp source for buffer words + 'hrsh7th/cmp-buffer', + requires = { 'hrsh7th/nvim-cmp' }, + } + use { -- nvim-cmp source for filesystem paths + 'hrsh7th/cmp-path', + requires = { 'hrsh7th/nvim-cmp' }, + } + use { -- nvim-cmp source for vim's cmdline + 'hrsh7th/cmp-cmdline', + requires = { 'hrsh7th/nvim-cmp' }, + } + use { -- completion engine + 'hrsh7th/nvim-cmp', + after = { + 'cmp-nvim-lsp', + 'cmp-buffer', + 'cmp-path', + 'cmp-cmdline', + 'cmp_luasnip' + }, + config = load_config('nvim-cmp'), + } + + -------------------- + -- Misc Utilities + -------------------- + use { -- fuzzy finder + 'nvim-telescope/telescope.nvim', + config = load_config('telescope'), + requires = {'nvim-lua/plenary.nvim'}, + } + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if packer_bootstrap then + require('packer').sync() + end + end, + config = { + display = { + open_fn = function() + return require('packer.util').float({ border = 'rounded' }) + end, + }, + profile = { + enable = true, + threshold = 1, -- the amount in ms that a plugins load time must be over for it to be included in the profile + }, + }, +}) diff --git a/config/nvim/lua/plugins/friendly-snippets.lua b/config/nvim/lua/plugins/friendly-snippets.lua new file mode 100644 index 0000000..e62dc5a --- /dev/null +++ b/config/nvim/lua/plugins/friendly-snippets.lua @@ -0,0 +1 @@ +require('luasnip.loaders.from_vscode').lazy_load() diff --git a/config/nvim/lua/plugins/github-nvim-theme.lua b/config/nvim/lua/plugins/github-nvim-theme.lua new file mode 100644 index 0000000..653c7da --- /dev/null +++ b/config/nvim/lua/plugins/github-nvim-theme.lua @@ -0,0 +1,7 @@ +require('github-theme').setup({ + options = { + transparent = true, + }, +}) + +vim.cmd.colorscheme('github_dark_colorblind') diff --git a/config/nvim/lua/plugins/lspconfig.lua b/config/nvim/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..e2418e1 --- /dev/null +++ b/config/nvim/lua/plugins/lspconfig.lua @@ -0,0 +1,24 @@ +local map = require('utils').map -- import map + +require('mason-lspconfig').setup() +require('mason-lspconfig').setup_handlers({ + function(server_name) -- default handler + -- prepare nvim-cmp source + local capabilities = require('cmp_nvim_lsp').default_capabilities() + require('lspconfig')[server_name].setup({ + -- announce nvim-cmp-lsp capabilities to each lsp server + capabilities = capabilities + }) + end +}) + +-- lsp keybindings +map('n', 'gd', 'lua vim.lsp.buf.definition()') +map('n', 'gD', 'lua vim.lsp.buf.declaration()') +map('n', 'K', 'lua vim.lsp.buf.hover()') +map('n', 'gi', 'lua vim.lsp.buf.implementation()') +map('n', 'gr', 'lua vim.lsp.buf.references()') +map('n', '', 'lua vim.lsp.buf.signature_help()') +map('n', 'rn', 'lua vim.lsp.buf.rename()') +map('n', 'ca', 'lua vim.lsp.buf.code_action()') +map('n', 'f', 'lua vim.lsp.buf.type_definition({ async = true })') diff --git a/config/nvim/lua/plugins/mason.lua b/config/nvim/lua/plugins/mason.lua new file mode 100644 index 0000000..eba961c --- /dev/null +++ b/config/nvim/lua/plugins/mason.lua @@ -0,0 +1,9 @@ +require('mason').setup({ + ui = { + icons = { + package_installed = '✓', + package_pending = '➜', + package_uninstalled = '✗', + }, + }, +}) diff --git a/config/nvim/lua/plugins/null-ls.lua b/config/nvim/lua/plugins/null-ls.lua new file mode 100644 index 0000000..7d41884 --- /dev/null +++ b/config/nvim/lua/plugins/null-ls.lua @@ -0,0 +1,2 @@ +require('null-ls').setup() +require('mason-null-ls').setup() diff --git a/config/nvim/lua/plugins/nvim-cmp.lua b/config/nvim/lua/plugins/nvim-cmp.lua new file mode 100644 index 0000000..a8adbf8 --- /dev/null +++ b/config/nvim/lua/plugins/nvim-cmp.lua @@ -0,0 +1,78 @@ +vim.opt.completeopt = 'menu,menuone,noselect' + +local cmp = require('cmp') +cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + formatting = { + format = function(entry, vim_item) + vim_item.menu = ({ + nvim_lsp = '[LSP]', + buffer = '[Buffer]', + luasnip = '[Snippet]', + })[entry.source.name] + return vim_item + end, + }, + window = { + completion = cmp.config.window.bordered({ border = 'rounded' }), + documentation = cmp.config.window.bordered({ border = 'rounded' }), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp', keyword_length = 3 }, + { name = 'luasnip', keyword_length = 2 }, + }, { + { + name = 'buffer', + keyword_length = 3, + option = { + get_bufnrs = function() + return vim.api.nvim_list_bufs() + end, + }, + }, + }) +}) + +-- configure completion for specific filetype +cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'buffer' }, + }), +}) + +-- use buffer source for `/` and `?` (if you enabled `native_menu`, this won't +-- work anymore) +cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + }, +}) + +-- use cmdline & path source for ':' (if you enabled `native_menu`, this won't +-- work anymore). +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { + name = 'path', + option = { + trailing_slash = false, + label_trailing_slash = false, + } + } + }, { + { name = 'cmdline' } + }), +}) diff --git a/config/nvim/lua/plugins/telescope.lua b/config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..b549b98 --- /dev/null +++ b/config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,7 @@ +local map = require('utils').map -- import map + +-- telescope keybindings +map('n', 'ff', 'Telescope find_files') +map('n', 'fg', 'Telescope live_grep') +map('n', 'fb', 'Telescope buffers') +map('n', 'fh', 'Telescope help_tags') diff --git a/config/nvim/lua/utils.lua b/config/nvim/lua/utils.lua new file mode 100644 index 0000000..292c148 --- /dev/null +++ b/config/nvim/lua/utils.lua @@ -0,0 +1,30 @@ +local M = {} + +-- keybinding mapper +function M.map(mode, lhs, rhs, opts) + local options = { noremap = true, silent = true } + if opts then + options = vim.tbl_extend('force', options, opts) + end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +-- simple prompt +function M.prompt(msg, accept_msg, deny_msg) + local answer = vim.fn.input(msg .. ' (YES/no) ') + while(true) do + -- clear vim cmdline before printing anything + vim.cmd('mode') + if answer == 'YES' then + print(accept_msg) + return true + elseif string.lower(answer) == 'no' then + print(deny_msg) + return false + end + -- re-request user input + answer = vim.fn.input('Please retry: ' .. msg .. ' (YES/no) ') + end +end + +return M diff --git a/gitconfig b/gitconfig index 7b65888..883d149 100644 --- a/gitconfig +++ b/gitconfig @@ -2,7 +2,7 @@ email = mail@tpreisner.de name = Thomas Preisner [core] - editor = vim + editor = nvim [commit] verbose = true [alias] @@ -20,3 +20,9 @@ s = status st = status t = tag +[init] + defaultBranch = main +[diff "ansible-vault"] + textconv = "ansible-vault view" +[diff "sopsdiffer"] + textconv = "sops --config /dev/null --decrypt" diff --git a/gnupg/gpg-agent.conf b/gnupg/gpg-agent.conf index 0bd0209..c26143c 100644 --- a/gnupg/gpg-agent.conf +++ b/gnupg/gpg-agent.conf @@ -4,3 +4,5 @@ default-cache-ttl 600 max-cache-ttl 3600 grab + +pinentry-program /usr/bin/pinentry-gnome3 diff --git a/setup.sh b/setup.sh index 20b8438..4937942 100755 --- a/setup.sh +++ b/setup.sh @@ -48,7 +48,15 @@ if installed vim; then echo "Setting up vim:" link vimrc ~/.vimrc - #link vim ~/.vim + link vim ~/.vim + + echo +fi +if installed nvim; then + echo "Setting up nvim:" + + mkdir -p ~/.config + link config/nvim ~/.config/nvim echo fi @@ -83,6 +91,7 @@ if installed ssh; then mkdir -p ~/.ssh link ssh/config ~/.ssh/config + link ssh/conf.d ~/.ssh/conf.d echo fi diff --git a/ssh/conf.d b/ssh/conf.d new file mode 160000 index 0000000..e322403 --- /dev/null +++ b/ssh/conf.d @@ -0,0 +1 @@ +Subproject commit e322403a55ca26a907da9e92a50316a14cf87898 diff --git a/ssh/config b/ssh/config index 5593fa6..95548e1 100644 --- a/ssh/config +++ b/ssh/config @@ -3,44 +3,10 @@ Host * AddKeysToAgent confirm -Host 0?? 0??? - HostName faui%h.informatik.uni-erlangen.de - ForwardAgent yes +# Include external config if available +Include conf.d/* -Host faui0? faui0?? faui0??? - HostName %h.informatik.uni-erlangen.de - ForwardAgent yes - -Host man? man?? big? - HostName faui49%h.informatik.uni-erlangen.de - ProxyJump ty28wuqu@i4lab1.informatik.uni-erlangen.de - -Match Host faui* - User ty28wuqu - -Host ircbox - HostName ircbox.informatik.uni-erlangen.de - User ty28wuqu - -Host irc - HostName tpreisner.de - User weechat - -Host server - HostName tpreisner.de - User root - -Host steep - Hostname steep.cs.fau.de - User preisi - Port 17 - -Host pi - HostName wg.tpreisner.de - # dynamic ip behind hostname would cause warnings - CheckHostIP no - -# use if they havent been defined yet: +# Use if they havent been defined yet: Host * Compression yes ForwardAgent no diff --git a/vim/colors/dichromatic.vim b/vim/colors/dichromatic.vim new file mode 100644 index 0000000..5011d6e --- /dev/null +++ b/vim/colors/dichromatic.vim @@ -0,0 +1,161 @@ +" dichromatic.vim -- Vim color scheme. +" Author: Romain Lafourcade (romainlafourcade@gmail.com) +" Webpage: https://raw.githubusercontent.com/romainl/vim-dichromatic/master/colors/dichromatic.vim +" Description: A 'dark' colorscheme for color blind vimmers. But not only. + +hi clear + +if exists("syntax_on") + syntax reset +endif + +let colors_name = "dichromatic" + +if ($TERM =~ '256' || &t_Co >= 256) || has("gui_running") + hi Normal ctermbg=232 ctermfg=252 cterm=NONE guibg=#080808 guifg=#D0D0D0 gui=NONE + hi NonText ctermbg=NONE ctermfg=240 cterm=NONE guibg=NONE guifg=#585858 gui=NONE + hi Comment ctermbg=NONE ctermfg=244 cterm=NONE guibg=NONE guifg=#808080 gui=NONE + hi Constant ctermbg=NONE ctermfg=168 cterm=NONE guibg=NONE guifg=#D75F87 gui=NONE + hi Error ctermbg=15 ctermfg=89 cterm=reverse guibg=#FFFFFF guifg=#87005F gui=reverse + hi Identifier ctermbg=NONE ctermfg=133 cterm=NONE guibg=NONE guifg=#AF5FAF gui=NONE + hi Ignore ctermbg=NONE ctermfg=NONE cterm=NONE guibg=NONE guifg=NONE gui=NONE + hi PreProc ctermbg=NONE ctermfg=186 cterm=NONE guibg=NONE guifg=#DFDF87 gui=NONE + hi Special ctermbg=NONE ctermfg=15 cterm=NONE guibg=NONE guifg=#FFFFFF gui=NONE + hi Statement ctermbg=NONE ctermfg=133 cterm=NONE guibg=NONE guifg=#AF5FAF gui=NONE + hi String ctermbg=NONE ctermfg=142 cterm=NONE guibg=NONE guifg=#AFAF00 gui=NONE + hi Todo ctermbg=NONE ctermfg=NONE cterm=reverse guibg=NONE guifg=NONE gui=reverse + hi Type ctermbg=NONE ctermfg=116 cterm=NONE guibg=NONE guifg=#87D7D7 gui=NONE + hi Underlined ctermbg=NONE ctermfg=NONE cterm=underline guibg=NONE guifg=NONE gui=underline + hi Number ctermbg=NONE ctermfg=168 cterm=NONE guibg=NONE guifg=#D75F87 gui=NONE + hi StatusLine ctermbg=15 ctermfg=240 cterm=NONE guibg=#FFFFFF guifg=#585858 gui=NONE + hi StatusLineNC ctermbg=240 ctermfg=15 cterm=NONE guibg=#585858 guifg=#FFFFFF gui=NONE + hi VertSplit ctermbg=240 ctermfg=240 cterm=NONE guibg=#585858 guifg=#585858 gui=NONE + hi TabLine ctermbg=240 ctermfg=15 cterm=NONE guibg=#585858 guifg=#FFFFFF gui=NONE + hi TabLineFill ctermbg=240 ctermfg=240 cterm=NONE guibg=#585858 guifg=#585858 gui=NONE + hi TabLineSel ctermbg=15 ctermfg=240 cterm=NONE guibg=#FFFFFF guifg=#585858 gui=NONE + hi Title ctermbg=NONE ctermfg=72 cterm=NONE guibg=NONE guifg=#5FAF87 gui=NONE + hi LineNr ctermbg=NONE ctermfg=116 cterm=NONE guibg=NONE guifg=#87D7D7 gui=NONE + hi Cursor ctermbg=15 ctermfg=232 cterm=NONE guibg=#FFFFFF guifg=#080808 gui=NONE + hi CursorColumn ctermbg=89 ctermfg=NONE cterm=NONE guibg=#87005F guifg=NONE gui=NONE + hi CursorLine ctermbg=236 ctermfg=NONE cterm=NONE guibg=#303030 guifg=NONE gui=NONE + hi CursorLineNr ctermbg=236 ctermfg=NONE cterm=NONE guibg=#303030 guifg=NONE gui=NONE + hi helpLeadBlank ctermbg=NONE ctermfg=NONE cterm=NONE guibg=NONE guifg=NONE gui=NONE + hi helpNormal ctermbg=NONE ctermfg=NONE cterm=NONE guibg=NONE guifg=NONE gui=NONE + hi Visual ctermbg=116 ctermfg=232 cterm=NONE guibg=#87D7D7 guifg=#080808 gui=NONE + hi VisualNOS ctermbg=133 ctermfg=232 cterm=NONE guibg=#AF5FAF guifg=#080808 gui=NONE + hi Pmenu ctermbg=186 ctermfg=232 cterm=NONE guibg=#DFDF87 guifg=#080808 gui=NONE + hi PmenuSbar ctermbg=142 ctermfg=186 cterm=NONE guibg=#AFAF00 guifg=#DFDF87 gui=NONE + hi PmenuSel ctermbg=133 ctermfg=232 cterm=NONE guibg=#AF5FAF guifg=#080808 gui=NONE + hi PmenuThumb ctermbg=133 ctermfg=133 cterm=NONE guibg=#AF5FAF guifg=#AF5FAF gui=NONE + hi FoldColumn ctermbg=NONE ctermfg=72 cterm=NONE guibg=NONE guifg=#5FAF87 gui=NONE + hi Folded ctermbg=NONE ctermfg=248 cterm=NONE guibg=NONE guifg=#A8A8A8 gui=NONE + hi WildMenu ctermbg=53 ctermfg=15 cterm=NONE guibg=#00005F guifg=#FFFFFF gui=NONE + hi SpecialKey ctermbg=NONE ctermfg=186 cterm=NONE guibg=NONE guifg=#DFDF87 gui=NONE + hi DiffAdd ctermbg=232 ctermfg=111 cterm=reverse guibg=#080808 guifg=#87afff gui=reverse + hi DiffChange ctermbg=232 ctermfg=188 cterm=reverse guibg=#080808 guifg=#dfdfdf gui=reverse + hi DiffDelete ctermbg=232 ctermfg=222 cterm=reverse guibg=#080808 guifg=#ffdf87 gui=reverse + hi DiffText ctermbg=232 ctermfg=145 cterm=reverse guibg=#080808 guifg=#afafaf gui=reverse + hi IncSearch ctermbg=232 ctermfg=133 cterm=reverse guibg=#080808 guifg=#AF5FAF gui=reverse + hi Search ctermbg=186 ctermfg=232 cterm=NONE guibg=#DFDF87 guifg=#080808 gui=NONE + hi Directory ctermbg=NONE ctermfg=72 cterm=NONE guibg=NONE guifg=#5FAF87 gui=NONE + hi MatchParen ctermbg=240 ctermfg=186 cterm=NONE guibg=#585858 guifg=#DFDF87 gui=NONE + hi SpellBad ctermbg=89 ctermfg=232 cterm=NONE guibg=#87005F guifg=#080808 gui=NONE guisp=#87005F + hi SpellCap ctermbg=72 ctermfg=232 cterm=NONE guibg=#5FAF87 guifg=#080808 gui=NONE guisp=#5FAF87 + hi SpellLocal ctermbg=142 ctermfg=232 cterm=NONE guibg=#AFAF00 guifg=#080808 gui=NONE guisp=#AFAF00 + hi SpellRare ctermbg=133 ctermfg=232 cterm=NONE guibg=#AF5FAF guifg=#080808 gui=NONE guisp=#AF5FAF + hi ColorColumn ctermbg=133 ctermfg=NONE cterm=NONE guibg=#AF5FAF guifg=NONE gui=NONE + hi signColumn ctermbg=NONE ctermfg=186 cterm=NONE guibg=NONE guifg=#DFDF87 gui=NONE + hi ErrorMsg ctermbg=89 ctermfg=15 cterm=NONE guibg=#87005F guifg=#FFFFFF gui=NONE + hi ModeMsg ctermbg=142 ctermfg=232 cterm=NONE guibg=#AFAF00 guifg=#080808 gui=NONE + hi MoreMsg ctermbg=NONE ctermfg=142 cterm=NONE guibg=NONE guifg=#AFAF00 gui=NONE + hi Question ctermbg=NONE ctermfg=72 cterm=NONE guibg=NONE guifg=#5FAF87 gui=NONE + hi WarningMsg ctermbg=168 ctermfg=232 cterm=NONE guibg=#D75F87 guifg=#080808 gui=NONE + hi QuickFixLine ctermbg=15 ctermfg=240 cterm=NONE guibg=#FFFFFF guifg=#585858 gui=NONE + +elseif &t_Co == 8 || $TERM !~# '^linux' || &t_Co == 16 + set t_Co=16 + + hi Normal ctermbg=black ctermfg=grey cterm=NONE + hi NonText ctermbg=NONE ctermfg=darkgrey cterm=NONE + hi Comment ctermbg=NONE ctermfg=darkgrey cterm=NONE + hi Constant ctermbg=NONE ctermfg=red cterm=NONE + hi Error ctermbg=white ctermfg=darkmagenta cterm=reverse + hi Identifier ctermbg=NONE ctermfg=darkred cterm=NONE + hi Ignore ctermbg=NONE ctermfg=NONE cterm=NONE + hi PreProc ctermbg=NONE ctermfg=yellow cterm=NONE + hi Special ctermbg=NONE ctermfg=white cterm=NONE + hi Statement ctermbg=NONE ctermfg=darkred cterm=NONE + hi String ctermbg=NONE ctermfg=darkyellow cterm=NONE + hi Todo ctermbg=NONE ctermfg=NONE cterm=reverse + hi Type ctermbg=NONE ctermfg=cyan cterm=NONE + hi Underlined ctermbg=NONE ctermfg=NONE cterm=underline + hi Number ctermbg=NONE ctermfg=red cterm=NONE + hi StatusLine ctermbg=white ctermfg=darkgrey cterm=NONE + hi StatusLineNC ctermbg=darkgrey ctermfg=white cterm=NONE + hi VertSplit ctermbg=darkgrey ctermfg=darkgrey cterm=NONE + hi TabLine ctermbg=darkgrey ctermfg=white cterm=NONE + hi TabLineFill ctermbg=darkgrey ctermfg=darkgrey cterm=NONE + hi TabLineSel ctermbg=white ctermfg=darkgrey cterm=NONE + hi Title ctermbg=NONE ctermfg=green cterm=NONE + hi LineNr ctermbg=NONE ctermfg=cyan cterm=NONE + hi Cursor ctermbg=white ctermfg=black cterm=NONE + hi CursorColumn ctermbg=darkmagenta ctermfg=NONE cterm=NONE + hi CursorLine ctermbg=black ctermfg=NONE cterm=NONE + hi CursorLineNr ctermbg=black ctermfg=NONE cterm=NONE + hi helpLeadBlank ctermbg=NONE ctermfg=NONE cterm=NONE + hi helpNormal ctermbg=NONE ctermfg=NONE cterm=NONE + hi Visual ctermbg=cyan ctermfg=black cterm=NONE + hi VisualNOS ctermbg=darkred ctermfg=black cterm=NONE + hi Pmenu ctermbg=yellow ctermfg=black cterm=NONE + hi PmenuSbar ctermbg=darkyellow ctermfg=yellow cterm=NONE + hi PmenuSel ctermbg=darkred ctermfg=black cterm=NONE + hi PmenuThumb ctermbg=darkred ctermfg=darkred cterm=NONE + hi FoldColumn ctermbg=NONE ctermfg=green cterm=NONE + hi Folded ctermbg=NONE ctermfg=grey cterm=NONE + hi WildMenu ctermbg=darkblue ctermfg=white cterm=NONE + hi SpecialKey ctermbg=NONE ctermfg=yellow cterm=NONE + hi DiffAdd ctermbg=black ctermfg=blue cterm=reverse + hi DiffChange ctermbg=black ctermfg=grey cterm=reverse + hi DiffDelete ctermbg=black ctermfg=yellow cterm=reverse + hi DiffText ctermbg=black ctermfg=darkgray cterm=reverse + hi IncSearch ctermbg=black ctermfg=darkred cterm=reverse + hi Search ctermbg=yellow ctermfg=black cterm=NONE + hi Directory ctermbg=NONE ctermfg=green cterm=NONE + hi MatchParen ctermbg=darkgrey ctermfg=yellow cterm=NONE + hi SpellBad ctermbg=darkmagenta ctermfg=black cterm=NONE + hi SpellCap ctermbg=green ctermfg=black cterm=NONE + hi SpellLocal ctermbg=darkyellow ctermfg=black cterm=NONE + hi SpellRare ctermbg=darkred ctermfg=black cterm=NONE + hi ColorColumn ctermbg=darkred ctermfg=NONE cterm=NONE + hi signColumn ctermbg=NONE ctermfg=yellow cterm=NONE + hi ErrorMsg ctermbg=darkmagenta ctermfg=white cterm=NONE + hi ModeMsg ctermbg=darkyellow ctermfg=black cterm=NONE + hi MoreMsg ctermbg=NONE ctermfg=darkyellow cterm=NONE + hi Question ctermbg=NONE ctermfg=green cterm=NONE + hi WarningMsg ctermbg=red ctermfg=black cterm=NONE + hi QuickFixLine ctermbg=white ctermfg=darkgrey cterm=NONE +endif + +hi link StatusLineTerm StatusLine +hi link StatusLineTermNC StatusLineNC + +let g:terminal_ansi_colors = [ + \ '#080808', + \ '#AF5FAF', + \ '#008700', + \ '#AFAF00', + \ '#00005F', + \ '#87005F', + \ '#87D7D7', + \ '#D0D0D0', + \ '#808080', + \ '#D75F87', + \ '#5FAF87', + \ '#DFDF87', + \ '#87D7D7', + \ '#D75F87', + \ '#87D7D7', + \ '#FFFFFF', + \ ] + +" Generated with RNB (https://gist.github.com/romainl/5cd2f4ec222805f49eca) diff --git a/vim/general.vim b/vim/general.vim new file mode 100644 index 0000000..d0ff70b --- /dev/null +++ b/vim/general.vim @@ -0,0 +1,139 @@ +" drop vi-compatibility +set nocompatible +" disable autocmd +set secure +" use utf8 only +set encoding=utf8 + +" file/directory matching +set wildmode=list:longest,full +" ignore case when completing +if exists('+wildignorecase') + set wildignorecase +endif +" ignorelist +set wildignore=*.o,*.d,*.so,*.class,*.aux,*.log,*.out,*.toc,*.pdf,*.pyc + +" increase command history +set history=1000 +" increase count of possible undos +set undolevels=1000 + +" encrypt buffers when saved to files +if exists('+cryptmethod') + set cryptmethod=blowfish +endif + +" enable fast terminal for tmux but not for ssh connection +if &term =~# '^screen' && !exists('SSH_CONNECTION') + set ttyfast +endif + +" enable automatic file detection, plugin and indention support +if has('autocmd') + filetype plugin indent on +endif + +" use utf8 encoding for all files and recognize latin1 +set fileencodings=utf-8,latin1 + +" use unix line-endings and recognize dos endings +set fileformats=unix,dos + +" tabs +set tabstop=4 +set shiftwidth=4 +set autoindent +set smartindent +set smarttab + +" allow backspacing over autoindent and line breaks +set backspace=indent,eol,start + +" already display matches while searching +set incsearch +" only check for case if the searched word contains a capital +set ignorecase +set smartcase +" highlight all matches. use to remove the highlights +set hlsearch + +" treat hyphenated words as a single word +set iskeyword+=- + +" syntax folding +if has('folding') + set foldmethod=syntax + " only use folding when there is enough space +" if &columns > 80 +" set foldcolumn=2 +" endif + set foldlevel=99 + + " dont open fold for block movements + set foldopen-=block +endif + +" allow buffers with changes to be hidden +set hidden + +" correct splitting +if has('vertsplit') + set splitright + set splitbelow +endif + +" Visual +" set text color for dark terminal background +set background=dark + +" activate syntax highlighting +if has('syntax') + syntax enable +endif + +" set colorscheme +colorscheme dichromatic + +" display line at which the current is positioned +if exists('+cursorline') + set cursorline + " remove line and make the line bold instead + highlight CursorLine term=bold cterm=bold + highlight CursorLineNR term=bold cterm=bold ctermbg=darkgrey +endif + +" display warning column at 81 and 121 +let &colorcolumn="81,121" +highlight ColorColumn ctermbg=235 guibg=#2d2d2d + +" display line numbers +set number + +" show cursor position all the time +set ruler + +" show vim tabs all the time +set showtabline=2 + +" show currently typed command +set showcmd + +" define characters to display when using 'set list' +set listchars=tab:→\ ,trail:∙,eol:¬,extends:❯,precedes:❮,nbsp:␣ + +" increase completion performance and reduce time until timeout +set updatetime=300 +set timeoutlen=500 + +" copy paste between vim and everything else +set clipboard=unnamedplus + +" Misc +set mouse=n + +" remove windows ^M when the encoding gets messed up +noremap m mmHmt:%s///ge'tzt'm + +" add convenience command for force-saving read-only files +cmap w!! w !sudo tee % diff --git a/vim/keybindings.vim b/vim/keybindings.vim new file mode 100644 index 0000000..b2ba8bc --- /dev/null +++ b/vim/keybindings.vim @@ -0,0 +1,16 @@ +" allow easier pane switching +nnoremap +nnoremap +nnoremap +nnoremap + +" allow easier pane resizing +nnoremap :resize -2 +nnoremap :resize +2 +nnoremap :vertical resize -2 +nnoremap :vertical resize +2 + +" use TAB to switch to next buffers +nnoremap :bnext +" use Shift-TAB to switch to previous buffers +nnoremap :bprevious diff --git a/vimrc b/vimrc index a03ec52..ce6afd3 100644 --- a/vimrc +++ b/vimrc @@ -1,143 +1,2 @@ -" .vimrc - -" only vim and not vi -set nocompatible -" disable autocmd -set secure -" use utf8 only -set encoding=utf8 - -" file/directory matching -set wildmode=list:longest,full -" ignore case when completing -if exists('+wildignorecase') - set wildignorecase -endif -" ignorelist -set wildignore=*.o,*.d,*.so,*.class,*.aux,*.log,*.out,*.toc,*.pdf,*.pyc - -" show completion menu even with only one match -if exists('+completeopt') - set completeopt+=menuone -endif - -" increase command history -set history=1000 -" increase count of possible undos -set undolevels=1000 - -" encrypt buffers when saved to files -if exists('+cryptmethod') - set cryptmethod=blowfish -endif - -" enable fast terminal for tmux but not for ssh connection -if &term =~# '^screen' && !exists('SSH_CONNECTION') - set ttyfast -endif - -" enable automatic file detection, plugin and indention support -if has('autocmd') - filetype off "for pathogen - filetype plugin indent on -endif - -" use utf8 encoding for all files and recognize latin1 -set fileencodings=utf-8,latin1 - -" use unix line-endings and recognize dos endings -set fileformats=unix,dos - -" tabs -set tabstop=4 -set shiftwidth=4 -set autoindent -set smartindent -set smarttab - -" allow backspacing over autoindent and line breaks -set backspace=indent,eol,start - -" already display matches while searching -set incsearch -" only check for case if the searched word contains a capital -set ignorecase -set smartcase -" highlight all matches. use to remove the highlights -set hlsearch - -" syntax folding -if has('folding') - set foldmethod=syntax - " only use folding when there is enough space -" if &columns > 80 -" set foldcolumn=2 -" endif - set foldlevel=99 - - " dont open fold for block movements - set foldopen-=block -endif - -" allow buffers with changes to be hidden -set hidden - -" correct splitting -if has('vertsplit') - set splitright - set splitbelow -endif - -" Visual -" set text color for dark terminal background -set background=dark - -" activate syntax highlighting -if has('syntax') - syntax enable -endif - -" set colorscheme -colorscheme ron - -" display line at which the current is positioned -if exists('+cursorline') - set cursorline - " remove line and make the line bold instead - highlight CursorLine term=bold cterm=bold - highlight CursorLineNR term=bold cterm=bold ctermbg=darkgrey -endif - -" display box from column 81 to 100 -let &colorcolumn=join(range(81, 100), ",") -highlight ColorColumn ctermbg=235 guibg=#2d2d2d - -" display line numbers -set number - -" show currently typed command -set showcmd - -" define characters to display when using 'set list' -set listchars=tab:→\ ,trail:∙,eol:¬,extends:❯,precedes:❮,nbsp:␣ - -" Disable arrow keys -"map -"map -"map -"map - -"map! -"map! -"map! -"map! - -" allow easier pane switching -nnoremap -nnoremap -nnoremap -nnoremap - -" Misc -set mouse=n -noremap m mmHmt:%s///ge'tzt'm +source $HOME/.vim/general.vim +source $HOME/.vim/keybindings.vim diff --git a/xinitrc b/xinitrc index e8c0eb9..6c8f23f 100755 --- a/xinitrc +++ b/xinitrc @@ -1,9 +1,14 @@ #! /bin/bash case "$HOSTNAME" in - fau*) + cipbuero4) # detects fau-machine and defines variable for Xresources - xrdb -load -DHOST_FAUCIP ~/.Xresources + xrdb -load -DHOST_FAUCIP ~/.Xresources + xrandr --output DP-2 --scale 1.6x1.6 + ;; + fau*|cip*) + # detects fau-machine and defines variable for Xresources + xrdb -load -DHOST_FAUCIP ~/.Xresources ;; *) # other hosts cann use SRVR_host @@ -18,13 +23,19 @@ if [ -d $HOME/.fonts ]; then xset fp rehash fi +# start automount-daemon for udisks2 if available +if type "udiskie" >/dev/null 2>&1; then + udiskie & +fi + # autolock on suspend -xss-lock -- i3lock --nofork & +xss-lock -- i3lock --nofork --show-failed-attempts & # autolock after 5 minutes of inactivity xset s 300 # set background +xsetroot -solid '#22AA22' feh --randomize --bg-fill ~/misc/wallpapers exec i3 diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index 1ba6b2b..e42d262 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -45,7 +45,14 @@ alias grep='grep --binary-files=without-match -H -n --color=always' alias less='less -r' alias cp='cp -i' alias mv='mv -i' +# use nvim instead of vim when available +if type nvim >/dev/null 2>&1; then +alias vi='vim' +alias vim='nvim' +fi alias automake='{ while true; do inotifywait -r -e modify . && make; done; } &' +# less verbose and more colorful `ip addr`-output +alias ip='ip -br -color=auto' # ===== sp aliases alias xterm='xterm -fa terminus -fs 8' diff --git a/zsh/completion.zsh b/zsh/completion.zsh index fc06169..65140ab 100644 --- a/zsh/completion.zsh +++ b/zsh/completion.zsh @@ -51,7 +51,9 @@ zstyle ':completion:::::' completer \ #TODO: keep _prefix or not? # ignore case when trying to match typed characters -zstyle ':completion:*:(^approximate):*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' +zstyle ':completion:*:(^approximate):*' matcher-list 'm:{[:lower:]}={[:upper:]}' \ + '+m:{[:upper:]}={[:lower:]}' \ + '+m:{-_}={_-}' # allow one mistake per three characters zstyle -e ':completion:*:approximate:*' max-errors \ @@ -106,11 +108,11 @@ zstyle ':completion:*' separate-sections on zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' # do not complete unwanted files with vim -zstyle ':completion:*:*:vim:*:globbed-files' ignored-patterns \ - '*.aux' '*.log' '*.pdf' '*.ps' '*.bbl' '*.blg' '*.out' '*-blx.bib' '*.run.xml' '*.dvi' \ - '*.o' \ - '*.pyc' \ - '*.class' +zstyle ':completion:*:*:*vim:*:globbed-files' ignored-patterns \ + '*.o' '*.so' '*.out' \ + '*.class' \ + '*.pyc' \ + '*.aux' '*.bbl' '*.bcf' '*.blg' '*.lof' '*.lol' '*.lot' '*.pdf' '*.rubbercache' '*.run.xml' '*.toc' '*.pdf' '*.dvi' # only complete *.pdf with katarakt zstyle ':completion:*:*:katarakt:*:*' file-patterns '*.pdf *(-/)' diff --git a/zsh/exports.zsh b/zsh/exports.zsh index cc36a5f..0de31ae 100644 --- a/zsh/exports.zsh +++ b/zsh/exports.zsh @@ -1,4 +1,6 @@ # set EDITOR variable -if type vim >/dev/null 2>&1; then +if type nvim >/dev/null 2>&1; then + export EDITOR="nvim" +elif type vim >/dev/null 2>&1; then export EDITOR="vim" fi diff --git a/zsh/prompt.zsh b/zsh/prompt.zsh index e625ee9..1e9b4a7 100644 --- a/zsh/prompt.zsh +++ b/zsh/prompt.zsh @@ -7,7 +7,7 @@ case "$OSTYPE" in export LSCOLORS=gxfxcxdxbxegedabagacad ;; *) - export LS_COLORS=di='36;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:' + export LS_COLORS=di='36;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;45:' ;; esac @@ -18,6 +18,9 @@ setopt transient_rprompt # only show the rprompt on the current prompt # ===== set the prompt zshrc_prompt_precmd() { + # call vcs_info before every prompt + vcs_info + # regex to remove all zerospace elements. Used to calculate the width of # the top prompt. local zero='%([BSUBfksu]|([FB]|){*})' @@ -52,6 +55,14 @@ zshrc_prompt_precmd() { # username, green for normal users, red for root local user="%(!.%F{red}.%F{green})%n%f" + # information about unstaged/staged changes in VCS in current directory + local vcs="${vcs_info_msg_0_}" + local vcs_width=${#${(S%%%)vcs//$~zero/}} + if [[ $vcs_width -ne 0 ]]; then + # add brackets if vcs is non-empty + vcs="${bracket_open}${vcs}${bracket_close}" + fi + # hostname, underlined if running on a remote system through SSH local host="%F{green}%m%f" if [[ -n $SSH_CONNECTION ]]; then @@ -95,6 +106,7 @@ zshrc_prompt_precmd() { # combine them to create the prompt local top_left="" local top_right="${bracket_open}${time}${bracket_close}" + local top_middle="${vcs}" local bottom_left="${bracket_open}${user}%F{green}@%f${host}${bracket_close}${exitcode}${separator}${symbol}" local bottom_right= @@ -109,15 +121,16 @@ zshrc_prompt_precmd() { local width_top_prefix=${#${(S%%%)top_prefix//$~zero/}} local width_top_suffix=${#${(S%%%)top_suffix//$~zero/}} local width_top_left=${#${(S%%%)top_left//$~zero/}} + local width_top_middle=${#${(S%%%)top_middle//$~zero/}} local width_top_right=${#${(S%%%)top_right//$~zero/}} # calculate the maximum width of ${top_left}: - # (-4 for brackets, -1 as spacing between top_left and top_right) + # (-4 for brackets and as spacing between top_left, top_middle and top_right) local top_left_width_max=$(( COLUMNS - $width_top_prefix - - $width_top_left - 4 - - 1 - - $width_top_right + - $width_top_left - 2 + - $width_top_middle + - $width_top_right - 2 - $width_top_suffix )) @@ -129,12 +142,14 @@ zshrc_prompt_precmd() { local width=$(( COLUMNS - width_top_prefix - width_top_left + - width_top_middle - width_top_right - width_top_suffix )) - local top_separator="%F{cyan}${(pl:${width}::$dash:)}%f" + local top_left_separator="%F{cyan}${(pl:$((width / 2))::$dash:)}%f" + local top_right_separator="%F{cyan}${(pl:$((width / 2 + width % 2))::$dash:)}%f" - PROMPT="${top_prefix}${top_left}${top_separator}${top_right}${top_suffix} + PROMPT="${top_prefix}${top_left}${top_left_separator}${top_middle}${top_right_separator}${top_right}${top_suffix} ${bottom_prefix}${bottom_left} " RPROMPT="${bottom_right}${bottom_suffix}" diff --git a/zsh/vcs.zsh b/zsh/vcs.zsh new file mode 100644 index 0000000..ef69f50 --- /dev/null +++ b/zsh/vcs.zsh @@ -0,0 +1,69 @@ +autoload -Uz vcs_info + +# only look for certain VCS +zstyle ':vcs_info:*' enable git + +# check repository for changes so that they can be used in %u/%c +# (this might be slow for bigger repositories) +zstyle ':vcs_info:*' check-for-changes yes + +# display current branch (%b -> green), unstaged + staged changes (%u/%c -> green), +# VCS (%s -> blue) and custom messages (%m). +zstyle ':vcs_info:*' formats \ + "%F{green}%b%u%c%F{default}:%F{blue}%s%F{default}%m" +# during special actions (e.g. merge, rebase), also display those (%a -> red) +zstyle ':vcs_info:*' actionformats \ + "(%F{green}%b%u%c%F{default}/%F{red}%a%F{default}:%F{blue}%s%F{default}%m)" + +# set style for formats/actionformats when unstaged (%u) and staged (%c) +# changes are detected in the repository +# (check-for-changes must be true for this to work) +zstyle ':vcs_info:*' unstagedstr '¹' +zstyle ':vcs_info:*' stagedstr '²' + +# force vcs_info to be run. this prevents running it later for performance reasons. +# default to run vcs_info. will be prevented from running later if possible +# (for speedup) +zshrc_force_run_vcs_info=1 + +# cache data +zstyle ':vcs_info:*+pre-get-data:*' hooks pre-get-data ++vi-pre-get-data() { + # only git and mercurial support and need caching. ignore all other VCS + [[ $vcs != git && $vcs != hg ]] && return + + # run vcs_info on startup, on directory change (or for other custom reasons) + if [[ -n $zshrc_force_run_vcs_info ]]; then + zshrc_force_run_vcs_info= + return + fi + + # don't run vcs_info by default to speed up the shell + ret=1 + case $(fc -ln $(($HISTCMD-1))) in + # vcs status might need an update after running git/hg + git* | g\ *) + ret=0 + ;; + esac +} + +# display stash count +function +vi-git-stashes() { + if [[ -s ${hook_com[base]/.git/refs/stash} ]]; then + local -a stashes + # "grep" output of git stash list via (M) and :#(...) + stashes=( ${(M)${(f)"$(git stash list 2>/dev/null)"}:#(*WIP*)} ) + + if [[ ${#stashes} -gt 0 ]]; then + hook_com[misc]+=" %F{yellow}${#stashes}s%F{default}" + fi + fi +} +zstyle ':vcs_info:git*+set-message:*' hooks git-stashes + +# enforce running vcs_info when changing directory +prompt_chpwd() { + zshrc_force_run_vcs_info=1 +} +chpwd_functions+=(prompt_chpwd) diff --git a/zshrc b/zshrc index d147f0b..24e77ac 100644 --- a/zshrc +++ b/zshrc @@ -2,9 +2,15 @@ source ~/.zsh/keybindings.zsh source ~/.zsh/setopt.zsh source ~/.zsh/general.zsh +source ~/.zsh/vcs.zsh source ~/.zsh/prompt.zsh source ~/.zsh/completion.zsh source ~/.zsh/history.zsh source ~/.zsh/aliases.zsh source ~/.zsh/multiplexer.zsh source ~/.zsh/exports.zsh + +# Try loading additional local config if available +if [ -f ~/.zsh/custom.zsh ]; then + source ~/.zsh/custom.zsh +fi