Jochen Sprickerhof

Last changed: 2017-11-02

Fish Config

set -x EDITOR nvim
set -x BROWSER surf
set -x LESS -iRw
set -x LC_MESSAGES C.UTF-8
set -x MAKEFLAGS -j(nproc)
set -x GPG_TTY (tty)
set -x DEB_BUILD_OPTIONS parallel=(nproc)
#set -x CFLAGS "-Wall -Wextra -Wpedantic -Wabi -Wconversion -pipe -fdiagnostics-color=auto -O3 -march=native"
set -x CFLAGS "-Wall -Wextra -Wpedantic -Wabi -Wconversion -pipe -fdiagnostics-color=auto -O3"
set -x CXXFLAGS "$CFLAGS -Weffc++ -Wold-style-cast"
set -x LDFLAGS "-Wl,--as-needed -s"
set -x WINEDLLOVERRIDES winemenubuilder.exe=d
set -x JAVA_AWT_WM_NONREPARENTING 1
test -d $HOME/.local/bin; and set -x PATH ~/.local/bin $PATH
test -d /usr/lib/ccache; and set -x PATH /usr/lib/ccache $PATH
test -d $HOME/.local/lib; and set -x LD_LIBRARY_PATH "$HOME/.local/lib:$LD_LIBRARY_PATH"
test -d $HOME/.local/lib; and set -x LIBRARY_PATH "$HOME/.local/lib:$LIBRARY_PATH"
test -d $HOME/.local/include; and set -x CPATH "$HOE/.local/include:$CPATH"
test -d $HOME/.local/lib/pkgconfig; and set -x PKG_CONFIG_PATH "$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH"
test -d $HOME/.local/man; and set -x MANPATH "$HOME/.local/man:$MANPATH"
test -d $HOME/.local; and set -x CMAKE_PREFIX_PATH "$HOME/.local:$CMAKE_PREFIX_PATH"
test -d $HOME/.local/share/texmf; and set -x TEXMFHOME "$HOME/.local/share/texmf"

if not status --is-interactive
  exit
end

mesg n
set fish_greeting
set -q SSH_CONNECTION; and set __fish_prompt_hostname (set_color brblue)(prompt_hostname)' '
set __fish_prompt_normal (set_color -b normal)
set __fish_prompt_jobs (set_color -b green)
set __fish_prompt_status (set_color -b red)
set __fish_prompt_envdirs (set_color cyan)

function fish_prompt
    set -l last_status $status
    set -l jobs (jobs | wc -l)
    test $last_status -ne 0; and echo -n -s "$__fish_prompt_status" "$last_status" "$__fish_prompt_normal" ' '
    test $jobs -ne 0; and echo -n -s "$__fish_prompt_jobs" "$jobs" "$__fish_prompt_normal" ' '
    test -n "$envdirs"; and echo -n -s "$__fish_prompt_envdirs" "$envdirs" ' '
    echo -n -s "$__fish_prompt_user" "$__fish_prompt_hostname" "$__fish_prompt_normal" (prompt_pwd) '> '
end

function postexec_bell --on-event fish_postexec
    echo -n -e "\a"
end

function __fish_commandline_insert_escaped --description 'Insert the first arg escaped if a second arg is given'
    if set -q argv[2]
        commandline -i \\$argv[1]
    else
        commandline -i $argv[1]
    end
end

function __fish_start_bracketed_paste
    # Save the last bind mode so we can restore it.
    set -g __fish_last_bind_mode $fish_bind_mode
    # If the token is currently single-quoted,
    # we escape single-quotes (and backslashes).
    __fish_commandline_is_singlequoted
    and set -g __fish_paste_quoted 1
end

function __fish_stop_bracketed_paste
    # Restore the last bind mode.
    set fish_bind_mode $__fish_last_bind_mode
    set -e __fish_paste_quoted
    commandline -f force-repaint
end

function fish_xclip_paste
    set -l data
    if not set data (xclip -o)
    return 1
    end
    set data (string split \r -- $data)

    if __fish_commandline_is_singlequoted
        set data (string replace -ra "(['\\\])" '\\\\\\\$1' -- $data)
    end
    if test -n "$data"
        commandline -i -- $data
    end
end

function fish_default_key_bindings
    bind --erase --all
    bind "" self-insert
    bind \r execute
    bind \n execute
    bind \ck kill-line
    bind \cy yank
    bind \t complete
    bind \e\r "commandline -i \n"

    bind \e\[A up-or-search
    bind \e\[B down-or-search
    bind \ej up-or-search
    bind \ek down-or-search
    bind \e\[C forward-char
    bind \e\[D backward-char
    bind \el forward-char
    bind \eh backward-char

    bind -k backspace backward-delete-char

    bind \en nextd-or-forward-word
    bind \ep prevd-or-backward-word
    bind \e. history-token-search-backward
    bind \e, history-token-search-forward

    bind \ca beginning-of-line
    bind \ce end-of-line
    bind \ey yank-pop
    bind \ch backward-delete-char
    bind \cw backward-kill-word
    bind \cp history-search-backward
    bind \cn history-search-forward
    bind \cf forward-char
    bind \cb backward-char
    bind \ct transpose-chars
    bind \et transpose-words
    bind \ec capitalize-word
    bind \eb backward-word
    bind \ef forward-word
    bind \e\< beginning-of-buffer
    bind \e\> end-of-buffer

    bind \eL __fish_list_current_token
    bind \ew 'set tok (commandline -pt); if test $tok[1]; echo; whatis $tok[1]; commandline -f repaint; end'
    bind \cl 'clear; commandline -f repaint'
    bind \cc __fish_cancel_commandline
    bind \cu backward-kill-line
    bind \cd delete-or-exit
    bind \ed kill-word
    bind \eP '__fish_paginate'
    bind \e cancel
    bind -k btab complete-and-search
    bind \e\# __fish_toggle_comment_commandline
    bind \ee edit_command_buffer

    bind \cx 'commandline | xclip -i'
    bind \cv fish_xclip_paste

    bind -M default -m paste \e\[200~ '__fish_start_bracketed_paste'
    bind -M paste \e\[201~ '__fish_stop_bracketed_paste'
    bind -M paste "" self-insert
    bind -M paste \r "commandline -i \n"
    bind -M paste "'" "__fish_commandline_insert_escaped \' \$__fish_paste_quoted"
    bind -M paste \\ "__fish_commandline_insert_escaped \\\ \$__fish_paste_quoted"

    #bind \ed 'set -l cmd (commandline); if test -z "$cmd"; echo; dirh; commandline -f repaint; else; commandline -f kill-word; end'
    bind \eh __fish_man_page
end

function pkg-config
    /usr/bin/pkg-config $argv | tr -s ' ' '\n'
end

#eval (env TERM=rxvt dircolors -b)
#eval (lesspipe)

alias vi 'nvim'
alias l 'ls'
alias ll 'ls -lh'
alias a 'l -A'
alias la 'll -A'
alias psl 'ps auxf | less'
alias psg 'ps aux | grep'
alias hist 'history | less'
alias hig 'history --search'
alias df 'df -h -x fuse.sshfs'
alias free 'free -m'
alias rsync 'rsync -ahP'
alias serv 'python3 -m http.server'
alias ssh_insec 'ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
alias scp_insec 'scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
alias pling 'echo -ne \a'
alias studip 'rename s/^\[[0-9]+\]_// *'
alias emacs 'emacs -nw'
alias wodim 'wodim -v'
alias x 'atool -qx'
alias cmake 'cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/.local -DCMAKE_EXPORT_COMPILE_COMMANDS=ON'
alias cmaked 'cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=~/.local -DCMAKE_EXPORT_COMPILE_COMMANDS=ON'
alias dquilt 'quilt --quiltrc=$HOME/.quiltrc-dpkg'
alias cclive 'cclive -s best'
alias dmesg 'dmesg -H'
alias grep 'grep --color=auto'
alias p 'ipython3 --no-banner --colors=Linux --TerminalInteractiveShell.true_color=True'
alias rviz 'rviz -s ""'
alias soffice 'soffice --nologo'
alias qr 'qrencode -t ansi'

if test "$USER" = root
    umask 0022
    set __fish_prompt_user (set_color red)$USER' '
    set -x XAUTHORITY ~jspricke/.Xauthority
    alias plingr 'echo -e "\a" > /dev/tty0'
end

Alternatives