Remove fish config

master
Pierre Neidhardt 2017-07-08 23:16:18 +01:00
parent 8e3a5e52a7
commit 36ee5cd5b2
12 changed files with 1 additions and 379 deletions

View File

@ -1,56 +0,0 @@
## fish working paths
set -q XDG_DATA_HOME; or set -l XDG_DATA_HOME $HOME/.local/share
set -q XDG_CONFIG_HOME; or set -l XDG_CONFIG_HOME $HOME/.config
set -q fish_data_path; or set -g fish_data_path $XDG_DATA_HOME/fish
set -q fish_config_path; or set -g fish_config_path $XDG_CONFIG_HOME/fish
## cdhist options
set -g fish_cdhist_path $fish_data_path/fish_cdhist
set -g fish_cdhist_max 128
## Go back to last cdhist folder. Run this before the SHELL_FILEBROWSER hook.
if grep -q . $fish_cdhist_path ^ /dev/null
set dirprev (cat $fish_cdhist_path)
set -q dirprev[$fish_cdhist_max]; and set dirprev $dirprev[(math - $fish_cdhist_max)..-1]
cd $dirprev[(count $dirprev)] ^ /dev/null
end
## Start at a specific location. Useful when switching to a shell from a browser
## for instance.
[ -n "$SHELL_CD" ]; and cd $SHELL_CD; and set -u SHELL_CD
## Misc
set fish_greeting
## Colors
## For custom prompt.
set fish_color_user brcyan
set fish_color_hostname brcyan
## Aliases
function ls --description 'List contents of directory'
set -l param --color=auto
if isatty 1
set param $param --indicator-style=classify
end
if [ (uname -o) = "GNU/Linux" ]
set param $param --group-directories-first
end
command ls $param $argv
end
alias l 'ls -1'
alias la 'll -lAh'
alias mkdir 'mkdir -p'
function mkcd -a folder -d 'Make directory and change into it.'
mkdir -p $folder
cd $folder
end
alias cal 'cal -m'
alias cp 'cp -i'
alias mv 'mv -i'
if type -pq pacman
source $fish_config_path/pacman.fish
end

View File

@ -1,36 +0,0 @@
# Wrap the builtin cd command to maintain a permanent directory history.
function cd --description "Change directory"
if test (count $argv) -gt 1
printf "%s\n" (_ "Too many args for cd command")
return 1
end
# Skip history in subshells.
if status --is-command-substitution
builtin cd $argv
return $status
end
if test "$argv" = "-"
set argv $dirprev[(math (count $dirprev) - 1)]
end
builtin cd $argv
set -l cd_status $status
if test $cd_status -eq 0
if set -q dirprev
## Remove duplicates.
set -g dirprev (string match -v $PWD $dirprev) $PWD
## Keep last '$fish_cdhist_max' elements only.
set -q dirprev[$fish_cdhist_max]; and set dirprev $dirprev[(math - $fish_cdhist_max)..-1]
## Save history.
string join \n $dirprev > $fish_cdhist_path
else
set -g dirprev $PWD
end
set -e dirnext
end
return $cd_status
end

View File

@ -1,21 +0,0 @@
function describe -d 'Extended "type"'
for i in $argv
set typ (type -t $i ^ /dev/null)
if test $status -ne 0
set -l path $i
ls -l $path
file $path | cut -d':' -f2 | cut -b 2-
type -pq pacman; and pacman -Qo $path ^ /dev/null
continue
end
switch $typ
case file
set -l path (type -p $i)
ls -l $path
file $path | cut -d':' -f2 | cut -b 2-
type -pq pacman; and pacman -Qo $path ^ /dev/null
case '*'
type $i
end
end
end

View File

@ -1,7 +0,0 @@
function fish_primary_copy
if type -q pbcopy
commandline | pbcopy
else if type -q xsel
commandline | xsel
end
end

View File

@ -1,29 +0,0 @@
function fish_primary_paste
set -l data
if type -q pbpaste
set data (pbpaste)
else if type -q xsel
# Return if `xsel` failed.
# That way any xsel error is printed (to show e.g. a non-functioning X connection),
# but we don't print the redundant (and overly verbose for this) commandline error.
# Also require non-empty contents to not clear the buffer.
if not set data (xsel)
return 1
end
end
# Also split on \r to turn it into a newline,
# otherwise the output looks really confusing.
set data (string split \r -- $data)
# If the current token has an unmatched single-quote,
# escape all single-quotes (and backslashes) in the paste,
# in order to turn it into a single literal token.
#
# This eases pasting non-code (e.g. markdown or git commitishes).
if __fish_commandline_is_singlequoted
set data (string replace -ra "(['\\\])" '\\\\\\\$1' -- $data)
end
if test -n "$data"
commandline -i -- $data
end
end

View File

@ -1,27 +0,0 @@
function fish_prompt
set HOST (hostname)
printf "%s%s%s%s%s" (set_color -o)'(' \
(set_color normal) \
(set_color $fish_color_user)$USER \
(set_color normal) \
(set_color -o)@ \
(set_color normal) \
(set_color $fish_color_hostname)$HOST \
(set_color normal) \
(set_color -o)')'
## Path
set -l cwd_color $fish_color_cwd
if test (id -u) -eq 0
set cwd_color $fish_color_cwd_root
end
set PROMPT_PWD (prompt_pwd)
printf "%s%s%s%s" \
(set_color -o)'[' \
(set_color -o $cwd_color)$PROMPT_PWD \
(set_color normal) \
(set_color -o)']'
echo
echo '> '
end

View File

@ -1,21 +0,0 @@
function fish_user_key_bindings
fish_vi_key_bindings
set fish_escape_delay_ms 10
## Useful for rsync when folders are completed with fzf.
bind \cw trim_trailing_slashes
bind \e\x7f backward-kill-word
bind -M insert \e\x7f backward-kill-word
bind -M insert \ce edit_command_buffer
bind -m insert \ce edit_command_buffer
bind \cv fish_primary_paste
bind \cx fish_primary_copy
## fzf
if type -pq fzf
source $fish_config_path/fzf.fish
end
end

View File

@ -1,35 +0,0 @@
function man --description 'Color and justify the on-line manual pages'
## Work around the "builtin" manpage that everything symlinks to,
## by prepending our fish datadir to man. This also ensures that man gives fish's
## man pages priority, without having to put fish's bin directories first in $PATH
# Justify man pager to current window size.
set -q MANWIDTH; and [ $COLUMNS -lt $MANWIDTH ]; and set -lx MANWIDTH $COLUMNS
## Color when using LESS.
## mb = ?
## md = bold (titles, commands)
## so = status bar
## us = italic (arguments, files)
set -lx LESS_TERMCAP_mb (printf "\e[1;31m")
set -lx LESS_TERMCAP_md (printf "\e[0;36m")
set -lx LESS_TERMCAP_me (printf "\e[0m")
set -lx LESS_TERMCAP_se (printf "\e[0m")
set -lx LESS_TERMCAP_so (printf "\e[1;4;37m")
set -lx LESS_TERMCAP_ue (printf "\e[0m")
set -lx LESS_TERMCAP_us (printf "\e[0;33m")
# Notice local but exported variable
set -lx MANPATH (string join : $MANPATH)
if test -z "$MANPATH"
type -q manpath
and set MANPATH (command manpath)
end
set -l fish_manpath (dirname $__fish_datadir)/fish/man
if test -d "$fish_manpath" -a -n "$MANPATH"
set MANPATH "$fish_manpath":$MANPATH
end
# If fish's man pages could not be found, just invoke man normally
command man $argv
end

View File

@ -1,17 +0,0 @@
# This is useful for rsync when folders have slashes automatically appended to
# them (e.g. with fzf completion).
function trim_trailing_slashes --description "Trim trailing slashes of all commandline tokens"
set -l list (commandline -o)
commandline -r ""
for i in $list
set i (string replace -r '/$' '' $i)
set -l prefix (string sub -s 1 -l 1 -- $i)
switch $prefix
case '~'
commandline -t -- (string sub -s 2 (string escape -n -- $i))
case '*'
commandline -t -- (string escape -- $i)
end
commandline -i -- ' '
end
end

View File

@ -1,110 +0,0 @@
fzf_key_bindings
## Emacs bindings
# bind \cT transpose-chars
# bind \e\ct fzf-file-widget
## Emacs binding that is also useful in vi.
bind -M insert \ec capitalize-word
bind -m insert \ec fzf-cd-widget
# bind -M insert \et fzf-file-widget
# Add to normal mode too.
bind \cT fzf-file-widget
# bind R fzf-history-widget
# bind -m insert C fzf-cd-widget
function fzf-select -d 'Eval commandline, fzf result and print out selection'
set -l cmd (commandline -j)
[ "$cmd" ]; or return
eval $cmd | fzf -m --select-1 --exit-0 | string join ' ' | read -l result
[ "$result" ]; and commandline -j -- $result
commandline -f repaint
end
bind \e\cm fzf-select
bind m fzf-select
## TODO: 'complete' is not completely finished, keep original version for now.
## We need a way to distinguish escape content from unescaped content:
## - https://github.com/fish-shell/fish-shell/issues/1127
## - https://github.com/fish-shell/fish-shell/issues/3469
## Examples:
## - $VAR
## - ~/
## - echo \$HOME-$H<tab>
function fzf-complete -d 'fzf completion and print selection back to commandline'
# As of 2.6, fish's "complete" function does not understand
# subcommands. Instead, we use the same hack as __fish_complete_subcommand and
# extract the subcommand manually.
set -l cmd (commandline -co) (commandline -ct)
switch $cmd[1]
case env sudo
for i in (seq 2 (count $cmd))
switch $cmd[$i]
case '-*'
case '*=*'
case '*'
set cmd $cmd[$i..-1]
break
end
end
end
set cmd (string join -- ' ' $cmd)
set -l complist (complete -C$cmd)
set -l result
string join -- \n $complist | sort | fzf -m --select-1 --exit-0 --header '(commandline)' | cut -f1 | while read -l r; set result $result $r; end
set prefix (string sub -s 1 -l 1 -- (commandline -t))
for i in (seq (count $result))
set -l r $result[$i]
switch $prefix
case "'"
commandline -t -- (string escape -- $r)
case '"'
if string match '*"*' -- $r >/dev/null
commandline -t -- (string escape -- $r)
else
commandline -t -- '"'$r'"'
end
case '~'
commandline -t -- (string sub -s 2 (string escape -n -- $r))
case '*'
commandline -t -- (string escape -n -- $r)
end
[ $i -lt (count $result) ]; and commandline -i ' '
end
commandline -f repaint
end
bind \t fzf-complete
bind \e\t complete
bind -M insert \t fzf-complete
bind -M insert \e\t complete
function fzf-bcd-widget -d 'cd backwards'
set -lx FZF_DEFAULT_OPTS "$FZF_DEFAULT_OPTS $FZF_BCD_OPTS"
pwd | awk -v RS=/ '/\n/ {exit} {p=p $0 "/"; print p}' | tac | fzf +m --select-1 --exit-0 | read -l result
[ "$result" ]; and cd $result
commandline -f repaint
end
# bind \e\cL fzf-bcd-widget
bind -m insert / fzf-bcd-widget
function fzf-cdhist-widget -d 'cd to one of the previously visited locations'
## Clear non-existent folders from cdhist.
set -l buf
for i in (seq 1 (count $dirprev))
set -l dir $dirprev[$i]
if test -d $dir
set buf $buf $dir
end
end
set dirprev $buf
set -lx FZF_DEFAULT_OPTS "$FZF_DEFAULT_OPTS $FZF_CDHIST_OPTS"
string join \n $dirprev | tac | sed 1d | eval (__fzfcmd) +m --tiebreak=index --toggle-sort=ctrl-r | read -l result
[ "$result" ]; and cd $result
commandline -f repaint
end
# bind \er fzf-cdhist-widget
bind -m insert z fzf-cdhist-widget

View File

@ -1,12 +0,0 @@
set -l listinstalled "(pacman -Q | string replace ' ' \t)"
set -l listall "(__fish_print_packages)"
complete -c pacfiles -a "$listinstalled"
function pacls -d 'List/open package files with fzf'
set -l result
set -lx OPT $FZF_CTRL_T_OPTS
pacman -Qlq $argv | grep -v '/$' | eval (__fzfcmd) -m --tiebreak=index --toggle-sort=ctrl-r $OPT | string join ' ' | read -l result
[ "$result" ]; and commandline -- $result
end
complete -c pacls -a "$listinstalled"

View File

@ -230,14 +230,7 @@ e-mail."
;;; Arch Linux PKGBUILD
(add-to-list 'auto-mode-alist '("PKGBUILD" . sh-mode))
;;; rc
(add-to-list 'auto-mode-alist '("rc\\'" . sh-mode))
;;; Fish
(nconc package-selected-packages '(fish-mode))
(defun fish-check-buffer ()
(when (string-match "/tmp/tmp\..*\.fish" (buffer-file-name))
(when (require 'with-editor nil t) (with-editor-mode))
(end-of-line)))
(add-hook 'find-file-hook 'fish-check-buffer)
(nconc package-selected-packages '(rc-mode))
;;; Srt (subtitles)
(add-to-list 'auto-mode-alist '("\\.srt\\'" . text-mode))