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:
7
fish/apps/autojump.fish
Normal file
7
fish/apps/autojump.fish
Normal 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
|
||||
@@ -2,68 +2,29 @@
|
||||
# Basics, etc…
|
||||
# ============
|
||||
|
||||
# Default browser
|
||||
# Default editor
|
||||
set -g -x EDITOR "emacsclient"
|
||||
set -g -x ALTERNATE_EDITOR "vim"
|
||||
|
||||
# Add ~/bin to PATH
|
||||
set -g -x PATH ~/bin $PATH
|
||||
# Setup PATH
|
||||
ensure_path ~/bin
|
||||
ensure_path ~/.emacs.d/bin
|
||||
|
||||
# Disable Fish greeting banner
|
||||
set --universal fish_greeting
|
||||
|
||||
# iTerm2 integration
|
||||
source ~/.config/fish/fish_startup.in
|
||||
# Configuration for apps
|
||||
for app in ~/.config/fish/apps/*.fish
|
||||
source $app
|
||||
end
|
||||
|
||||
# OS-specific configuration
|
||||
switch (uname)
|
||||
case Linux
|
||||
source ~/.config/fish/linux.fish
|
||||
case Darwin
|
||||
source ~/.config/fish/osx.fish
|
||||
case '*'
|
||||
echo 'Unknown OS. No specifc config'
|
||||
end
|
||||
source ~/.config/fish/os/os.fish
|
||||
|
||||
# Machine-local config
|
||||
if test -e ~/.config/fish/local.fish
|
||||
source ~/.config/fish/local.fish
|
||||
end
|
||||
|
||||
# =======
|
||||
# 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
|
||||
# Hybrid Vi Mode
|
||||
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
4
fish/functions/ec.fish
Normal file
@@ -0,0 +1,4 @@
|
||||
# Emacs Client
|
||||
function ec
|
||||
emacsclient -n --alternate-editor=emacs $argv
|
||||
end
|
||||
7
fish/functions/ensure_path.fish
Normal file
7
fish/functions/ensure_path.fish
Normal 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
|
||||
6
fish/functions/hybrid_bindings.fish
Normal file
6
fish/functions/hybrid_bindings.fish
Normal 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
4
fish/functions/ip.fish
Normal file
@@ -0,0 +1,4 @@
|
||||
# Prints current public IP address
|
||||
function ip
|
||||
curl icanhazip.com
|
||||
end
|
||||
4
fish/functions/src.fish
Normal file
4
fish/functions/src.fish
Normal 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
9
fish/os/os.fish
Normal 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
|
||||
Reference in New Issue
Block a user