dotfiles/cli/fish.sh

110 lines
3.8 KiB
Bash
Raw Normal View History

2020-11-02 04:08:18 +00:00
#!/bin/sh
2020-09-17 10:24:35 +00:00
2020-11-21 18:07:26 +00:00
set -e
2020-11-08 16:26:14 +00:00
DIR=$(dirname "$(readlink -f "$0")")
2020-11-02 04:08:18 +00:00
. "$DIR/../env.sh"
2020-09-17 10:24:35 +00:00
2020-11-21 18:07:26 +00:00
log 'Setting up shell'
2021-10-05 15:29:10 +00:00
case "$PM" in
apt)
if ! has_cmd fish; then
2021-09-16 10:18:10 +00:00
sudo add-apt-repository ppa:fish-shell/release-3 -y -n
pm_update
2021-10-05 15:29:10 +00:00
sudo apt install fish
fi
sudo apt install silversearcher-ag -y
echo DISTRIB_RELEASE_MAJOR: $DISTRIB_RELEASE_MAJOR
echo DISTRIB_RELEASE: $DISTRIB_RELEASE
if [ "$DISTRIB_RELEASE_MAJOR" -gt 19 ] || [ "$DISTRIB_RELEASE" = "19.10" ]; then
sudo apt install dash bat -y
fi
sudo ln -sf /usr/bin/batcat /usr/bin/bat
intorepo https://github.com/junegunn/fzf.git "$HOME/.fzf"
./install --all
exitrepo
;;
pacman)
sudo pacman -S --noconfirm --needed fish the_silver_searcher dash bat fzf
# prevent bash upgradation relink /bin/sh
sudo mkdir -p /etc/pacman.d/hooks
echo "
[Trigger]
Type = Package
Operation = Install
Operation = Upgrade
Target = bash
[Action]
Description = Re-pointing /bin/sh symlink to dash...
When = PostTransaction
Exec = /usr/bin/ln -sfT dash /usr/bin/sh
Depends = dash
" | sed 's/^ *//' | sudo tee /etc/pacman.d/sh-is-dash.hook >/dev/null
;;
esac
# xclip/xsel for wsl
if [ -n "$WSL" ]; then
lnsf "$PDIR/bin/x-clip" "$HOME/.local/bin/xsel"
lnsf "$PDIR/bin/x-clip" "$HOME/.local/bin/xclip"
2021-09-16 10:18:10 +00:00
fi
2020-09-17 10:24:35 +00:00
2020-12-17 08:08:47 +00:00
# only for local machine with gui
if [ -z "$SSH_CLIENT" ] && [ -n "$DISPLAY" ] && has_cmd dash; then
2020-12-17 08:08:47 +00:00
log 'Setting up dash as default shell'
sudo /usr/bin/ln -sfT dash /usr/bin/sh
2020-12-17 08:08:47 +00:00
if [ "$(awk -F':' '/^'"$USER"'/{print $7}' /etc/passwd)" != "/bin/sh" ]; then
chsh -s /bin/sh
fi
fi
2020-09-17 10:24:35 +00:00
2020-11-21 18:07:26 +00:00
log 'Setting up fish'
lnsf "$DIR/fish/config.fish" "$XDG_CONFIG_HOME/fish/config.fish"
lnsf "$DIR/fish/functions/fish_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_prompt.fish"
lnsf "$DIR/fish/functions/fish_right_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_right_prompt.fish"
lnsf "$DIR/fish/functions/fisher.fish" "$XDG_CONFIG_HOME/fish/functions/fisher.fish"
lnsf "$DIR/fish/functions/r.fish" "$XDG_CONFIG_HOME/fish/functions/r.fish"
2021-03-02 02:52:31 +00:00
lnsf "$DIR/fish/functions/f.fish" "$XDG_CONFIG_HOME/fish/functions/f.fish"
2020-11-21 18:07:26 +00:00
lnsf "$DIR/fish/functions/append_paths.fish" "$XDG_CONFIG_HOME/fish/functions/append_paths.fish"
lnsf "$DIR/fish/functions/source_files.fish" "$XDG_CONFIG_HOME/fish/functions/source_files.fish"
2021-06-15 03:58:03 +00:00
lnsf "$DIR/fish/functions/git_clone_all.fish" "$XDG_CONFIG_HOME/fish/functions/git_clone_all.fish"
lnsf "$DIR/fish/functions/winip.fish" "$XDG_CONFIG_HOME/fish/functions/winip.fish"
2020-09-18 18:01:58 +00:00
# install plugins
2020-11-04 07:22:15 +00:00
# for better keybinding: C-o open file with $EDITOR / C-r search history / C-g open with xdg-open
fish -c "fisher add jethrokuan/fzf"
# set color theme: Old School
fish -c '
set -L
set -U fish_color_normal normal
set -U fish_color_command 00FF00
set -U fish_color_quote 44FF44
set -U fish_color_redirection 7BFF7B
set -U fish_color_end FF7B7B
set -U fish_color_error A40000
set -U fish_color_param 30BE30
set -U fish_color_comment 30BE30
set -U fish_color_match --background=brblue
set -U fish_color_selection white --bold --background=brblack
set -U fish_color_search_match bryellow --background=brblack
set -U fish_color_history_current --bold
set -U fish_color_operator 00a6b2
set -U fish_color_escape 00a6b2
set -U fish_color_cwd green
set -U fish_color_cwd_root red
set -U fish_color_valid_path --underline
set -U fish_color_autosuggestion 777777
set -U fish_color_user brgreen
set -U fish_color_host normal
set -U fish_color_cancel -r
set -U fish_pager_color_completion normal
set -U fish_pager_color_description B3A06D yellow
set -U fish_pager_color_prefix white --bold --underline
set -U fish_pager_color_progress brwhite --background=cyan
2020-11-21 18:07:26 +00:00
' > /dev/null