From ee1cc415b30148a77658b2b063f561f42e61596f Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Wed, 22 Apr 2020 18:35:58 +0700 Subject: [PATCH] Improvements to bookmark script. Cleaning up alacritty config. Moving dotfiles around. --- .ideavimrc => .config/.ideavimrc | 1 + .config/alacritty/alacritty.yml | 406 +----------------- .config/fish/config.fish | 1 + .../fish/functions/dotfiles_update_win.fish | 5 +- .config/fish/marks.fish | 140 +++--- .vimrc | 1 + 6 files changed, 68 insertions(+), 486 deletions(-) rename .ideavimrc => .config/.ideavimrc (98%) diff --git a/.ideavimrc b/.config/.ideavimrc similarity index 98% rename from .ideavimrc rename to .config/.ideavimrc index 7243831..47a4f49 100755 --- a/.ideavimrc +++ b/.config/.ideavimrc @@ -64,6 +64,7 @@ nnoremap 2 nnoremap gt :action GotoTypeDeclaration nnoremap s :action KJumpAction.Word0 +nnoremap h :action HideAllWindows nnoremap q :action CloseContent nnoremap d :action QuickImplementations nnoremap t :action QuickJavaDoc diff --git a/.config/alacritty/alacritty.yml b/.config/alacritty/alacritty.yml index 27b67b0..c5ce129 100644 --- a/.config/alacritty/alacritty.yml +++ b/.config/alacritty/alacritty.yml @@ -171,168 +171,7 @@ font: #draw_bold_text_with_bright_colors: false schemes: - Xterm: &xterm - # Default colors - primary: - background: '#000000' - foreground: '#ffffff' - # Normal colors - normal: - black: '#000000' - red: '#cd0000' - green: '#00cd00' - yellow: '#cdcd00' - blue: '#0000ee' - magenta: '#cd00cd' - cyan: '#00cdcd' - white: '#e5e5e5' - # Bright colors - bright: - black: '#7f7f7f' - red: '#ff0000' - green: '#00ff00' - yellow: '#ffff00' - blue: '#5c5cff' - magenta: '#ff00ff' - cyan: '#00ffff' - white: '#ffffff' - # Colors (Ubuntu) - - Ayu Dark: &ayu - # Default colors - primary: - background: '#0A0E14' - foreground: '#B3B1AD' - - # Normal colors - normal: - black: '#01060E' - red: '#EA6C73' - green: '#91B362' - yellow: '#F9AF4F' - blue: '#53BDFA' - magenta: '#FAE994' - cyan: '#90E1C6' - white: '#C7C7C7' - - # Bright colors - bright: - black: '#686868' - red: '#F07178' - green: '#C2D94C' - yellow: '#FFB454' - blue: '#59C2FF' - magenta: '#FFEE99' - cyan: '#95E6CB' - white: '#FFFFFF' - - Tomorrow Night: &tmr - # Default colors - primary: - background: '0x1d1f21' - foreground: '0xc5c8c6' - - # Colors the cursor will use if `custom_cursor_colors` is true - cursor: - text: '0x1d1f21' - cursor: '0xc5c8c6' - - # Normal colors - normal: - black: '0x1d1f21' - red: '0xcc6666' - green: '0xb5bd68' - yellow: '0xf0c674' - blue: '0x81a2be' - magenta: '0xb294bb' - cyan: '0x8abeb7' - white: '0xc5c8c6' - - # Bright colors - bright: - black: '0x969896' - red: '0xcc6666' - green: '0xb5bd68' - yellow: '0xf0c674' - blue: '0x81a2be' - magenta: '0xb294bb' - cyan: '0x8abeb7' - white: '0xffffff' - - indexed_colors: - - { index: 16, color: '0xde935f' } - - { index: 17, color: '0xa3685a' } - - { index: 18, color: '0x282a2e' } - - { index: 19, color: '0x373b41' } - - { index: 20, color: '0xb4b7b4' } - - { index: 21, color: '0xe0e0e0' } - - Dracula: &dracula - # Default colors - primary: - background: '#282a36' - foreground: '#f8f8f2' - - # Normal colors - normal: - black: '#000000' - red: '#ff5555' - green: '#50fa7b' - yellow: '#f1fa8c' - blue: '#caa9fa' - magenta: '#ff79c6' - cyan: '#8be9fd' - white: '#bfbfbf' - - # Bright colors - bright: - black: '#575b70' - red: '#ff6e67' - green: '#5af78e' - yellow: '#f4f99d' - blue: '#caa9fa' - magenta: '#ff92d0' - cyan: '#9aedfe' - white: '#e6e6e6' - - # Colors (iTerm 2 default theme) - iTerm: &iterm - # Default colors - primary: - background: '#101421' - foreground: '#fffbf6' - - # Normal colors - normal: - black: '#2e2e2e' - red: '#eb4129' - green: '#abe047' - yellow: '#f6c744' - blue: '#47a0f3' - magenta: '#7b5cb0' - cyan: '#64dbed' - white: '#e5e9f0' - - # Bright colors - bright: - black: '#565656' - red: '#ec5357' - green: '#c0e17d' - yellow: '#f9da6a' - blue: '#49a4f8' - magenta: '#a47de9' - cyan: '#99faf2' - white: '#ffffff' - - - - - - - ## [New Moon](https://github.com/taniarascia/new-moon) - - # Colors (New Moon) New Moon: &newmoon # Default colors primary: @@ -358,252 +197,9 @@ schemes: magenta: '#E1A6F2' cyan: '#76D4D6' white: '#FFFFFF' - - ## [Nord](https://github.com/arcticicestudio/nord) - - # Colors (Nord) - Nord: &nord - # Default colors - primary: - background: '#2E3440' - foreground: '#D8DEE9' - - # Normal colors - normal: - black: '#3B4252' - red: '#BF616A' - green: '#A3BE8C' - yellow: '#EBCB8B' - blue: '#81A1C1' - magenta: '#B48EAD' - cyan: '#88C0D0' - white: '#E5E9F0' - - # Bright colors - bright: - black: '#4C566A' - red: '#BF616A' - green: '#A3BE8C' - yellow: '#EBCB8B' - blue: '#81A1C1' - magenta: '#B48EAD' - cyan: '#8FBCBB' - white: '#ECEFF4' - - ## [Oceanic Next](https://github.com/voronianski/oceanic-next-color-scheme) - - # Colors (Oceanic Next) - Oceanic: &oceanic - # Default colors - primary: - background: '#1b2b34' - foreground: '#d8dee9' - - # Colors the cursor will use if `custom_cursor_colors` is true - cursor: - text: '#1b2b34' - cursor: '#ffffff' - - # Normal colors - normal: - black: '#343d46' - red: '#EC5f67' - green: '#99C794' - yellow: '#FAC863' - blue: '#6699cc' - magenta: '#c594c5' - cyan: '#5fb3b3' - white: '#d8dee9' - - # Bright colors - bright: - black: '#343d46' - red: '#EC5f67' - green: '#99C794' - yellow: '#FAC863' - blue: '#6699cc' - magenta: '#c594c5' - cyan: '#5fb3b3' - white: '#d8dee9' - - ## One Dark - - # Colors (One Dark) - One Dark: &onedark - # Default colors - primary: - background: '#282c34' - foreground: '#abb2bf' - - # Normal colors - normal: - # NOTE: Use '#131613' for the `black` color if you'd like to see - # black text on the background. - black: '#282c34' - red: '#e06c75' - green: '#98c379' - yellow: '#d19a66' - blue: '#61afef' - magenta: '#c678dd' - cyan: '#56b6c2' - white: '#abb2bf' - - # Bright colors - bright: - black: '#5c6370' - red: '#e06c75' - green: '#98c379' - yellow: '#d19a66' - blue: '#61afef' - magenta: '#c678dd' - cyan: '#56b6c2' - white: '#ffffff' - - ## [Oxide](https://github.com/dikiaap/dotfiles) - - # Colors (Oxide) - Oxide: &oxide - # Default colors - primary: - background: '#212121' - foreground: '#c0c5ce' - bright_foreground: '#f3f4f5' - - cursor: - text: '#212121' - cursor: '#c0c5ce' - - # Normal colors - normal: - black: '#212121' - red: '#e57373' - green: '#a6bc69' - yellow: '#fac863' - blue: '#6699cc' - magenta: '#c594c5' - cyan: '#5fb3b3' - white: '#c0c5ce' - - # Bright colors - bright: - black: '#5c5c5c' - red: '#e57373' - green: '#a6bc69' - yellow: '#fac863' - blue: '#6699cc' - magenta: '#c594c5' - cyan: '#5fb3b3' - white: '#f3f4f5' - - ## [Snazzy](https://github.com/sindresorhus/hyper-snazzy) - - # Colors (Snazzy) - Snazzy: &snazzy - # Default colors - primary: - background: '#282a36' - foreground: '#eff0eb' - - # Normal colors - normal: - black: '#282a36' - red: '#ff5c57' - green: '#5af78e' - yellow: '#f3f99d' - blue: '#57c7ff' - magenta: '#ff6ac1' - cyan: '#9aedfe' - white: '#f1f1f0' - - # Bright colors - bright: - black: '#686868' - red: '#ff5c57' - green: '#5af78e' - yellow: '#f3f99d' - blue: '#57c7ff' - magenta: '#ff6ac1' - cyan: '#9aedfe' - white: '#f1f1f0' - - ## [Taerminal](https://github.com/cozywigwam/iterm-taerminal) - - # Colors (Taerminal) - Taerminal: &taerminal - # Default colors - primary: - background: '#26282a' - foreground: '#f0f0f0' - cursor: - background: '#f0f0f0' - foreground: '#26282a' - - # Normal colors - normal: - black: '#26282a' - red: '#ff8878' - green: '#b4fb73' - yellow: '#fffcb7' - blue: '#8bbce5' - magenta: '#ffb2fe' - cyan: '#a2e1f8' - white: '#f1f1f1' - - # Bright colors - bright: - black: '#6f6f6f' - red: '#fe978b' - green: '#d6fcba' - yellow: '#fffed5' - blue: '#c2e3ff' - magenta: '#ffc6ff' - cyan: '#c0e9f8' - white: '#ffffff' - - ## [Tender](https://github.com/huyvohcmc/tender-alacritty) - - # Colors (Tender) - Tender: &tender - # Default colors - primary: - background: '#282828' - foreground: '#eeeeee' - - # Normal colors - normal: - black: '#282828' - red: '#f43753' - green: '#c9d05c' - yellow: '#ffc24b' - blue: '#b3deef' - magenta: '#d3b987' - cyan: '#73cef4' - white: '#eeeeee' - - # Bright colors - bright: - black: '#4c4c4c' - red: '#f43753' - green: '#c9d05c' - yellow: '#ffc24b' - blue: '#b3deef' - magenta: '#d3b987' - cyan: '#73cef4' - white: '#feffff' - -#colors: *tender -#colors: *ayu -#colors: *dracula -#colors: *tmr -#colors: *iterm + colors: *newmoon -#colors: *nord -#colors: *oceanic -#colors: *onedark -#colors: *oxide -#colors: *snazzy -#colors: *taerminal custom_cursor_colors: true # black diff --git a/.config/fish/config.fish b/.config/fish/config.fish index dcbe507..9ccaaf7 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -4,6 +4,7 @@ set -g MANPAGER "sh -c 'col -bx | bat -l man -p'" set EDITOR vim set -U FZF_COMPLETE 0 set -U FZF_LEGACY_KEYBINDINGS 0 +set -U FZF_DEFAULT_OPTS "--height 40% --reverse --border" source ~/.config/fish/dircolors.fish source ~/.config/fish/marks.fish diff --git a/.config/fish/functions/dotfiles_update_win.fish b/.config/fish/functions/dotfiles_update_win.fish index c7c21be..1bae859 100644 --- a/.config/fish/functions/dotfiles_update_win.fish +++ b/.config/fish/functions/dotfiles_update_win.fish @@ -1,5 +1,6 @@ # Defined in /tmp/fish.6qfkSz/dotfiles-update-win.fish @ line 1 -function dotfiles-update-win +function dotfiles_update_win cp /mnt/c/Users/josep/AppData/Roaming/alacritty/alacritty.yml ~/.config/alacritty/alacritty.yml - cp /mnt/c/Users/josep/.ideavimrc ~/.ideavimrc + cp /mnt/c/Users/josep/.ideavimrc ~/.config/.ideavimrc + cp /mnt/c/Users/josep/AutoHotkey-script-Open-Show-Apps.ahk ~/.config/AutoHotkey-script-Open-Show-Apps.ahk end diff --git a/.config/fish/marks.fish b/.config/fish/marks.fish index 429179e..1317105 100644 --- a/.config/fish/marks.fish +++ b/.config/fish/marks.fish @@ -1,11 +1,14 @@ if not set -q BMS_FILE set -gx BMS_FILE $HOME/.config/fish/bmarks end +if not set -q BMS_OPENER + set -gx BMS_OPENER xdg-open +end touch $BMS_FILE -set title_col (set_color white) -set text_col (set_color green) +set title_col (set_color cyan) +set text_col (set_color normal) set error_col (set_color red) function bookmark --description "Bookmark files and directories in fish" @@ -22,39 +25,38 @@ function bookmark --description "Bookmark files and directories in fish" switch $argv[1] case "go" if [ (count $argv) -lt 2 ] - echo -n $error_col - echo -e "Error: Please provide the bookmark name" - echo -n $text_col + __bookmarks_print_error "Please provide the bookmark name" return 1 end - set bname $argv[2] - if grep -q "^$bname " $BMS_FILE - echo -n $error_col - echo "Error: No bookmark by the name of $bname exists." - echo -n $text_col + set -l bname $argv[2] + if not grep -q "^$bname " $BMS_FILE + __bookmarks_print_error "No bookmark by the name of $bname exists." return 1 end - set bpath (cut -f2- -d' ') - if [ -e $bpath ] + set bpath (grep "^$bname " $BMS_FILE | cut -f2- -d' ') + if [ -e "$bpath" ] + if [ -d "$bpath" ] + cd "$bpath" + return 0 + else + __bookmarks_opener "$bpath" + end else - + __bookmarks_print_error "Bookmark is no longer valid for $bpath." + # TODO Add prompt for deletion end case "add" if [ (count $argv) -gt 1 ] set bname $argv[2] if echo $bname | not grep -q "^[a-zA-Z0-9_-]*\$" - echo -n $error_col - echo -e "Error: Bookmark names may only contain alphanumeric characters and underscores." - echo -n $text_col + __bookmarks_print_error "Bookmark names may only contain alphanumeric characters and underscores." return 1 end if [ (count $argv) -gt 2 ] set bpath (readlink -f $argv[3]) - if not [ -e $bpath ] - echo -n $error_col - echo -e "Error: No directory or path exist for provided argument." - echo -n $text_col + if not [ -e "$bpath" ] + __bookmarks_print_error "No directory or path exist for provided argument." return 1 end else @@ -65,9 +67,7 @@ function bookmark --description "Bookmark files and directories in fish" set bpath (pwd) end if grep -q "^$bname " $BMS_FILE - echo -n $error_col - echo "Error: Bookmark $bname already exists." - echo -n $text_col + __bookmarks_print_error "Bookmark $bname already exists." return 1 end echo "$bname $bpath" >> $BMS_FILE @@ -76,68 +76,29 @@ function bookmark --description "Bookmark files and directories in fish" __bookmarks_update_completions case "remove" - # if grep -q "^ + if [ (count $argv) -lt 2 ] + __bookmarks_print_error "Please provide the bookmark name" + return 1 + end + set -l bname $argv[2] + if not grep -q "^$bname " $BMS_FILE + __bookmarks_print_error "No bookmark by the name of $bname exists." + return 1 + end + sed -i "/^$bname /d" bmarks + echo "Bookmark '$bname' removed." case "list" - cat $BMS_FILE + set bpath (grep "^$bname " $BMS_FILE | cut -f2- -d' ') + # Use a random delimeter {*#*} that's unlikely that someone has used for a file/dir name + # If not directories with spaces will be split into columns + echo -n (set_color green) + echo " Name {*#*} Path" | cat - $BMS_FILE | sed "2,\$ s/^\([[:alnum:]_-]\+\)/$title_col &{*#*}$text_col/" | column -t -s "{*#*}" + echo end end -function go_to_bookmark --description "Go to (cd) to the directory associated with a bookmark" - if [ (count $argv) -lt 1 ] - echo -e "\033[0;31mERROR: '' bookmark does not exist\033[00m" - return 1 - end - if not _check_help $argv[1]; - cat $BMS_FILE | grep "^export DIR_" | sed "s/^export /set -x /" | sed "s/=/ /" | . - set -l target (env | grep "^DIR_$argv[1]=" | cut -f2 -d "=") - if [ ! -n "$target" ] - echo -e "\033[0;31mERROR: '$argv[1]' bookmark does not exist\033[00m" - return 1 - end - if [ -d "$target" ] - cd "$target" - return 0 - else - echo -e "\033[0;31mERROR: '$target' does not exist\033[00m" - return 1 - end - end -end - -function print_bookmark --description "Print the directory associated with a bookmark" - if [ (count $argv) -lt 1 ] - echo -e "\033[0;31mERROR: bookmark name required\033[00m" - return 1 - end - if not _check_help $argv[1]; - cat $BMS_FILE | grep "^export DIR_" | sed "s/^export /set -x /" | sed "s/=/ /" | . - env | grep "^DIR_$argv[1]=" | cut -f2 -d "=" - end -end - -function delete_bookmark --description "Delete a bookmark" - if [ (count $argv) -lt 1 ] - echo -e "\033[0;31mERROR: bookmark name required\033[00m" - return 1 - end - if not _valid_bookmark $argv[1]; - echo -e "\033[0;31mERROR: bookmark '$argv[1]' does not exist\033[00m" - return 1 - else - sed -i='' "/DIR_$argv[1]=/d" $BMS_FILE - _update_completions - end -end - -function list_bookmarks --description "List all available bookmarks" - if not _check_help $argv[1]; - cat $BMS_FILE | grep "^export DIR_" | sed "s/^export /set -x /" | sed "s/=/ /" | . - env | sort | awk '/DIR_.+/{split(substr($0,5),parts,"="); printf("\033[0;33m%-20s\033[0m %s\n", parts[1], parts[2]);}' - end -end - function _valid_bookmark if begin; [ (count $argv) -lt 1 ]; or not [ -n $argv[1] ]; end return 1 @@ -152,6 +113,27 @@ function _valid_bookmark end end +function __bookmarks_opener --description "Default opener" + set -l f "$argv[1]" + switch (file --mime-type -b "$f") + case "text/*" + $EDITOR "$f" + case "application/*" + file "$f" | grep -iq text && $EDITOR "$f" || $BMS_OPENER "$f" + case "image/*" + sxiv "$f" 2> /dev/null && $BMS_OPENER "$f" + case "*" + $BMS_OPENER "$f" + end +end + +function __bookmarks_print_error + echo -n $error_col + echo -n "Error: " + echo -n $text_col + echo $argv[1] +end + function __bookmarks_update_completions cat $BMS_FILE | grep "^export DIR_" | sed "s/^export /set -x /" | sed "s/=/ /" | . set -x _marks (env | grep "^DIR_" | sed "s/^DIR_//" | cut -f1 -d "=" | tr '\n' ' ') diff --git a/.vimrc b/.vimrc index f80f9da..8eebb7f 100644 --- a/.vimrc +++ b/.vimrc @@ -7,6 +7,7 @@ set splitright set tabstop=4 set shiftwidth=4 set expandtab +set softtabstop=4 set nowrap set hlsearch set ignorecase