This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/dotfiles/fish/alias.fish

186 lines
4.2 KiB
Fish
Raw Normal View History

2020-11-28 18:25:23 +01:00
# {{@@ header() @@}}
# __ _ _
# / _(_)___| |__
# | |_| / __| '_ \
# | _| \__ \ | | |
# |_| |_|___/_| |_|
2021-02-13 15:22:05 +01:00
function cabbr
command -qs ( echo $argv[2] | cut -d' ' -f1 )
and abbr -g $argv; end
function calias
command -qs ( echo $argv[2] | cut -d' ' -f1 )
and alias $argv; end
abbr -g mpn ncmpcpp
abbr -g dot "dotdrop install -f"
2021-06-23 07:59:30 +02:00
set -l root_cfg (dirname $DOTDROP_CONFIG)/root
2021-06-23 16:59:23 +02:00
alias rootdrop 'sudo dotdrop install -f -c "$root_cfg"'
2021-06-23 07:59:30 +02:00
2021-02-13 15:22:05 +01:00
cabbr p emerge
2022-02-01 02:20:49 +01:00
if command -qs xbps-install
cabbr p sudo xbps-install -y
end
2021-02-13 15:22:05 +01:00
cabbr p pacman
cabbr p pikaur
cabbr p yay
cabbr p paru
2020-11-28 18:25:23 +01:00
2022-02-01 02:20:49 +01:00
2020-11-28 18:25:23 +01:00
################################################################
# Editor
################################################################
2021-02-13 15:22:05 +01:00
cabbr v {{@@ editor @@}}
2020-11-28 18:25:23 +01:00
2022-02-08 05:00:07 +01:00
cabbr rv sudoedit
2021-02-13 15:22:05 +01:00
cabbr rv doas {{@@ editor @@}}
2020-11-28 18:25:23 +01:00
################################################################
# Safe guard for rm
################################################################
2021-02-13 15:22:05 +01:00
calias rm trash
abbr -g crm command rm -i
2020-11-28 18:25:23 +01:00
################################################################
# ls and cat
################################################################
2021-09-07 01:56:23 +02:00
calias ls 'exa --git --sort newest'
2021-10-28 20:01:53 +02:00
calias tree 'exa --git --tree --icons --git-ignore'
2021-04-21 08:13:01 +02:00
calias cat 'bat -p'
calias cp 'cp --reflink=auto'
2021-02-22 00:48:51 +01:00
calias ip 'ip --color=auto'
2020-11-28 18:25:23 +01:00
################################################################
2021-02-13 15:22:05 +01:00
# Chang Directory
2020-11-28 18:25:23 +01:00
################################################################
2021-02-13 15:22:05 +01:00
# The ever usefull "z" command
2020-11-28 18:25:23 +01:00
command -qs zoxide &&
zoxide init fish | source
2021-02-13 15:22:05 +01:00
for i in (seq 3 10)
set -l dots (string repeat -n $i .)
set -l segs (string repeat -n $i ./.)
alias $dots "cd $segs"
end
2020-11-28 18:25:23 +01:00
################################################################
# Show reminders on startup
################################################################
2021-10-23 04:53:55 +02:00
function fish_greeting
command -qs khal
or return
set -l khalList (khal --color list now 5d)
test -n "$khalList"
or return
echo $khalList | strip-escape | string match -qr '^No events$'
and return
printf "%s\n" $khalList
end
2020-11-28 18:25:23 +01:00
2021-10-23 04:53:55 +02:00
function fish_greeting
end
2020-11-28 18:25:23 +01:00
################################################################
# Git
################################################################
2021-06-06 21:59:40 +02:00
abbr -g g 'git'
abbr -g ga 'git add'
abbr -g gs 'git status'
abbr -g gsh 'git show'
abbr -g gl 'git log'
abbr -g gg 'git graph'
abbr -g gd 'git diff'
abbr -g gds 'git diff --staged'
abbr -g gc 'git commit'
abbr -g gca 'git commit --all'
abbr -g gcf 'git commit --fixup'
abbr -g gr 'cd (git root)'
abbr -g gri 'git rebase --interactive FETCH_HEAD'
2020-11-28 18:25:23 +01:00
################################################################
2021-02-13 15:22:05 +01:00
# open
2020-11-28 18:25:23 +01:00
################################################################
2021-02-13 15:22:05 +01:00
function open -w xdg-open
2021-12-08 00:50:27 +01:00
for i in $argv
xdg-open $i &> /dev/null & disown
end
2020-11-28 18:25:23 +01:00
end
2021-03-31 22:57:47 +02:00
2021-06-03 01:36:53 +02:00
################################################################
# Copy files like graphical programs
################################################################
function wl-copy-f -w wl-copy
set -a file
for arg in (seq 1 (count $argv))
if test -f "$argv[$arg]"
set -a file (realpath $argv[$arg])
set -e argv[$arg]
end
end
if test -n "$file"
wl-copy $argv -t text/uri-list "file:///$file"
else
wl-copy $argv
end
end
abbr -g wcf 'wl-copy-f'
2021-03-31 22:57:47 +02:00
################################################################
# man
################################################################
2021-06-18 00:13:11 +02:00
functions -q _man
or functions -c man _man
2021-03-31 22:57:47 +02:00
function man -w man
2021-04-17 08:10:45 +02:00
test "$COLUMNS" -lt 80
and set -x MANWIDTH "$COLUMNS"
or set -x MANWIDTH 80
2021-06-18 00:13:11 +02:00
_man $argv
2021-03-31 22:57:47 +02:00
end
2021-06-18 06:13:46 +02:00
################################################################
# sv
################################################################
function sv -w sv
set -l o (command sv $argv 2> /dev/null )
and printf "%s\n" $o
or sudo sv $argv
end
2020-11-28 18:25:23 +01:00
################################################################
# quickly edit dotfiles
################################################################
function edit-config
2021-06-18 06:13:46 +02:00
pushd (dirname "$DOTDROP_CONFIG")
2021-12-08 00:50:27 +01:00
set -l dotfile (fd --strip-cwd-prefix -HE .git | wdmenu)
2021-02-13 18:24:20 +01:00
test -n "$dotfile" || return 1
{{@@ editor @@}} "$dotfile"
2020-11-28 18:25:23 +01:00
popd
end
2021-02-13 15:22:05 +01:00
abbr -g ec edit-config