From 2ecb4c53faf27bb8100f1976e0bf259b0a3d91f9 Mon Sep 17 00:00:00 2001 From: Xavier Logerais Date: Sat, 21 May 2022 02:41:24 +0200 Subject: [PATCH] feat: improve config for powerline, mcfly and (n)vim --- aliases.d/nvim | 7 ++++++ aliases.d/vim | 2 +- rc.d/mcfly | 9 ++++++++ rc.d/mcfly.bash | 60 ------------------------------------------------- rc.d/prompt | 5 +++-- 5 files changed, 20 insertions(+), 63 deletions(-) create mode 100644 aliases.d/nvim create mode 100644 rc.d/mcfly delete mode 100644 rc.d/mcfly.bash diff --git a/aliases.d/nvim b/aliases.d/nvim new file mode 100644 index 0000000..1696caf --- /dev/null +++ b/aliases.d/nvim @@ -0,0 +1,7 @@ +#!/bin/bash + +# Vim Editor +if [ -x ~/AppImages/nvim.appimage ] +then + alias nvim='~/AppImages/nvim.appimage' +fi diff --git a/aliases.d/vim b/aliases.d/vim index 4a1809f..1953cf9 100644 --- a/aliases.d/vim +++ b/aliases.d/vim @@ -5,5 +5,5 @@ if [ -x /usr/bin/vim ] then alias vi='vim -p' alias view='vim -R' - alias vless='vim -u /usr/share/vim/vim74/macros/less.vim -c "colorscheme mustangpp"' + alias vless='vim -u /usr/share/vim/vim*/macros/less.vim' fi diff --git a/rc.d/mcfly b/rc.d/mcfly new file mode 100644 index 0000000..a31dd12 --- /dev/null +++ b/rc.d/mcfly @@ -0,0 +1,9 @@ +#!/bin/bash + +if (which mcfly &> /dev/null) +then + export MCFLY_INTERFACE_VIEW=BOTTOM + export MCFLY_RESULTS=25 + export MCFLY_RESULTS_SORT=LAST_RUN + eval "$(mcfly init bash)" +fi diff --git a/rc.d/mcfly.bash b/rc.d/mcfly.bash deleted file mode 100644 index 2dbd9f4..0000000 --- a/rc.d/mcfly.bash +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -if ( ! which mcfly &> /dev/null ); then return; fi - -# Avoid loading this file more than once -if [[ "$__MCFLY_LOADED" == "loaded" ]]; then - return 0 -fi - -__MCFLY_LOADED="loaded" -export MCFLY_SESSION_ID=$(cat /dev/urandom | env LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1) -export MCFLY_HISTORY=$(mktemp -t mcfly.XXXX) -export HISTFILE="${HISTFILE:-$HOME/.bash_history}" - -if [[ -f "$HISTFILE" ]]; -then - tail -n100 "${HISTFILE}" >| ${MCFLY_HISTORY} -else - printf "Welcome to McFly\n" >| ${MCFLY_HISTORY} -fi - -# Ignore commands with a leading space -#export HISTCONTROL="ignorespace" - -# Append new history items to .bash_history -shopt -s histappend - -# Setup a function to be used by $PROMPT_COMMAND. -function mcfly_prompt_command { - local exit_code=$? # Record exit status of previous command. - history -a ${MCFLY_HISTORY} # Append history to $MCFLY_HISTORY. - # Run mcfly with the saved code. It will: - # * append commands to $HISTFILE, (~/.bash_history by default) - # for backwards compatibility and to load in new terminal sessions; - # * find the text of the last command in $MCFLY_HISTORY and save it to the database. - mcfly add --exit ${exit_code} --append-to-histfile - # Clear the in-memory history and reload it from $MCFLY_HISTORY - # (to remove instances of '#mcfly: ' from the local session history). - history -cr ${MCFLY_HISTORY} - return ${exit_code} # Restore the original exit code by returning it. -} - -# Set $PROMPT_COMMAND run mcfly_prompt_command and then any existing $PROMPT_COMMAND. -PROMPT_COMMAND="mcfly_prompt_command;$PROMPT_COMMAND" - -# If this is an interactive shell, take ownership of ctrl-r. -# The logic here is: -# 1. Jump to the beginning of the edit buffer, add 'mcfly: ', and comment out the current line. We comment out the line -# to ensure that all possible special characters, including backticks, are ignored. This commented out line will -# end up as the most recent entry in the $MCFLY_HISTORY file. -# 2. Type "mcfly search" and then run the command. McFly will pull the last line from the $MCFLY_HISTORY file, -# which should be the commented-out search from step #1. It will then remove that line from the history file and -# render the search UI pre-filled with it. -if [[ $- =~ .*i.* ]]; then - if set -o | grep "vi " | grep -q on; then - bind "'\C-r': '\e0i#mcfly: \e\C-j mcfly search\C-j'" - else - bind "'\C-r': '\C-amcfly: \e# mcfly search\C-j'" - fi -fi diff --git a/rc.d/prompt b/rc.d/prompt index d1e2457..c2e6ac6 100644 --- a/rc.d/prompt +++ b/rc.d/prompt @@ -2,10 +2,11 @@ # Customize the prompt -if (which powerline &> /dev/null); then +POWERLINE=$(which powerline || which powerline-go) &> /dev/null +if [ -x "$POWERLINE" ]; then function _update_ps1() { - PS1="$(powerline -error $? -jobs $(jobs -p | wc -l))" + PS1="$($POWERLINE -error $? -jobs $(jobs -p | wc -l))" # Uncomment the following line to automatically clear errors after showing # them once. This not only clears the error for powerline-go, but also for