Fish config refactor

Move things into sub-files and sub-directories
Add ensure_path function to make sure stuff doesn't get spammed multiple
times into the PATH
This commit is contained in:
Tim McCarthy
2020-03-31 12:42:50 -07:00
parent a8e6dd2c75
commit 3ccf865b99
12 changed files with 51 additions and 49 deletions

7
fish/apps/autojump.fish Normal file
View File

@@ -0,0 +1,7 @@
# ========
# Autojump
# https://github.com/wting/autojump
# ========
[ -f /usr/local/share/autojump/autojump.fish ]; and . /usr/local/share/autojump/autojump.fish
[ -f /usr/share/autojump/autojump.fish ]; and . /usr/share/autojump/autojump.fish

View File

@@ -2,68 +2,29 @@
# Basics, etc… # Basics, etc…
# ============ # ============
# Default browser # Default editor
set -g -x EDITOR "emacsclient" set -g -x EDITOR "emacsclient"
set -g -x ALTERNATE_EDITOR "vim" set -g -x ALTERNATE_EDITOR "vim"
# Add ~/bin to PATH # Setup PATH
set -g -x PATH ~/bin $PATH ensure_path ~/bin
ensure_path ~/.emacs.d/bin
# Disable Fish greeting banner # Disable Fish greeting banner
set --universal fish_greeting set --universal fish_greeting
# iTerm2 integration # Configuration for apps
source ~/.config/fish/fish_startup.in for app in ~/.config/fish/apps/*.fish
source $app
end
# OS-specific configuration # OS-specific configuration
switch (uname) source ~/.config/fish/os/os.fish
case Linux
source ~/.config/fish/linux.fish
case Darwin
source ~/.config/fish/osx.fish
case '*'
echo 'Unknown OS. No specifc config'
end
# Machine-local config # Machine-local config
if test -e ~/.config/fish/local.fish if test -e ~/.config/fish/local.fish
source ~/.config/fish/local.fish source ~/.config/fish/local.fish
end end
# ======= # Hybrid Vi Mode
# Vi Mode
# =======
function hybrid_bindings --description "Vi-style bindings that inherit emacs-style bindings in all modes"
for mode in default insert visual
fish_default_key_bindings -M $mode
end
fish_vi_key_bindings --no-erase
end
set -g fish_key_bindings hybrid_bindings set -g fish_key_bindings hybrid_bindings
# ========
# Autojump
# https://github.com/wting/autojump
# ========
[ -f /usr/local/share/autojump/autojump.fish ]; and . /usr/local/share/autojump/autojump.fish
[ -f /usr/share/autojump/autojump.fish ]; and . /usr/share/autojump/autojump.fish
# =========
# Functions
# =========
function ec
emacsclient -n --alternate-editor=emacs $argv
end
# IP addresses
function ip
curl icanhazip.com
end
# reload your Fish config
function src
source ~/.config/fish/config.fish; and clear
end

4
fish/functions/ec.fish Normal file
View File

@@ -0,0 +1,4 @@
# Emacs Client
function ec
emacsclient -n --alternate-editor=emacs $argv
end

View File

@@ -0,0 +1,7 @@
function ensure_path --description "Ensures directories are in $PATH"
for pathdir in $argv
if not set -l index (contains -i $pathdir $PATH)
set -g -x PATH $pathdir $PATH
end
end
end

View File

@@ -0,0 +1,6 @@
function hybrid_bindings --description "Vi-style bindings that inherit emacs-style bindings in all modes"
for mode in default insert visual
fish_default_key_bindings -M $mode
end
fish_vi_key_bindings --no-erase
end

4
fish/functions/ip.fish Normal file
View File

@@ -0,0 +1,4 @@
# Prints current public IP address
function ip
curl icanhazip.com
end

4
fish/functions/src.fish Normal file
View File

@@ -0,0 +1,4 @@
# reload your Fish config
function src
source ~/.config/fish/config.fish; and clear
end

9
fish/os/os.fish Normal file
View File

@@ -0,0 +1,9 @@
# OS-specific configuration
switch (uname)
case Linux
source ~/.config/fish/os/linux.fish
case Darwin
source ~/.config/fish/os/osx.fish
case '*'
echo 'Unknown OS. No specifc config'
end