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

197 lines
4.8 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"
cabbr p emerge
cabbr p pacman
cabbr p pikaur
cabbr p yay
cabbr p paru
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
2021-02-13 15:22:05 +01:00
cabbr rv sudo {{@@ editor @@}}
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-02-13 15:22:05 +01:00
calias ls 'exa --git'
2021-05-21 06:24:23 +02:00
calias tree 'exa --git --tree --icons'
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
################################################################
command -qs khard &&
function fish_greeting
command -qs khal
2020-11-28 18:25:23 +01:00
or return
set -l khalList (khal --color list now 10d --format " {title}")
test -n "$khalList"
or return
echo $khalList | strip-escape | string match -qr '^No events$'
2020-11-28 18:25:23 +01:00
and return
printf "%s\n" $khalList
2020-11-28 18:25:23 +01:00
end
################################################################
# 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'
################################################################
# work stuff
################################################################
2021-06-18 06:13:46 +02:00
abbr svu sv up apache mariadb
abbr svd sv down apache mariadb
abbr svs sv status apache mariadb
2021-06-06 21:59:40 +02:00
abbr msv "\
set db (basename (pwd | sd -- - _))
set margs -v -u root --password=(_pass_get work_db)"
abbr msc 'echo "CREATE DATABASE $db" | mysql $margs'
abbr msl 'mysql $margs $db < dump/$db.sql'
abbr msd 'mariadb-dump $margs $db | mysql_format > dump/$db.sql'
abbr vw 'kak public/**.less resources/**.blade.php (fd -E \'*.min.js\' \'.js$\' public/)'
abbr gdw 'git diff -- "*.less" "*.js" "*.blade.php"'
2021-06-06 21:59:40 +02:00
abbr pl 'php7 artisan serve --host 0.0.0.0 & make watch'
function mysql_format
sd "\),\(" "),\n\t(" | sd "VALUES \(" "VALUES\n\t("
end
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
xdg-open $argv &> /dev/null & disown
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-03-05 03:36:16 +01:00
set -l dotfile (fd -HE .git | wdmenu)
2021-02-13 18:24:20 +01:00
test -n "$dotfile" || return 1
2021-02-13 15:22:05 +01:00
{{@@ 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