mirror of
https://github.com/kogakure/dotfiles.git
synced 2026-02-03 20:25:30 +00:00
feat(fish): convert a few functions
This commit is contained in:
7
fish/functions/dataUrl.fish
Normal file
7
fish/functions/dataUrl.fish
Normal file
@@ -0,0 +1,7 @@
|
||||
function dataUrl --description "Create a data URL from a file"
|
||||
set mimeType (file -b --mime-type $argv)
|
||||
if string match -r '^text/' $mimeType
|
||||
set mimeType "$mimeType;charset=utf-8"
|
||||
end
|
||||
echo "data:$mimeType;base64,(openssl base64 -in $argv | tr -d '\n')"
|
||||
end
|
||||
3
fish/functions/encodeBase64.fish
Normal file
3
fish/functions/encodeBase64.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function encodeBase64 --description "Encodes images in Base64"
|
||||
uuencode -m $argv[1] /dev/stdout | sed 1d | sed '$d'
|
||||
end
|
||||
3
fish/functions/fcd.fish
Normal file
3
fish/functions/fcd.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function fcd --description "cd into directory"
|
||||
cd (find * -type d | fzf --preview 'tree -C {} | head -50')
|
||||
end
|
||||
10
fish/functions/fe.fish
Normal file
10
fish/functions/fe.fish
Normal file
@@ -0,0 +1,10 @@
|
||||
# fe [FUZZY PATTERN] - Open the selected file with the default editor
|
||||
# - Bypass fuzzy finder if there's only one match (--select-1)
|
||||
# - Exit if there's no match (--exit-0)
|
||||
function fe --description "Open the selected file with the default editor"
|
||||
set files (fzf-tmux --query=$argv --multi --select-1 --exit-0 | string split \n)
|
||||
|
||||
if test -n "$files"
|
||||
$EDITOR $files; and true # This line is added to prevent failure when using "set -e" in shell.
|
||||
end
|
||||
end
|
||||
4
fish/functions/fhcd.fish
Normal file
4
fish/functions/fhcd.fish
Normal file
@@ -0,0 +1,4 @@
|
||||
function fhcd --description "Jump to home directory and search for directories"
|
||||
cd $HOME
|
||||
cd (find * -type d | fzf --preview 'tree -C {} | head -50')
|
||||
end
|
||||
13
fish/functions/fs.fish
Normal file
13
fish/functions/fs.fish
Normal file
@@ -0,0 +1,13 @@
|
||||
function fs --description "Determine size of a file or total size of a directory"
|
||||
if du -b /dev/null >/dev/null 2>&1
|
||||
set arg -sbh
|
||||
else
|
||||
set arg -sh
|
||||
end
|
||||
|
||||
if test -n "$argv"
|
||||
du $arg -- $argv
|
||||
else
|
||||
du $arg .[^.]* *
|
||||
end
|
||||
end
|
||||
3
fish/functions/server.fish
Normal file
3
fish/functions/server.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function server --description "Run a server with browser-sync"
|
||||
browser-sync start --server --files "**"
|
||||
end
|
||||
5
fish/functions/unquarantine.fish
Normal file
5
fish/functions/unquarantine.fish
Normal file
@@ -0,0 +1,5 @@
|
||||
function unquarantine --description "Manually remove a downloaded app or file from the quarantine"
|
||||
for attribute in com.apple.metadata:kMDItemDownloadedDate com.apple.metadata:kMDItemWhereFroms com.apple.quarantine
|
||||
xattr -r -d "$attribute" $argv
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user