fish: add fish_vars, improve fish_colors
This commit is contained in:
parent
737cbd0d9a
commit
87fdffca9e
6
fish/.gitignore
vendored
6
fish/.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
fish_variables
|
||||
fisher/
|
||||
fish_user_key_bindings.fish
|
||||
fzf_key_bindings.fish
|
||||
private/
|
||||
functions/br.fish
|
||||
functions/fish_user_key_bindings.fish
|
||||
functions/fzf_key_bindings.fish
|
||||
|
@ -10,21 +10,10 @@ set -gx LANG en_US.UTF-8
|
||||
set -gx SBT_OPTS '-Dsbt.supershell=false'
|
||||
set -gx ENHANCD_DISABLE_DOT 1
|
||||
|
||||
if command -q moar
|
||||
set -gx PAGER moar
|
||||
else if command -q most
|
||||
set -gx PAGER most
|
||||
end
|
||||
|
||||
if test -x /usr/libexec/java_home
|
||||
set -gx JAVA_HOME (/usr/libexec/java_home -v 1.8)
|
||||
end
|
||||
|
||||
# Path
|
||||
if not set -q fish_user_paths
|
||||
set -U fish_user_paths ~/bin ~/go/bin
|
||||
end
|
||||
|
||||
# FZF (https://github.com/junegunn/fzf)
|
||||
set -gx FZF_DEFAULT_OPTS "--no-height --layout=reverse --multi"
|
||||
set -gx FZF_DEFAULT_COMMAND "fd --type=file"
|
||||
@ -66,7 +55,7 @@ for file in $fisher_path/conf.d/*.fish
|
||||
end
|
||||
if not functions -q fisher
|
||||
echo "Installing fish-shell package manager: $fisher_path/functions/fisher.fish"
|
||||
curl https://git.io/fisher --create-dirs -sLo $fisher_path/functions/fisher.fish
|
||||
curl -fsSL -o $fisher_path/functions/fisher.fish --create-dirs https://git.io/fisher
|
||||
echo "Installing fish-shell packages..."
|
||||
fish -c fisher
|
||||
end
|
||||
|
@ -1,20 +1,7 @@
|
||||
function fbrew --description "Fuzzy homebrew"
|
||||
if test (count $argv) -eq 0
|
||||
echo "Usage: fbrew <install|uninstall>"
|
||||
return 1
|
||||
end
|
||||
|
||||
switch $argv[1]
|
||||
case i install
|
||||
_fbrew_install $argv[2..-1]
|
||||
case u uninstall
|
||||
_fbrew_uninstall $argv[2..-1]
|
||||
case '*'
|
||||
echo "Unsupported command: $argv[1]"
|
||||
end
|
||||
end
|
||||
|
||||
function _fbrew_install
|
||||
# Helper function for 'brew install'
|
||||
function _fbrew_install
|
||||
set --local inst_pkgs $argv
|
||||
|
||||
if test (count $inst_pkgs) -eq 0
|
||||
@ -25,9 +12,12 @@ function _fbrew_install
|
||||
echo "Installing: $inst_pkgs"
|
||||
brew install $inst_pkgs
|
||||
end
|
||||
end
|
||||
|
||||
function _fbrew_uninstall
|
||||
functions --erase _fbrew_install
|
||||
end
|
||||
|
||||
# Helper function for 'brew uninstall'
|
||||
function _fbrew_uninstall
|
||||
set --local uninst_pkgs $argv
|
||||
|
||||
# Don't uninstall these packages
|
||||
@ -105,4 +95,24 @@ function _fbrew_uninstall
|
||||
echo "Will not uninstall: $uninst_pkgs_leave"
|
||||
end
|
||||
end
|
||||
|
||||
functions --erase _fbrew_uninstall
|
||||
end
|
||||
|
||||
if test (count $argv) -eq 0
|
||||
echo "Usage: fbrew <install|uninstall>"
|
||||
return 1
|
||||
end
|
||||
|
||||
switch $argv[1]
|
||||
case i install
|
||||
_fbrew_install $argv[2..-1]
|
||||
case u uninstall
|
||||
_fbrew_uninstall $argv[2..-1]
|
||||
case '*'
|
||||
echo "Unsupported command: $argv[1]"
|
||||
end
|
||||
|
||||
functions --erase _fbrew_install
|
||||
functions --erase _fbrew_uninstall
|
||||
end
|
||||
|
@ -1,14 +1,41 @@
|
||||
function fish_colors --description 'Print the fish color variables'
|
||||
set --local plain 0
|
||||
if contains -- '--plain' $argv
|
||||
set plain 1
|
||||
|
||||
# Helper function that prints the fish commands needed to set the current colors
|
||||
function _fish_colors_commands --argument-names _variable_scope
|
||||
set -l color_list (set -n | grep fish | grep color | grep -v __)
|
||||
for i in $color_list
|
||||
echo (string join ' ' -- set $_variable_scope $i $$i)
|
||||
end
|
||||
end
|
||||
|
||||
for i in (set -n | string match 'fish*_color*')
|
||||
if test $plain -eq 1
|
||||
echo $i $$i
|
||||
# Helper function that prints examples using the current colors
|
||||
function _fish_colors_examples
|
||||
set -l color_list (set -n | grep fish | grep color | grep -v __)
|
||||
set -l normal (set_color normal)
|
||||
set -l bold (set_color --bold)
|
||||
|
||||
printf "\n| %-32s | %-38s | %-22s |\n" Variable Definition Example
|
||||
echo '|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|'
|
||||
for variable in $color_list
|
||||
set -l value $$variable
|
||||
set -l color (set_color $value ^/dev/null)
|
||||
or begin
|
||||
printf "| %-32s | %s%-38s | %-22s |\n" "$variable" (set_color --bold white --background=red) "$value" "The quick brown fox..."
|
||||
continue
|
||||
end
|
||||
printf "| $normal%-32s | $bold%-38s$normal | $color%-22s$normal |\n" "$variable" "$value" "The quick brown fox..."
|
||||
end
|
||||
echo '|__________________________________|________________________________________|________________________|'\n
|
||||
end
|
||||
|
||||
if contains -- '-g' $argv; or contains -- '--global' $argv
|
||||
_fish_colors_commands '--global'
|
||||
else if contains -- '-U' $argv; or contains -- '--universal' $argv
|
||||
_fish_colors_commands '--universal'
|
||||
else
|
||||
echo $i (set_color $$i)$$i(set_color normal)
|
||||
end
|
||||
_fish_colors_examples
|
||||
end
|
||||
|
||||
functions --erase _fish_colors_commands
|
||||
functions --erase _fish_colors_examples
|
||||
end
|
||||
|
@ -1,9 +0,0 @@
|
||||
function fish_trace --description 'Toggle fish function tracing'
|
||||
if not set --query fish_trace
|
||||
echo 'Enabling fish function tracing...'
|
||||
set --global fish_trace 1
|
||||
else
|
||||
echo 'Disabling fish function tracing...'
|
||||
set --erase fish_trace
|
||||
end
|
||||
end
|
28
fish/functions/fish_vars.fish
Normal file
28
fish/functions/fish_vars.fish
Normal file
@ -0,0 +1,28 @@
|
||||
function fish_vars
|
||||
set -l _special_variables BROWSER CDPATH LANG PATH SHLVL fish_ambiguous_width fish_emoji_width fish_escape_delay_ms fish_trace fish_user_paths hostname umask version
|
||||
set -l _path_variables CDPATH PATH fish_user_paths
|
||||
set -l _table_format "| %-24s | %-38s |\n"
|
||||
|
||||
printf "\n$_table_format" Variable Value
|
||||
|
||||
printf $_table_format (printf "%.s¯" (seq 24)) (printf "%.s¯" (seq 38))
|
||||
|
||||
for variable in $_special_variables
|
||||
if set -q $variable
|
||||
if contains -- $variable $_path_variables
|
||||
set -l paths (string collect (string split " " $$variable))
|
||||
printf $_table_format $variable "- $paths[1]"
|
||||
for path in $paths[2..-1]
|
||||
printf $_table_format "" "- $path"
|
||||
end
|
||||
else
|
||||
printf $_table_format $variable $$variable
|
||||
end
|
||||
else
|
||||
printf $_table_format $variable "<unset>"
|
||||
end
|
||||
end
|
||||
|
||||
printf $_table_format (printf "%.s_" (seq 24)) (printf "%.s_" (seq 38))
|
||||
|
||||
end
|
8
install-fzf.sh
Executable file
8
install-fzf.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Install fzf key-bindings
|
||||
FZF_INSTALLER=$(brew --prefix)/opt/fzf/install
|
||||
|
||||
if [ -x "$FZF_INSTALLER" ]; then
|
||||
"$FZF_INSTALLER" --key-bindings --no-completion --no-update-rc --no-bash --no-zsh
|
||||
end
|
@ -7,7 +7,7 @@ VIM_PLUG_SRC="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vi
|
||||
VIM_PLUG_DST="$HOME/.local/share/nvim/site/autoload/plug.vim"
|
||||
if [ ! -f "$VIM_PLUG_DST" ]; then
|
||||
echo "Downloading plug.vim ..."
|
||||
curl -fLo "$VIM_PLUG_DST" --create-dirs "$VIM_PLUG_SRC"
|
||||
curl -fsSL -o "$VIM_PLUG_DST" --create-dirs "$VIM_PLUG_SRC"
|
||||
fi
|
||||
|
||||
# Add Homebrew-managed shells to system list
|
||||
@ -18,5 +18,8 @@ grep -q "$BREW_PREFIX/bin/fish" /etc/shells || echo "$BREW_PREFIX/bin/fish" | su
|
||||
# Make fish the default shell
|
||||
sudo chsh -s "$BREW_PREFIX/bin/fish" `whoami`
|
||||
|
||||
# Install fzf keybindings
|
||||
"$DOTFILES/install-fzf.sh"
|
||||
|
||||
# Install symlinks
|
||||
"$DOTFILES/install-symlinks.sh"
|
||||
|
Loading…
x
Reference in New Issue
Block a user