Home > Blockchain >  Is it possible to trace my shell(bash, fish, zsh)?
Is it possible to trace my shell(bash, fish, zsh)?

Time:03-02

I am running archlinux(arcolinux distro to be specific) everything is fine but one little tiny problem which annoys me the problem is every time i open a terminal this pops us at the top of the terminal

"Linux pengu 5.15.25-1-lts x86_64 unknown"

I know this is a uname command with custom flags however I don't have that in my config.fish(I use fish shell(I run fish with bash i), I am aware that every time I open a my fish shell the stuff in my config.fish run, is there anything I am missing or what? here is my config.fish:


{

fish_vi_key_bindings
set VIRTUAL_ENV_DISABLE_PROMPT "1"
set -x MANPAGER "sh -c 'col -bx | bat -l man -p'"
## Export variable need for qt-theme
if type "qtile" >> /dev/null 2>&1
   set -x QT_QPA_PLATFORMTHEME "qt5ct"
end

# Set settings for https://github.com/franciscolourenco/done
set -U __done_min_cmd_duration 10000
set -U __done_notification_urgency_level low


## Environment setup
# Apply .profile: use this to put fish compatible .profile stuff in
if test -f ~/.fish_profile
  source ~/.fish_profile
end

# Add ~/.local/bin to PATH
if test -d ~/.local/bin
    if not contains -- ~/.local/bin $PATH
        set -p PATH ~/.local/bin
    end
end

# Add depot_tools to PATH
if test -d ~/Applications/depot_tools
    if not contains -- ~/Applications/depot_tools $PATH
        set -p PATH ~/Applications/depot_tools
    end
end

set -p PATH ~/.scripts
set -p PATH /home/omar/eclipse/java-2021-12/eclipse
set -p PATH ~/bin



## Starship prompt
if status --is-interactive
   source ("/usr/bin/starship" init fish --print-full-init | psub)
end

## Advanced command-not-found hook
#source /usr/share/doc/find-the-command/ftc.fish

## Functions
# Functions needed for !! and !$ https://github.com/oh-my-fish/plugin-bang-bang
function __history_previous_command
  switch (commandline -t)
  case "!"
    commandline -t $history[1]; commandline -f repaint
  case "*"
    commandline -i !
  end
end

function __history_previous_command_arguments
  switch (commandline -t)
  case "!"
    commandline -t ""
    commandline -f history-token-search-backward
  case "*"
    commandline -i '$'
  end
end

if [ "$fish_key_bindings" = fish_vi_key_bindings ];
  bind -Minsert ! __history_previous_command
  bind -Minsert '$' __history_previous_command_arguments
else
  bind ! __history_previous_command
  bind '$' __history_previous_command_arguments
end

# Fish command history
function history
    builtin history --show-time='%F %T '
end

function backup --argument filename
    cp $filename $filename.bak
end

# Copy DIR1 DIR2
function copy
    set count (count $argv | tr -d \n)
    if test "$count" = 2; and test -d "$argv[1]"
    set from (echo $argv[1] | trim-right /)
    set to (echo $argv[2])
        command cp -r $from $to
    else
        command cp $argv
    end
end

## Useful aliases
#Aliases to setbrightness
alias setbright1='xrandr --output HDMI-0 --brightness 1.00' #Sets the brightness to 1.00
alias setbright75='xrandr --output HDMI-0 --brightness 0.75' #Sets the brightness to 0.75
alias setbright50='xrandr --output HDMI-0 --brightness 0.50' #Sets the brightness to 0.50
alias setbright40='xrandr --output HDMI-0 --brightness 0.40' #Sets the brightness to 0.40
alias setbright30='xrandr --output HDMI-0 --brightness 0.30' #Sets the brightness to 0.30

# Replace ls with exa
alias ls='exa -al --color=always --group-directories-first --icons' # preferred listing
alias la='exa -a --color=always --group-directories-first --icons'  # all files and dirs
alias ll='exa -l --color=always --group-directories-first --icons'  # long format
alias lt='exa -aT --color=always --group-directories-first --icons' # tree listing
alias l.="exa -a | egrep '^\.'"                                     # show only dotfiles

# Aliases for quickly accessing config files(fish, bash, alacritty,etc..)
alias cf='vim ~/.config/fish/config.fish' # for quickly accessing fish config file
alias cb='vim .bashrc' # for quickly accessing bash config file
alias ca='vim ~/.config/alacritty/alacritty.yml' # for quickly acssesing alacritty config file
alias ck='vim ~/.config/kitty/kitty.conf'
alias cw='vim ~/.config/awesome/rc.lua'

# Replace some more things with better alternatives
alias cat='bat --style header --style rules --style snip --style changes --style header'
[ ! -x /usr/bin/yay ] && [ -x /usr/bin/paru ] && alias yay='paru'

#Media player utilities
alias pause='playerctl -p spotify pause'
alias play='playerctl -p spotify play'
# Common use
alias book='/home/omar/.scripts/books.sh'
alias poweroff='systemctl poweroff'
alias reboot='systemctl reboot'
alias grubup="sudo update-grub"
alias fixpacman="sudo rm /var/lib/pacman/db.lck"
alias tarnow='tar -acf '
alias untar='tar -zxvf '
alias wget='wget -c '
alias rmpkg="sudo pacman -Rdd"
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
alias upd='/usr/bin/update'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias hw='hwinfo --short'                                   # Hardware Info
alias big="expac -H M '%m\t%n' | sort -h | nl"              # Sort installed packages according to size in MB
alias gitpkg='pacman -Q | grep -i "\-git" | wc -l'          # List amount of -git packages

# Get fastest mirrors
alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist"
alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist"
alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist"
alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist"

# Help people new to Arch
alias apt='man pacman'
alias apt-get='man pacman'
alias please='sudo'
alias tb='nc termbin.com 9999'

# Cleanup orphaned packages
alias cleanup='sudo pacman -Rns (pacman -Qtdq)'

# Get the error messages from journalctl
alias jctl="journalctl -p 3 -xb"

# Recent installed packages
alias rip="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl"

#Cool terminal stuff(pipes, convo, etc...)
alias pipes='cd pipes.sh;./pipes.sh';cd 

## Run paleofetch if session is interactive
#if status --is-interactive
    #colorscript random
#end

}

I tried to debug the problem by calling something like strace on my fish shell but it just restarts my fish shell, I also wrote a little script where i made a while loop and excuted this command: ps -ax | grep uname; sleep 0.1 which should give me any instanced of the uname command and kept running my fish shell over and over but there was no uname instances I am really puzzled with this

CodePudding user response:

strace can attach to a process using -p:

-p pid         trace process with process id PID, may be repeated

this way you would be able to attach to your running process.

You may also find useful

  -f             follow forks
  -ff            follow forks with output into separate files

if you attach to the parent process.

CodePudding user response:

You can ask fish to output the commands it runs by setting the fish_trace variable. Example:

fish_trace=1 fish

this is mentioned in the docs around debugging fish.

CodePudding user response:

I figured it out though without tracing the fish shell syscalls or something like that I realized that I am using oh-my-fish plugin or framework and it is loading a theme which displayed the unwanted message, thanks for the tips though I at least now know how to trace the fish shell

  • Related