fish: functions: Move HieDb helpers to functions

Using abbreviations for shell commands does not seem clean. They also
seem out of place along with other cabal abbreviations.

While at it, we also add a helper to nuke all Haskell build artefacts.
This is convenient instead of running cabal clean in every project or
relying on Kondo.

For deleting directories, we replace -delete with -exec rm -rv {} + or
-exec rm -rv {} \ which should delete directories recursively without
error. + at the end will result in rm -rv file1 file2 ... while using
\ will result in rm -rv file1; rm -rv file2; ...
This commit is contained in:
Sanchayan Maity 2024-11-30 11:06:29 +05:30
parent 386cc0c75b
commit aab3d5bee3
Signed by: sanchayanmaity
GPG key ID: 6F6A0609C12038F3
4 changed files with 9 additions and 2 deletions

View file

@ -37,5 +37,3 @@ abbr cpD 'cabal-plan dot'
abbr cpdp 'cabal-plan dot-png'
abbr cpt 'cabal-plan topo'
abbr cplr 'cabal-plan license-reportate'
abbr chi 'hiedb -D .hiedb index .hiefiles --src-base-dir .'
abbr chic 'find . -name .hiefiles | awk \'{print $1" "substr($1, 1, length($1) - length(".hiefiles"))}\' | xargs -n2 sh -c \'hiedb -D .hiedb index $0 --src-base-dir=$1 --skip-types\''

View file

@ -0,0 +1,3 @@
function hclean --description "Clean all Haskell build artefacts"
find . -name .hiedb -type f -delete && find . -name .hiefiles -type d -exec rm -rf {} + && find . -name dist-newstyle -type d -exec rm -rf {} + && find . -name tags -type f -delete && find . -name ".ghc.environment*" -type f -delete
end

View file

@ -0,0 +1,3 @@
function hieg --description "Generate HieDb"
hiedb -D .hiedb index .hiefiles --src-base-dir .
end

View file

@ -0,0 +1,3 @@
function hier --description "Generate HieDb for multi-project workspace"
find . -name .hiefiles | awk '{print $1" "substr($1, 1, length($1) - length(".hiefiles"))}' | xargs -n2 sh -c 'hiedb -D .hiedb index $0 --src-base-dir=$1 --skip-types'
end