#StackBounty: #linux #command-line #bash #terminal #xargs How to batch delete the redis keys from local mache and through a jump machin…

Bounty: 50

I need to delete some keys in my redis cluster which can only be accessed from a jump machine deployed in the kubernetes cluster.

So if I know the key I can delete it by the following command without problem:

➜ kubectl exec -it jump-machine -- /usr/local/bin/redis-cli -c -h redis-cluster-host DEL "the-key"
(interger) 1

But if I want to do it in batch then it gives output 0 which means not deleted:

➜ kubectl exec -it jump-machine -- /usr/local/bin/redis-cli -c -h redis-cluster-host --scan --pattern "*the-key-pattern*" | xargs -L 1 kubectl exec -it jump-machine -- /usr/local/bin/redis-cli -c -h redis-cluster-host -c DEL

Unable to use a TTY - input is not a terminal or the right kind of file
0
Unable to use a TTY - input is not a terminal or the right kind of file
0
Unable to use a TTY - input is not a terminal or the right kind of file
0
Unable to use a TTY - input is not a terminal or the right kind of file
0
Unable to use a TTY - input is not a terminal or the right kind of file
0
Unable to use a TTY - input is not a terminal or the right kind of file
0
Unable to use a TTY - input is not a terminal or the right kind of file
0

I’m quite new about using the xargs, and I can’t tell where is wrong.

I tried debug it with the following command, it gives all the keys without issue:

➜ kubectl exec -it jump-machine -- /usr/local/bin/redis-cli -c -h redis-cluster-host --scan --pattern "*the-key-pattern*" | xargs -L 1 echo

the-key-pattern-1
the-key-pattern-2
the-key-pattern-3
...

Hope someone can shed some light on it, thanks in advance!


Get this bounty!!!

#StackBounty: #terminal #bsd #locate #darwin "locate" returns relative instead of absolute paths

Bounty: 100

One advised me to post here since this would be more appropriate (I am going to remove the previous one).

On my MacBook, I have the following entry in root’s crontab:

0 */4 * * * cd /private/var/root && ./locate.updatedb

I have an alias for locate in ~/.zshrc:

alias locate='locate -d /var/db/locate.database'   

When I do a "locate Table_Synthesis_GREY_" , in all the full paths of files found, the first slash of the path indicating the file system root is missing. Here is a sample of the ouput:

Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_05_AOUT_2020/temp/Table_Synthesis_GREY_IMPORTANT_SAVE_5_AOUT_2020.run.xml
Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_05_AOUT_2020/temp/Table_Synthesis_GREY_IMPORTANT_SAVE_5_AOUT_2020.tex
Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_05_AOUT_2020/temp/Table_Synthesis_GREY_IMPORTANT_SAVE_5_AOUT_2020.zip
Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_05_AOUT_2020/temp/Table_Synthesis_GREY_IMPORTANT_SAVE_5_AOUT_2020_ORIGINAL_INTO_zip_here.pdf
Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_AFTER_05_AOUT_2020/FLAT_Synthesis/Table_Synthesis_GREY_FLAT.docx

How can I have paths output as absolute paths, i.e. starting at /Users? The desired output is

/Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_AFTER_05_AOUT_2020/FLAT_Synthesis/Table_Synthesis_GREY_FLAT.docx

as opposed to

Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_AFTER_05_AOUT_2020/FLAT_Synthesis/Table_Synthesis_GREY_FLAT.docx

UPDATE 1: I have copied /usr/libexec/locate.updatedb into my home root, that is in /var/root/ . I did that since I could not modify the /usr/libexec/locate.updatedb file, even being root or with sudo.

So in this other file /var/root/locate.updatedb, I could do the modification :

if [ "$(id -u)" = "99" ]; then

instead of initially :

if [ "$(id -u)" = "0" ]; then

What do you think about this trick ? and mostly why I have not the first slash displayed when results into my /Users/henry/.

0 */4 * * * cd /private/var/root ; /bin/sh locate.updatedb

but issue remains.

By the way, if results are located into /Applications or other main directories but not systematically, the first slash is well displayed.

The content of script is not very big, here is :

# $FreeBSD: src/usr.bin/locate/locate/updatedb.sh,v 1.20 2005/11/12 12:45:08 grog Exp $

if [ "$(id -u)" = "99" ]; then
    rc=0
    export FCODES=`sudo -u nobody mktemp -t updatedb`
    chown nobody $FCODES
    tmpdb=`su -fm nobody -c "$0"` || rc=1
    if [ $rc = 0 ]; then
        install -m 0444 -o nobody -g wheel $FCODES /var/db/locate.database
    fi
    rm $FCODES
    exit $rc
fi
: ${LOCATE_CONFIG="/etc/locate.rc"}
if [ -f "$LOCATE_CONFIG" -a -r "$LOCATE_CONFIG" ]; then
       . $LOCATE_CONFIG
fi

# The directory containing locate subprograms
: ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR
: ${TMPDIR:=/tmp}; export TMPDIR
if ! TMPDIR=`mktemp -d $TMPDIR/locateXXXXXXXXXX`; then
    exit 1
fi

PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH

# 6497475
set -o noglob

: ${mklocatedb:=locate.mklocatedb}      # make locate database program
: ${FCODES:=/var/db/locate.database}    # the database
: ${SEARCHPATHS:="/"}                   # directories to be put in the database
: ${PRUNEPATHS:="/private/tmp /private/var/folders /private/var/tmp */Backups.backupdb"} # unwanted directories
: ${FILESYSTEMS:="hfs ufs apfs"}        # allowed filesystems
: ${find:=find}

case X"$SEARCHPATHS" in 
    X) echo "$0: empty variable SEARCHPATHS"; exit 1;; esac
case X"$FILESYSTEMS" in 
    X) echo "$0: empty variable FILESYSTEMS"; exit 1;; esac

# Make a list a paths to exclude in the locate run
excludes="! (" or=""
for fstype in $FILESYSTEMS
do
    excludes="$excludes $or -fstype $fstype"
    or="-or"
done
excludes="$excludes ) -prune"

case X"$PRUNEPATHS" in
    X) ;;
    *) for path in $PRUNEPATHS
    do
        excludes="$excludes -or -path $path -prune"
    done;;
esac

# Ignore the target of firmlinks
while read firmlink; do
    excludes="$excludes -or -path $firmlink -prune"
done <<< "$(awk -F't' '{print "/System/Volumes/Data/" $2}' /usr/share/firmlinks)"

tmp=$TMPDIR/_updatedb$$
trap 'rm -f $tmp; rmdir $TMPDIR; exit' 0 1 2 3 5 10 15

# search locally
# echo $find $SEARCHPATHS $excludes -or -print && exit
if $find -s $SEARCHPATHS $excludes -or -print 2>/dev/null |
        $mklocatedb -presort > $tmp
then
    case X"`$find $tmp -size -257c -print`" in
        X) cat $tmp > $FCODES;;
        *) echo "updatedb: locate database $tmp is empty"
           exit 1
    esac
fi

Anyone has a clue ?


Get this bounty!!!

#StackBounty: #terminal #zsh #path #search #locate "locate" returns relative instead of absolute paths

Bounty: 100

One advised me to post here since this would be more appropriate (I am going to remove the previous one).

On my MacBook, I have the following entry in root’s crontab:

0 */4 * * * cd /private/var/root && ./locate.updatedb

I have an alias for locate in ~/.zshrc:

alias locate='locate -d /var/db/locate.database'   

When I do a "locate Table_Synthesis_GREY_" , in all the full paths of files found, the first slash of the path indicating the file system root is missing. Here is a sample of the ouput:

Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_05_AOUT_2020/temp/Table_Synthesis_GREY_IMPORTANT_SAVE_5_AOUT_2020.run.xml
Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_05_AOUT_2020/temp/Table_Synthesis_GREY_IMPORTANT_SAVE_5_AOUT_2020.tex
Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_05_AOUT_2020/temp/Table_Synthesis_GREY_IMPORTANT_SAVE_5_AOUT_2020.zip
Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_05_AOUT_2020/temp/Table_Synthesis_GREY_IMPORTANT_SAVE_5_AOUT_2020_ORIGINAL_INTO_zip_here.pdf
Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_AFTER_05_AOUT_2020/FLAT_Synthesis/Table_Synthesis_GREY_FLAT.docx

How can I have paths output as absolute paths, i.e. starting at /Users? The desired output is

/Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_AFTER_05_AOUT_2020/FLAT_Synthesis/Table_Synthesis_GREY_FLAT.docx

as opposed to

Users/henry/Projects/JUNK_AND_OLD/Travail_9_Paper_Combinaison_et_Methode_des_biais_communs_pour_ma_These_SAUVEGARDES/TABLES_FLAT_AND_NON_FLAT_to_include_into_my_Phd_paper_LAST/Table_Synthesis_Main_AFTER_05_AOUT_2020/FLAT_Synthesis/Table_Synthesis_GREY_FLAT.docx

UPDATE 1: I have copied /usr/libexec/locate.updatedb into my home root, that is in /var/root/ . I did that since I could not modify the /usr/libexec/locate.updatedb file, even being root or with sudo.

So in this other file /var/root/locate.updatedb, I could do the modification :

if [ "$(id -u)" = "99" ]; then

instead of initially :

if [ "$(id -u)" = "0" ]; then

What do you think about this trick ? and mostly why I have not the first slash displayed when results into my /Users/henry/.

0 */4 * * * cd /private/var/root ; /bin/sh locate.updatedb

but issue remains.

By the way, if results are located into /Applications or other main directories but not systematically, the first slash is well displayed.

The content of script is not very big, here is :

# $FreeBSD: src/usr.bin/locate/locate/updatedb.sh,v 1.20 2005/11/12 12:45:08 grog Exp $

if [ "$(id -u)" = "99" ]; then
    rc=0
    export FCODES=`sudo -u nobody mktemp -t updatedb`
    chown nobody $FCODES
    tmpdb=`su -fm nobody -c "$0"` || rc=1
    if [ $rc = 0 ]; then
        install -m 0444 -o nobody -g wheel $FCODES /var/db/locate.database
    fi
    rm $FCODES
    exit $rc
fi
: ${LOCATE_CONFIG="/etc/locate.rc"}
if [ -f "$LOCATE_CONFIG" -a -r "$LOCATE_CONFIG" ]; then
       . $LOCATE_CONFIG
fi

# The directory containing locate subprograms
: ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR
: ${TMPDIR:=/tmp}; export TMPDIR
if ! TMPDIR=`mktemp -d $TMPDIR/locateXXXXXXXXXX`; then
    exit 1
fi

PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH

# 6497475
set -o noglob

: ${mklocatedb:=locate.mklocatedb}      # make locate database program
: ${FCODES:=/var/db/locate.database}    # the database
: ${SEARCHPATHS:="/"}                   # directories to be put in the database
: ${PRUNEPATHS:="/private/tmp /private/var/folders /private/var/tmp */Backups.backupdb"} # unwanted directories
: ${FILESYSTEMS:="hfs ufs apfs"}        # allowed filesystems
: ${find:=find}

case X"$SEARCHPATHS" in 
    X) echo "$0: empty variable SEARCHPATHS"; exit 1;; esac
case X"$FILESYSTEMS" in 
    X) echo "$0: empty variable FILESYSTEMS"; exit 1;; esac

# Make a list a paths to exclude in the locate run
excludes="! (" or=""
for fstype in $FILESYSTEMS
do
    excludes="$excludes $or -fstype $fstype"
    or="-or"
done
excludes="$excludes ) -prune"

case X"$PRUNEPATHS" in
    X) ;;
    *) for path in $PRUNEPATHS
    do
        excludes="$excludes -or -path $path -prune"
    done;;
esac

# Ignore the target of firmlinks
while read firmlink; do
    excludes="$excludes -or -path $firmlink -prune"
done <<< "$(awk -F't' '{print "/System/Volumes/Data/" $2}' /usr/share/firmlinks)"

tmp=$TMPDIR/_updatedb$$
trap 'rm -f $tmp; rmdir $TMPDIR; exit' 0 1 2 3 5 10 15

# search locally
# echo $find $SEARCHPATHS $excludes -or -print && exit
if $find -s $SEARCHPATHS $excludes -or -print 2>/dev/null |
        $mklocatedb -presort > $tmp
then
    case X"`$find $tmp -size -257c -print`" in
        X) cat $tmp > $FCODES;;
        *) echo "updatedb: locate database $tmp is empty"
           exit 1
    esac
fi

Anyone has a clue ?


Get this bounty!!!

#StackBounty: #windows #command-line #terminal #taskbar #desktop Stick a terminal window to the on the desktop

Bounty: 50

For some reason I need to get rid of the default desktop and instead I need a terminal to be in the place of the desktop. As an example if I’m using Windows my desktop looks as shown in below.

enter image description here

But, I don’t need to see the desktops icons & wallpaper, and what I need to see is the desktop as the screenshot shown in below. (Note: Here I have used Windows Terminal).

enter image description here

So, then when I right-click my taskbar and select Show the desktop or press Win + D shortcut, it should come to this Terminal Desktop instead of that ordinary desktop! Note that I still need to see the taskbar (I don’t need a complete DOS feeling :D).

How can I archive this?

I was thinking that,

May be stacking the items as this, will be a solution.

enter image description here

(Note that, this stacking should be persistent.)

How can I achieve this?


Get this bounty!!!

#StackBounty: #terminal #shell-script #elementaryos Elementary OS: How to create a clickable shellscript

Bounty: 50

I am trying to make a shellscript clickable in a folder?

What I want is for the user to be able to click/double-click a shellscript in Files via the GUI and then have this shellscript open and run inside a graphical terminal.

I have tried making it executable (chmod +x myscript), but when I click it it just opens a terminal and not running the script.

I think I somehow associated shellscripts with Terminal app in an attempt to get this to work. I probably need to remove this association somehow but cannot find any way of doing this in the UI.

When I right-click my script, it has a "Run" option but when I click this, nothing happens.

Update:
I found out that right click -> run actual does run the script although in a wrong path and with NO visual feedback what so ever. How do I make it run in a terminal?


Get this bounty!!!

#StackBounty: #mac #terminal #visual-studio-code How to get branch names to appear in the VS Code integrated terminal?

Bounty: 50

I recently installed a new instance of VS Code on my Mac and the integrated terminal no longer shows the current branch.

In the old world, it would show which branch I was on right now with git and update as I changed branches.

Now, it shows my location in the file directory and git works as normal but it doesn’t show the branch.

I have no extensions except for GitHistory. This is an excerpt from my settings file:

{
    "workbench.statusBar.visible": false,
    "explorer.decorations.colors": false,
    "window.zoomLevel": 0,
    "workbench.startupEditor": "newUntitledFile",
    "workbench.editor.closeOnFileDelete": true,
    "workbench.editor.limit.enabled": true,
    "workbench.editor.openPositioning": "first",
    "python.linting.pylintEnabled": true,
    "python.linting.enabled": true,
    "terminal.integrated.scrollback": 50000,
    "terminal.integrated.shell.osx": ""
}


Get this bounty!!!

#StackBounty: #bash #terminal #keyboard-shortcuts Why does exiting Python REPL clear my Ctrl-V Bash mapping?

Bounty: 50

I have mapped Ctrl-V in my .bash_profile to a function that opens a file in Vim using fzf. It works perfectly, but whenever I exit from the Python REPL the mapping doesn’t work until I source my .bash_profile twice or start a completely new shell session.

Steps to reproduce:

  1. Use this minimal .bash_profile that replicates the problem:
stty lnext ^-
bind -x '"C-v": "echo mapping works"'
  1. Start a Bash session.

  2. Press Ctrl-V -> see the output mapping works.

  3. Run $ python3.

  4. Use exit() or Ctrl-D to exit the REPL.

  5. Ctrl-V is back to it’s default behavior.

  6. $ source ~/.bash_profile the mapping still doesn’t work?

  7. $ source ~/.bash_profile now Ctrl-V correctly produces mapping works, how?

Why does starting/exiting the Python REPL affect my Ctrl-V mapping (this does not happen to my other mappings)? And why do I need to source my profile twice for the mapping to start working?


Get this bounty!!!

#StackBounty: #terminal #keyboard-shortcuts #xfce #xfce4-terminal how to not move tabs by xfce terminal?

Bounty: 50

I am using xfce terminal on one side of screen, and many tabs. But when I want to use EOF interupt (aka <ctrl>-D), then the tab will remove its position from that side of screen to the other (see image below), I have even try to set -o ignoreeof but to no avail.

Before <ctrl>-D:
enter image description here

after <ctrl>-D:
enter image description here

As you can see, the first tab Terminal will get off the right side of screen to the other, only because of <ctrl>-D. Is there a way to fix this bug? (that is -> the tab where is EOF interupt triggered (Terminal in my case), will stay at its position (will be fixed), without moving randomly on the screen)? This is really annoying.

I cannot find any shortcut for <ctrl>-D in ~/.config/xfce4/terminal/accels.scm, so I assume the xfce4-terminal does not interpret it? (And let it be handle as interrupt?), but not sure where the problem is.


Get this bounty!!!

#StackBounty: #terminal #pdf #preview #ranger How to make ranger's image/pdf preview persist in terminal?

Bounty: 100

Just got image/pdf preview working in ranger, but I’ve noticed that when moving my mouse away from the ranger terminal window, the preview disappears. More annoying than this is that you can’t run commands with the preview still displayed.

For instance I would like to preview the file, and then :rename it. As soon as any key is pressed (Shift in this case) the preview vanishes and I have to navigate to another file and then back to the file I want to preview.

I’m using the st terminal emulator and the default set preview_image_method w3m.

What’s going on here? Any way to fix this?

EDIT: Would also be happy to learn about any alternatives to ranger that can achieve the above.


Get this bounty!!!

#StackBounty: #terminal #pdf #preview #ranger How to make ranger's image/pdf preview persist in terminal?

Bounty: 100

Just got image/pdf preview working in ranger, but I’ve noticed that when moving my mouse away from the ranger terminal window, the preview disappears. More annoying than this is that you can’t run commands with the preview still displayed.

For instance I would like to preview the file, and then :rename it. As soon as any key is pressed (Shift in this case) the preview vanishes and I have to navigate to another file and then back to the file I want to preview.

I’m using the st terminal emulator and the default set preview_image_method w3m.

What’s going on here? Any way to fix this?

EDIT: Would also be happy to learn about any alternatives to ranger that can achieve the above.


Get this bounty!!!