152 lines
4.2 KiB
Fish
Executable File
152 lines
4.2 KiB
Fish
Executable File
## Set values
|
|
# Hide welcome message & ensure we are reporting fish as shell
|
|
set fish_greeting
|
|
set VIRTUAL_ENV_DISABLE_PROMPT "1"
|
|
set -xU MANPAGER "sh -c 'col -bx | bat -l man -p'"
|
|
set -xU MANROFFOPT "-c"
|
|
set -xU EDITOR /usr/bin/nvim
|
|
set -x SHELL /usr/bin/fish
|
|
|
|
## Export variable need for qt-theme
|
|
if type "qtile" >> /dev/null 2>&1
|
|
set -x QT_QPA_PLATFORMTHEME "qt5ct"
|
|
end
|
|
|
|
# Set settings for https://github.com/franciscolourenco/done
|
|
set -U __done_min_cmd_duration 10000
|
|
set -U __done_notification_urgency_level low
|
|
|
|
|
|
## Environment setup
|
|
# Apply .profile: use this to put fish compatible .profile stuff in
|
|
if test -f ~/.fish_profile
|
|
source ~/.fish_profile
|
|
end
|
|
|
|
# Add ~/.local/bin to PATH
|
|
if test -d ~/.local/bin
|
|
if not contains -- ~/.local/bin $PATH
|
|
set -p PATH ~/.local/bin
|
|
end
|
|
end
|
|
|
|
## Starship prompt
|
|
if status --is-interactive
|
|
set -l starship_path (which starship)
|
|
source ("$starship_path" init fish --print-full-init | psub)
|
|
end
|
|
|
|
## Advanced command-not-found hook
|
|
#source /usr/share/doc/find-the-command/ftc.fish
|
|
|
|
set -l xdg_data_home $XDG_DATA_HOME ~/.local/share
|
|
set -gx --path XDG_DATA_DIRS $xdg_data_home[1]/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share
|
|
|
|
for flatpakdir in ~/.local/share/flatpak/exports/bin /var/lib/flatpak/exports/bin
|
|
if test -d $flatpakdir
|
|
contains $flatpakdir $PATH; or set -a PATH $flatpakdir
|
|
end
|
|
end
|
|
|
|
## Functions
|
|
# Functions needed for !! and !$ https://github.com/oh-my-fish/plugin-bang-bang
|
|
function __history_previous_command
|
|
switch (commandline -t)
|
|
case "!"
|
|
commandline -t $history[1]; commandline -f repaint
|
|
case "*"
|
|
commandline -i !
|
|
end
|
|
end
|
|
|
|
function __history_previous_command_arguments
|
|
switch (commandline -t)
|
|
case "!"
|
|
commandline -t ""
|
|
commandline -f history-token-search-backward
|
|
case "*"
|
|
commandline -i '$'
|
|
end
|
|
end
|
|
|
|
if [ "$fish_key_bindings" = fish_vi_key_bindings ];
|
|
bind -Minsert ! __history_previous_command
|
|
bind -Minsert '$' __history_previous_command_arguments
|
|
else
|
|
bind ! __history_previous_command
|
|
bind '$' __history_previous_command_arguments
|
|
end
|
|
|
|
# Fish command history
|
|
function history
|
|
builtin history --show-time='%F %T '
|
|
end
|
|
|
|
function backup --argument filename
|
|
cp $filename $filename.bak
|
|
end
|
|
|
|
# Copy DIR1 DIR2
|
|
function copy
|
|
set count (count $argv | tr -d \n)
|
|
if test "$count" = 2; and test -d "$argv[1]"
|
|
set from (echo $argv[1] | string trim --right --chars=/)
|
|
set to (echo $argv[2])
|
|
command cp -r $from $to
|
|
else
|
|
command cp $argv
|
|
end
|
|
end
|
|
|
|
function fish_greeting
|
|
# echo -e "\n"
|
|
# fastfetch
|
|
end
|
|
|
|
## Useful aliases
|
|
|
|
# Replace ls with eza
|
|
alias ls 'eza --color=always --group-directories-first --icons' # preferred listing
|
|
alias la 'eza -a --color=always --group-directories-first --icons' # all files and dirs
|
|
alias ll 'eza -l --color=always --group-directories-first --icons' # long format
|
|
alias lt 'eza -aT --color=always --group-directories-first --icons' # tree listing
|
|
alias l. 'eza -ald --color=always --group-directories-first --icons .*' # show only dotfiles
|
|
|
|
# Replace some more things with better alternatives
|
|
alias cat 'bat --style header --style snip --style changes --style header'
|
|
|
|
# Replace df command tool
|
|
alias df='duf'
|
|
|
|
# Common use
|
|
alias .. 'cd ..'
|
|
alias ... 'cd ../..'
|
|
alias .... 'cd ../../..'
|
|
alias ..... 'cd ../../../..'
|
|
alias ...... 'cd ../../../../..'
|
|
alias dir 'dir --color=auto'
|
|
alias grep 'ugrep --color=auto'
|
|
alias egrep 'ugrep -E --color=auto'
|
|
alias fgrep 'ugrep -F --color=auto'
|
|
alias grubup 'sudo update-grub'
|
|
alias hw 'hwinfo --short' # Hardware Info
|
|
alias ip 'ip -color'
|
|
alias psmem 'ps auxf | sort -nr -k 4'
|
|
alias psmem10 'ps auxf | sort -nr -k 4 | head -10'
|
|
alias tarnow 'tar -acf '
|
|
alias untar 'tar -zxvf '
|
|
alias vdir 'vdir --color=auto'
|
|
alias wget 'wget -c '
|
|
alias rost 'rpm-ostree'
|
|
alias vi 'nvim'
|
|
|
|
# Get the error messages from journalctl
|
|
alias jctl 'journalctl -p 3 -xb'
|
|
|
|
# Aliases run commands inner Archlinux Toolbox container
|
|
alias exercism 'toolbox run -c arch-toolbox-latest exercism'
|
|
alias k9s 'toolbox run -c arch-toolbox-latest k9s'
|
|
alias kubectl 'toolbox run -c arch-toolbox-latest kubectl'
|
|
alias lazydocker 'toolbox run -c arch-toolbox-latest lazydocker'
|
|
alias lazygit 'toolbox run -c arch-toolbox-latest lazygit'
|