new cli tools aliases for fish

This commit is contained in:
Sergio Laín 2023-07-16 23:39:36 +02:00
parent e92172c27e
commit 4661ad04b5
8 changed files with 57 additions and 338 deletions

View file

@ -6,7 +6,7 @@
"url": "/channels/674984102860161025/1007802241035538452", "url": "/channels/674984102860161025/1007802241035538452",
"selected": true, "selected": true,
"currentStatus": "none", "currentStatus": "none",
"iconUrl": "https://cdn.discordapp.com/icons/674984102860161025/a4c5c84a118b923dfe68dccd886d1d87.webp?size=44", "iconUrl": "https://cdn.discordapp.com/icons/674984102860161025/a4c5c84a118b923dfe68dccd886d1d87.webp?size=40",
"channelId": "1007802241035538452" "channelId": "1007802241035538452"
}, },
{ {
@ -26,11 +26,12 @@
"channelId": "635625917623828520" "channelId": "635625917623828520"
}, },
{ {
"name": "Friends", "name": "@Sergio Laín",
"url": "/channels/@me", "url": "/channels/@me/1107960185529581679",
"selected": false, "selected": false,
"currentStatus": "none", "currentStatus": "offline",
"iconUrl": "https://cdn.discordapp.com/embed/avatars/0.png" "iconUrl": "https://cdn.discordapp.com/avatars/1087642197685452850/b61c2b287c9f9e3e31a5a9741884a33d.webp?size=40",
"channelId": "1107960185529581679"
} }
], ],
"favs": [], "favs": [],

View file

@ -44,6 +44,17 @@
{ {
"id": "vscode.menubar.separator" "id": "vscode.menubar.separator"
}, },
{
"id": "openRecentFolder",
"uri": {
"$mid": 1,
"external": "file:///home/matt/.config/kitty",
"path": "/home/matt/.config/kitty",
"scheme": "file"
},
"enabled": true,
"label": "~/.config/kitty"
},
{ {
"id": "openRecentFolder", "id": "openRecentFolder",
"uri": { "uri": {
@ -143,17 +154,6 @@
"enabled": true, "enabled": true,
"label": "~/.config/pipewire" "label": "~/.config/pipewire"
}, },
{
"id": "openRecentFolder",
"uri": {
"$mid": 1,
"external": "file:///usr/lib/librewolf/browser",
"path": "/usr/lib/librewolf/browser",
"scheme": "file"
},
"enabled": true,
"label": "/usr/lib/librewolf/browser"
},
{ {
"id": "vscode.menubar.separator" "id": "vscode.menubar.separator"
}, },
@ -666,11 +666,13 @@
}, },
{ {
"id": "workbench.action.toggleZenMode", "id": "workbench.action.toggleZenMode",
"label": "Zen Mode" "label": "Zen Mode",
"checked": true
}, },
{ {
"id": "workbench.action.toggleCenteredLayout", "id": "workbench.action.toggleCenteredLayout",
"label": "&&Centered Layout" "label": "&&Centered Layout",
"checked": true
}, },
{ {
"id": "vscode.menubar.separator" "id": "vscode.menubar.separator"
@ -1003,45 +1005,54 @@
}, },
{ {
"id": "workbench.action.focusThirdEditorGroup", "id": "workbench.action.focusThirdEditorGroup",
"label": "Group &&3" "label": "Group &&3",
"enabled": false
}, },
{ {
"id": "workbench.action.focusFourthEditorGroup", "id": "workbench.action.focusFourthEditorGroup",
"label": "Group &&4" "label": "Group &&4",
"enabled": false
}, },
{ {
"id": "workbench.action.focusFifthEditorGroup", "id": "workbench.action.focusFifthEditorGroup",
"label": "Group &&5" "label": "Group &&5",
"enabled": false
}, },
{ {
"id": "vscode.menubar.separator" "id": "vscode.menubar.separator"
}, },
{ {
"id": "workbench.action.focusNextGroup", "id": "workbench.action.focusNextGroup",
"label": "&&Next Group" "label": "&&Next Group",
"enabled": false
}, },
{ {
"id": "workbench.action.focusPreviousGroup", "id": "workbench.action.focusPreviousGroup",
"label": "&&Previous Group" "label": "&&Previous Group",
"enabled": false
}, },
{ {
"id": "vscode.menubar.separator" "id": "vscode.menubar.separator"
}, },
{ {
"id": "workbench.action.focusLeftGroup", "id": "workbench.action.focusLeftGroup",
"label": "Group &&Left" "label": "Group &&Left",
"enabled": false
}, },
{ {
"id": "workbench.action.focusRightGroup", "id": "workbench.action.focusRightGroup",
"label": "Group &&Right" "label": "Group &&Right",
"enabled": false
}, },
{ {
"id": "workbench.action.focusAboveGroup", "id": "workbench.action.focusAboveGroup",
"label": "Group &&Above" "label": "Group &&Above",
"enabled": false
}, },
{ {
"id": "workbench.action.focusBelowGroup", "id": "workbench.action.focusBelowGroup",
"label": "Group &&Below" "label": "Group &&Below",
"enabled": false
} }
] ]
} }
@ -1241,7 +1252,8 @@
}, },
{ {
"id": "workbench.action.terminal.split", "id": "workbench.action.terminal.split",
"label": "&&Split Terminal" "label": "&&Split Terminal",
"enabled": false
}, },
{ {
"id": "vscode.menubar.separator" "id": "vscode.menubar.separator"
@ -1792,7 +1804,7 @@
"sideBarSide": "left", "sideBarSide": "left",
"editorPartMinWidth": 220, "editorPartMinWidth": 220,
"titleBarHeight": 0, "titleBarHeight": 0,
"activityBarWidth": 48, "activityBarWidth": 0,
"sideBarWidth": 0, "sideBarWidth": 0,
"statusBarHeight": 0, "statusBarHeight": 0,
"windowBorder": false "windowBorder": false
@ -1800,13 +1812,13 @@
}, },
"windowsState": { "windowsState": {
"lastActiveWindow": { "lastActiveWindow": {
"folder": "file:///home/matt/.config", "folder": "file:///home/matt/.config/kitty",
"backupPath": "/home/matt/.config/VSCodium/Backups/375730732710406c4b825f9cde716ece", "backupPath": "/home/matt/.config/VSCodium/Backups/f862d78a22ff70d122e141cd428aace5",
"uiState": { "uiState": {
"mode": 1, "mode": 1,
"x": 21, "x": 1234,
"y": 1109, "y": 1109,
"width": 2404, "width": 1191,
"height": 934 "height": 934
} }
}, },
@ -1822,10 +1834,7 @@
"folderUri": "file:///home/matt/.config/awesome" "folderUri": "file:///home/matt/.config/awesome"
}, },
{ {
"folderUri": "file:///home/matt/.oh-my-zsh" "folderUri": "file:///home/matt/.config/kitty"
},
{
"folderUri": "file:///home/matt/.config"
} }
], ],
"emptyWindows": [] "emptyWindows": []
@ -1869,7 +1878,6 @@
"file:///home/matt/Repos/Non-Personal/Community%20Dotfiles/Dots/AwesomeWM/awesomeCrylia": "__default__profile__", "file:///home/matt/Repos/Non-Personal/Community%20Dotfiles/Dots/AwesomeWM/awesomeCrylia": "__default__profile__",
"file:///home/matt/Repos/Personal/Dotfiles": "__default__profile__", "file:///home/matt/Repos/Personal/Dotfiles": "__default__profile__",
"file:///home/matt/.zhs": "__default__profile__", "file:///home/matt/.zhs": "__default__profile__",
"file:///home/matt/.config/kitty": "__default__profile__",
"file:///home/matt/Repos/Non-Personal/Community%20Dotfiles/Dots/Hyprland/dotfiles-hyprland": "__default__profile__", "file:///home/matt/Repos/Non-Personal/Community%20Dotfiles/Dots/Hyprland/dotfiles-hyprland": "__default__profile__",
"file:///home/matt/Repos/Non-Personal/Community%20Dotfiles/Dots/Hyprland/.dotfiles": "__default__profile__", "file:///home/matt/Repos/Non-Personal/Community%20Dotfiles/Dots/Hyprland/.dotfiles": "__default__profile__",
"file:///home/matt/Repos/Clase/2%C2%BADAM/PSP": "__default__profile__", "file:///home/matt/Repos/Clase/2%C2%BADAM/PSP": "__default__profile__",
@ -1885,7 +1893,8 @@
"file:///home/matt/.config/lazygit": "__default__profile__", "file:///home/matt/.config/lazygit": "__default__profile__",
"file:///home/matt/.oh-my-zsh/themes": "__default__profile__", "file:///home/matt/.oh-my-zsh/themes": "__default__profile__",
"file:///home/matt/.oh-my-zsh": "__default__profile__", "file:///home/matt/.oh-my-zsh": "__default__profile__",
"file:///home/matt/.config": "__default__profile__" "file:///home/matt/.config": "__default__profile__",
"file:///home/matt/.config/kitty": "__default__profile__"
}, },
"emptyWindows": {} "emptyWindows": {}
}, },

View file

@ -1,3 +0,0 @@
if test -z "$TO_DIR"
set -U TO_DIR ~/.tofish
end

View file

@ -1,6 +1,7 @@
if status is-interactive if status is-interactive
# Commands to run in interactive sessions can go here # Commands to run in interactive sessions can go here
neofetch neofetch
zoxide init fish | source
end end
alias code='vscodium' alias code='vscodium'
@ -11,15 +12,18 @@ alias matrix='unimatrix'
alias q='exit' alias q='exit'
alias install='sudo pacman -S ' alias install='sudo pacman -S '
alias uninstall='sudo pacman -R ' alias uninstall='sudo pacman -R '
alias yayinstall='yay -S ' alias yinstall='yay -S '
alias yayuninstall='yay -R ' alias yuninstall='yay -R '
alias update='sudo pacman -Syu' alias update='sudo pacman -Syu'
alias yayupdate='yay -Syu' alias yupdate='yay -Syu'
alias search='pacseek' alias search='pacseek'
alias gpt='tgpt' alias gpt='tgpt'
alias clock='tty-clock -sbc' alias clock='tty-clock -sbc'
alias l='xplr' alias files='xplr'
alias sysproc='sysz' alias sysproc='sysz'
alias cat='bat' alias cat='bat'
alias dots='yadm enter lazygit' alias dots='yadm enter lazygit'
alias audiorestart='systemctl --user restart wireplumber pipewire pipewire-pulse' alias audiorestart='systemctl --user restart wireplumber pipewire pipewire-pulse'
alias info='tldr'
alias cd='z'
alias disks='duf'

View file

@ -1,290 +0,0 @@
# Display general usage
function __to_usage
echo 'Usage:'
echo ' to (BOOKMARK|DIR) Go to BOOKMARK or DIR'
echo ' to add [BOOKMARK] [DEST] Create a BOOKMARK for DEST'
echo ' Default BOOKMARK: name of current directory'
echo ' Default DEST: path to current directory'
echo ' to add DEST Create a bookmark for DEST if it is a directory'
echo ' to ls List all bookmarks'
echo ' to mv OLD NEW Change the name of a bookmark from OLD to NEW'
echo ' to rm BOOKMARK Remove BOOKMARK'
echo ' to clean Remove bookmarks that have a missing destination'
echo ' to resolve BOOKMARK Print the destination of a bookmark'
echo ' to help Show this message'
echo
echo "Bookmarks are stored in: $TO_DIR"
echo 'To change, run: set -U TO_DIR <dir>'
return 1
end
# https://github.com/fish-shell/fish-shell/issues/6173#issuecomment-1067114363
function is_empty_dir
test -d "$argv"
or return 1 # not a directory, so not an empty directory
# count counts how many arguments it received
# if this glob doesn't match, it won't get arguments
# and so it will return 1
# because we *want* an empty directory, turn that around.
# the `{.*,*}` ensures it matches hidden files as well.
not count $argv/{.*,*} >/dev/null
end
function __to_dir
if test -n "$TO_DIR"
echo $TO_DIR
return
end
set -l dir
if test -d "$HOME/.tofish" && not is_empty_dir $HOME/.tofish
set dir $HOME/.tofish
else if test -n "$XDG_DATA_HOME"
set dir $XDG_DATA_HOME/to-fish
else
set dir $HOME/.local/share/to-fish
end
set -U TO_DIR $dir
echo $TO_DIR
end
function __to_bm_path
echo (__to_dir)/$argv
end
function __to_resolve
readlink (__to_bm_path $argv) 2>/dev/null
end
function __to_print
__to_resolve $argv | string replace -r "^$HOME" "~" | string replace -r '^~$' $HOME
end
function __to_ls
for l in (__to_dir)/*
basename $l
end
end
function __to_rm
command rm -v (__to_bm_path $argv[1]); or return $status
__to_update_bookmark_completions
end
function __to_add -a bm dest
# if there are no arguments
if test -z "$bm"
# use the current directory
set dest (pwd)
set bm (basename $dest)
else
# if there are two arguments
if test -n "$dest"
# use them as bookmark name and destination
set dest (realpath $dest)
# if there is only one argument
else
# if the argument is a directory
if string match -q '*/*' $bm && test -d "$bm"
# use it as the destination
set dest (realpath $bm)
set bm (basename $dest)
else
# if not a directory
# use it as the bookmark name
set dest (pwd)
end
end
end
if __to_resolve $bm > /dev/null
echo "ERROR: Bookmark exists: $bm -> "(__to_print $bm) >&2
return 1
end
if not test -d "$dest"
echo "ERROR: Destination does not exist: $dest" >&2
return 1
end
if string match -q '*/*' $bm
echo "ERROR: Bookmark name cannot contain '/': $bm" >&2
return 1
end
switch (uname)
case Darwin
command ln -s $dest (__to_bm_path $bm); or return $status
case '*'
command ln -sT $dest (__to_bm_path $bm); or return $status
end
echo $bm "->" (__to_print $bm)
__to_update_bookmark_completions
end
function __to_complete_directories
set -l cl (commandline -ct | string split -m 1 /)
set -l bm $cl[1]
set -l bmdir (__to_resolve $bm)
if test -z "$bmdir"
__fish_complete_directories
else
set -e cl[1]
if test -z "$cl"
__fish_complete_directories $bmdir/ | string replace -r 'Directory$' $bm
else
__fish_complete_directories $bmdir/$cl | string replace -r 'Directory$' $bm
end
end
end
function __to_update_bookmark_completions
complete -e -c to
complete -c to -k -x -s h -l help -d 'Show help'
# Subcommands
complete -c to -k -n '__fish_use_subcommand' -f -a 'help' -d 'Show help'
complete -c to -k -n '__fish_use_subcommand' -x -a 'resolve' -d 'Print bookmark destination'
complete -c to -k -n '__fish_use_subcommand' -x -a 'clean' -d 'Remove bad bookmarks'
complete -c to -k -n '__fish_use_subcommand' -x -a 'mv' -d 'Rename bookmark'
complete -c to -k -n '__fish_use_subcommand' -x -a 'rm' -d 'Remove bookmark'
complete -c to -k -n '__fish_use_subcommand' -f -a 'ls' -d 'List bookmarks'
complete -c to -k -n '__fish_use_subcommand' -x -a 'add' -d 'Create bookmark'
# Directories
complete -c to -k -n '__fish_use_subcommand' -r -a '(__to_complete_directories)'
# Bookmarks
for bm in (__to_ls | sort -r)
complete -c to -k -n '__fish_use_subcommand; or __fish_seen_subcommand_from rm mv resolve' -r -a (echo $bm | string escape) -d (__to_print $bm)
end
end
function to -d 'Bookmarking tool'
set -l dir (__to_dir)
# Create tofish directory
if not test -d "$dir"
if command mkdir $dir
echo "Created bookmark directory: $dir"
else
echo "Failed to Create bookmark directory: $dir"
return 1
end
end
# Catch usage errors
set -l cmd $argv[1]
set -l numargs (count $argv)
switch $cmd
# subcommands that don't take an argument
case ls help clean
if not test $numargs -eq 1
echo "Usage: to $cmd"
return 1
end
# subcommands that require an argument
case rm resolve
if not test $numargs -eq 2
echo "Usage: to $cmd BOOKMARK"
return 1
end
# add has 2 optional arguments
case add
if not test $numargs -ge 1 -a $numargs -le 3
echo 'Usage: to add [BOOKMARK] [DEST]'
echo ' to add DEST'
return 1
end
# subcommands that require 2 arguments
case mv
if not test $numargs -eq 3
echo 'Usage: to mv OLD NEW'
return 1
end
end
switch $cmd
# Add a bookmark
case add
__to_add $argv[2..-1]
return $status
# Remove a bookmark
case rm
__to_rm $argv[2]
return $status
# List all bookmarks
case ls
for bm in (__to_ls)
echo "$bm -> "(__to_print $bm)
end
return 0
# Rename a bookmark
case mv
set -l old $argv[2]
if not __to_resolve $old > /dev/null
echo "ERROR: Bookmark not found: $old"
return 1
end
set -l new $argv[3]
__to_add $new (__to_resolve $old); or return $status
__to_rm $old; or return $status
return 0
# Clean
case clean
for bm in (__to_ls)
if not test -d (__to_resolve $bm)
__to_rm $bm
end
end
return 0
# Resolve
case resolve
__to_resolve $argv[2]
return $status
# Help
case -h --help help
__to_usage
return 0
# Default
case '*'
set -l name $argv[1]
if test -z "$name"
__to_usage
return 1
end
set -l dest (__to_resolve $name)
if test -z "$dest"
if test -d "$name"
echo "cd \"$name\"" | source -
else
echo "to: No such bookmark “$name" >&2
return 1
end
else if test -d "$dest"
echo "cd \"$dest\"" | source -
else
echo "to: Destination for bookmark “$name” does not exist: $dest" >&2
return 1
end
end
end

View file

@ -1 +0,0 @@
/home/matt/.config/fish

View file

@ -1 +0,0 @@
/home/matt/.config/hypr