Switch to fish shell
This commit is contained in:
16
.config/fish/alias.fish
Normal file
16
.config/fish/alias.fish
Normal file
@@ -0,0 +1,16 @@
|
||||
# Utilities
|
||||
alias cls clear
|
||||
|
||||
alias vencord 'sh -c "$(curl -sS https://raw.githubusercontent.com/Vendicated/VencordInstaller/main/install.sh)"'
|
||||
|
||||
# Places
|
||||
alias applications 'cd ~/.local/share/applications/'
|
||||
alias dot 'cd ~/dotfiles'
|
||||
|
||||
# Layout
|
||||
alias smap layout # Switch map
|
||||
alias us 'layout -t us'
|
||||
alias sv 'layout -t se'
|
||||
|
||||
# SSH
|
||||
alias louis 'echo "$(set_color red)You changed this dimwit, use \'vpn\' instead"'
|
||||
66
.config/fish/config.fish
Normal file
66
.config/fish/config.fish
Normal file
@@ -0,0 +1,66 @@
|
||||
set fish_greeting '( .-.)'
|
||||
|
||||
set PI 3.141592653589
|
||||
|
||||
set _TEMP '/tmp/anton/'
|
||||
|
||||
if not test -d $_TEMP
|
||||
mkdir -p $_TEMP
|
||||
end
|
||||
|
||||
source ~/.config/fish/alias.fish
|
||||
|
||||
set -l last_status $status
|
||||
|
||||
function fish_mode_prompt; end
|
||||
|
||||
function fish_prompt
|
||||
set -l duration $CMD_DURATION
|
||||
|
||||
if test $CMD_DURATION -gt 700
|
||||
set -l seconds $(round -p 2 $(math $duration / 1000 % 60))
|
||||
set seconds $seconds "s"
|
||||
set -l minutes
|
||||
if test $duration -gt 60000
|
||||
set minutes $(round (math $duration / 60000))
|
||||
set minutes $minutes "m "
|
||||
end
|
||||
|
||||
|
||||
string join '' -- (set_color white) "took " (set_color yellow) $minutes $seconds
|
||||
end
|
||||
|
||||
set -l mode
|
||||
switch (echo $fish_bind_mode)
|
||||
case default
|
||||
set mode $(string join '' -- (set_color --bold red) '[N] ' (set_color normal))
|
||||
case insert
|
||||
set mode $(string join '' -- (set_color --bold cyan) '[I] ' (set_color normal))
|
||||
case replace_one
|
||||
set mode $(string join '' -- (set_color --bold green) '[R] ' (set_color normal))
|
||||
case visual
|
||||
set mode $(string join '' -- (set_color --bold brmagenta) '[V] ' (set_color normal))
|
||||
case '*'
|
||||
set mode $(string join '' -- (set_color --bold red) '[?] ' (set_color normal))
|
||||
end
|
||||
|
||||
set -l last_status $status
|
||||
|
||||
set -l cursor_color $(set_color green)
|
||||
|
||||
if test $last_status -ne 0
|
||||
set last_status $(string join '' -- (set_color red) " [$last_status]")
|
||||
set cursor_color $(set_color red)
|
||||
else
|
||||
set last_status ""
|
||||
end
|
||||
|
||||
set -l git $(string trim -- (fish_vcs_prompt))
|
||||
if test -n "$git"
|
||||
set git $(string join '' -- (set_color yellow) " " (string sub -s 2 $git -e -1) " ")
|
||||
end
|
||||
|
||||
set -l pwd $(string join '' -- (set_color green) (prompt_pwd -D 2 -d 1) (set_color normal))
|
||||
|
||||
string join '' -- $mode $pwd $last_status $git $cursor_color '|> '
|
||||
end
|
||||
20
.config/fish/functions/clip.fish
Normal file
20
.config/fish/functions/clip.fish
Normal file
@@ -0,0 +1,20 @@
|
||||
function clip
|
||||
set -g stdin
|
||||
if not tty -s >/dev/null
|
||||
read stdin
|
||||
end
|
||||
set stdin $(string trim -- $stdin)
|
||||
|
||||
set -l argv $(string trim -- $argv)
|
||||
if test -n "$argv"
|
||||
echo "$argv" | xclip -selection clipboard
|
||||
return 0
|
||||
end
|
||||
|
||||
if test -n "$stdin"
|
||||
echo "$stdin" | xclip -selection clipboard
|
||||
return 0
|
||||
end
|
||||
|
||||
xclip -selection clipboard -o
|
||||
end
|
||||
3
.config/fish/functions/into.fish
Normal file
3
.config/fish/functions/into.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function into
|
||||
mkdir -p "$argv" && cd "$argv"
|
||||
end
|
||||
61
.config/fish/functions/layout.fish
Normal file
61
.config/fish/functions/layout.fish
Normal file
@@ -0,0 +1,61 @@
|
||||
function layout
|
||||
argparse -n "layout" "v/verbose" "t/target=" -- $argv
|
||||
or return 1
|
||||
|
||||
set _target
|
||||
|
||||
if set -q _flag_target
|
||||
set _target "$_flag_target"
|
||||
end
|
||||
|
||||
if test -f "$_TEMP/curr-layout"
|
||||
if not set -q _flag_target
|
||||
switch (cat "$_TEMP/curr-layout")
|
||||
case us
|
||||
set _target "sv"
|
||||
case se
|
||||
set _target "us"
|
||||
case sv
|
||||
set _target "us"
|
||||
case '*'
|
||||
if set -q _flag_verbose
|
||||
echo "Unregognized layout set in /curr-layout file; stopping..."
|
||||
end
|
||||
return 1
|
||||
end
|
||||
end
|
||||
else
|
||||
if set -q _flag_verbose; and not set -q _flag_target
|
||||
echo "Could not determine current layout; defaulting to US"
|
||||
end
|
||||
echo "us" > "$_TEMP/curr-layout"
|
||||
if not set -q _flag_target
|
||||
set _target "sv"
|
||||
end
|
||||
end
|
||||
|
||||
if not set -q _target
|
||||
return 2
|
||||
end
|
||||
|
||||
if set -q _flag_verbose
|
||||
switch (echo $_target)
|
||||
case sv
|
||||
echo "Switching to Swedish layout..."
|
||||
case us
|
||||
echo "Switching to U.S. layout..."
|
||||
end
|
||||
end
|
||||
|
||||
switch (echo $_target)
|
||||
case sv
|
||||
set _target se
|
||||
case '*'
|
||||
end
|
||||
|
||||
if setxkbmap -layout $_target
|
||||
echo $_target > "$_TEMP/curr-layout"
|
||||
end
|
||||
|
||||
return $status
|
||||
end
|
||||
22
.config/fish/functions/round.fish
Normal file
22
.config/fish/functions/round.fish
Normal file
@@ -0,0 +1,22 @@
|
||||
function round
|
||||
argparse -n "round" -i "p/precision=!_validate_int" -- $argv
|
||||
or return 1
|
||||
|
||||
set -l value $argv
|
||||
|
||||
set -l precision 0
|
||||
if set -q _flag_precision
|
||||
set precision $_flag_precision
|
||||
end
|
||||
|
||||
set precision $(math 10 ^ $precision)
|
||||
|
||||
set value $(math $value x $precision)
|
||||
|
||||
set -l right $(math $value % 1)
|
||||
|
||||
set value $(math $value - $right)
|
||||
set value $(math $value / $precision)
|
||||
|
||||
echo $value
|
||||
end
|
||||
84
.config/fish/functions/vpn.fish
Normal file
84
.config/fish/functions/vpn.fish
Normal file
@@ -0,0 +1,84 @@
|
||||
function vpn
|
||||
argparse -n "vpn" -x e,d -x q,s 'e/enable' 'd/disable' 's/status' 'q/quiet' 'f/force' -- $argv
|
||||
or return 1
|
||||
|
||||
set _silent false
|
||||
if set -q _flag_quiet
|
||||
set _silent true
|
||||
end
|
||||
|
||||
set _path ~/wg0.conf
|
||||
set _status false
|
||||
|
||||
if test -f "$_TEMP/vpn-status"
|
||||
switch (cat "$_TEMP/vpn-status")
|
||||
case true
|
||||
set _status true
|
||||
case false
|
||||
set _status false
|
||||
case '*'
|
||||
if not $_quiet
|
||||
echo "Unregognized /vpn-status contents, exiting!"
|
||||
end
|
||||
return 1
|
||||
end
|
||||
else
|
||||
if not $_silent
|
||||
echo "Did not find status file; creating..."
|
||||
echo "false" >> "$_TEMP/vpn-status"
|
||||
end
|
||||
end
|
||||
|
||||
if set -q _flag_status
|
||||
if $_status
|
||||
echo "VPN is active."
|
||||
else
|
||||
echo "VPN is inactive."
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
if not set -q _flag_enable; and not set -q _flag_disable
|
||||
if $_status
|
||||
set _flag_disable
|
||||
else
|
||||
set _flag_enable
|
||||
end
|
||||
end
|
||||
|
||||
if set -q _flag_enable
|
||||
if $_status; and not set -q _flag_force
|
||||
if not $_silent
|
||||
echo "Already enabled."
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
if wg-quick up $_path
|
||||
echo "true" > "$_TEMP/vpn-status"
|
||||
if not $_silent
|
||||
echo "Successfully enabled."
|
||||
end
|
||||
end
|
||||
return $status
|
||||
end
|
||||
|
||||
if set -q _flag_disable
|
||||
if not $_status; and not set -q _flag_force
|
||||
if not $_silent
|
||||
echo "Already disabled."
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
if wg-quick down $_path
|
||||
echo "false" > "$_TEMP/vpn-status"
|
||||
if not $_silent
|
||||
echo "Successfully disabled."
|
||||
end
|
||||
end
|
||||
return $status
|
||||
end
|
||||
|
||||
return 2
|
||||
end
|
||||
@@ -21,4 +21,5 @@ color14 #4d7b73
|
||||
color7 #b5b8b6
|
||||
color15 #5a6169
|
||||
|
||||
selection_foreground #161718
|
||||
selection_foreground #b7bcb9
|
||||
selection_background #2a2e33
|
||||
@@ -1325,6 +1325,7 @@ enable_audio_bell no
|
||||
#: Advanced {{{
|
||||
|
||||
# shell .
|
||||
shell /usr/bin/fish
|
||||
|
||||
#: The shell program to execute. The default value of . means to use
|
||||
#: whatever shell is set as the default shell for the current user.
|
||||
|
||||
Reference in New Issue
Block a user