Skip to content

Instantly share code, notes, and snippets.

@pabloasanchez
Last active October 13, 2023 19:44
Show Gist options
  • Save pabloasanchez/18439ab284c68b94e7e627a52d911527 to your computer and use it in GitHub Desktop.
Save pabloasanchez/18439ab284c68b94e7e627a52d911527 to your computer and use it in GitHub Desktop.
Taking a few things from my fish cfg back to bash
# Taking a few things from my fish cfg back to bash: vi keys, branch name in prompt, custom prompt, completion (with fzf)
# Custom prompt
# Vi keys
# History
# Completion (Using fzf & fzf-tab-completion)
# Tip: Install bashmarks and fasd for faster directory browsing
# Custom prompt: Add to .bashrc
# Helps reset prompt when tty crashes
PROMPT_COMMAND='stty sane; tput rmacs'
# Custom prompt, originally generated from bash-prompt-generator.org
PS1='\[\e[2m\](\[\e[0;38;5;202m\]$(git branch 2>/dev/null | grep '"'"'*'"'"' | colrm 1 2)\[\e[0;2m\]) \[\e[0;38;5;214m\]\w\033[0m\n\[\e[38;5;242m\]\t \[\e[0m\]'
# Enables vi mode (works with ble.sh too)
set -o vi
# Make sure .inputrc reloads
bind -f ~/.inputrc
# Add to .inputrc
"\C-k":history-search-backward
"\C-j":history-search-forward
"\C-l":clear-screen
set show-mode-in-prompt on
set editing-mode vi
set vi-ins-mode-string \1\e[31m\2• \1\e[0m\2
set vi-cmd-mode-string \1\e[0m\2$ \1\e[0m\2
# Use vi keys, also works with ble.sh; add to .bashrc
set -o vi
# turn off with set +o vi
# Copy fish's history
cp ~/.bash_history .bash_history_backup
cat ~/.local/share/fish/fish_history | grep -e "- cmd: " | sed "s/- cmd: //" >> ~/.bash_history
# Install fzf and use Ctrl+R and Ctrl+T
sudo apt install fzf
# Add to .bashrc
export FZF_DEFAULT_COMMAND='rg --files --hidden' #FZF using ripgrep instead of find to respect .gitignore
export FZF_DEFAULT_OPTS="--extended --cycle --bind 'tab:toggle-down,btab:toggle-up'"
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind 'tab:toggle-up,btab:toggle-down' --header 'Command History'"
# Install https://github.com/lincheney/fzf-tab-completion
# git clone https://github.com/lincheney/fzf-tab-completion
# Add to .bashrc to configure fzf-tab-completion, (see project's README for updated instructions)
# export FZF_COMPLETION_AUTO_COMMON_PREFIX=true
# export FZF_COMPLETION_AUTO_COMMON_PREFIX_PART=true
# source $HOME/Apps/fzf-tab-completion/bash/fzf-bash-completion.sh
# bind -x '"\t": fzf_bash_completion'
# A banner. Add to .bashrc
echo -e "\e[31m"
sed '6s/$/'"$(uname -srm)"'/' ~/.banner | sed '7s/$/'"$(date)"'/'
echo -e "\e[0m"
# ...Or just use ble.sh https://github.com/akinomyoga/ble.sh:
# Enables ble.sh
# source ~/.local/share/blesh/ble.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment