Why does GitBash create a file named "1" when I use my alias? - alias

So I wanted to create an alias that opens a new GitBash terminal at the current location. I looked it up and found this command
/git-bash.exe & > /dev/null 2&>1
I added it to aliases.sh like so:
The command works just fine. It opens a new bash terminal at the current directory like I wanted, But it always creates a file called "1" with command not found:
I tried removing the 2&>1 part but that did nothing.

Fixed by using what Joachim Sauer said: "Move the & at the end of the alias"

Related

Mac: Replace "users/<computer-name>" in all terminals

I'm running into an issue with hiding my computer name. I want all terminal outputs on my mac (iTerm ->zsh & IntelliJ) to stop showing my computer name and show ~/. Can someone help me achieve this, I'm not sure what setting I'm looking to change.
ie.
From
users/ComputerName/app/src/main/java/com/virtualprodigy/android_compose_template
To
~/app/src/main/java/com/virtualprodigy/android_compose_template
Prompt format in zsh is controlled by PROMPT or PS1 variable. You can check if one of these variables is set up in ~/.zshrc (if there's no such file, create it by running touch ~/.zshrc).
If in your .zshrc you see a line setting either PROMPT or PS1, in its value substitute %/ (absolute path) with %~ (relative to home path).
If there's no such line in your .zshrc, you can just add this:
PROMPT='%~ %# '
Then save the file and restart your terminal.
You can change the prompt in your terminal to display ~ instead of the full path by modifying your shell's configuration file.
For zsh, you can add the following line to your ~/.zshrc file:
PROMPT='%~ %# '
For bash, you can add this line to your ~/.bash_profile or ~/.bashrc file:
PS1="\w \$ "
This will change the prompt to display only the current directory, represented by ~ for the home directory, and the command prompt symbol ($ for normal users, # for superusers).
You will need to either restart your terminal, or run the command source ~/.zshrc or source ~/.bashrc to apply the changes.

package.json not able to locate file

I have added a script in my script section of package.json which is present at root directory
"packagr": "ng-packagr -p src/ng-package.json"
But while running this script using
npm run pacakgr
gives error saying "no such file or directory" and tries to find my file at location
root/ng-package.json
instead of
root/src/ng-package.json
Does we need some configuration to map files?
It was a stupid mistake and it happened because I wrote the command in microsoft word.
When you type - in word and press space-bar it converts that character to something else.
Accidentally I used "–" character instead of "-"
Though python interpreter shows same ascii value for both the characters.

ConEmu + WSL: Open new console in current tab directory

I'm using WSL and ConEmu build 180506. I'm trying to setup a task in ConEmu to use the current directory of the active tab when opening a new console but I cannot get it to work.
What I did is to setup the task {Bash: bash} using the instructions on this page
setting the task command as :
set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -C~ -cur_console:pm:/mnt
Then following the instruction on this page, I added to my .bashrc
if [[ -n "${ConEmuPID}" ]]; then
PS1="$PS1\[\e]9;9;\"\w\"\007\e]9;12\007\]"
fi
and finally setup a shortcut using the macro :
Shell("new_console", "{bash}", "", "%CD%")
But it always open the new console in the default directory ('/home/[username]').
I don't understand what I'm not doing right.
I also noticed that a lot of environment variables listed here are not set. Basically, only $ConEmuPID and $ConEmuBuild seem to be set.
Any help would be appreciated.
GuiMacro Shell was intended to run certain commands, not tasks.
You think you may try to run macro Task("{bash}","%CD%")
Or set your {bash} task parameters to -dir %CD% and just set hotkey for your task.
Of course both methods require working CD acquisition from shell. Seems like it's OK in your case - %d shows proper folder.
I found the answer:
Shell("new_console:I", "bash.exe", "", "%CD%")
The readme is actually pretty good: https://github.com/cmderdev/cmder/blob/master/README.md

How to use current file as parameter to Run configuration in pycharm

I want to create custom run configurations, but i cannot figure out how to get the current file name as a parameter...
I would like to do something like this:
py.test -m mymarker %f
autopep8 %f
where %f is the current file name.
The answer by Ctrl+C already hints at $FileName$ and at least in the current version 2020.2 of PyCharm this works in Run Configurations.
Create a run configuration as you desire, e.g. Python
In Parameters field you can simply use macros like $FileName$ or $FilePath$. Or click on the + at the right end for a full list
Hit the Run button or Shift+F10 by default while your target file is opened
What you want to insert there is called a macro, which is a context-dependent variable: $FileName$ (current file in this case). Unfortunately this doesn't work yet in Run configurations.
Workaround - use External Tools
Settings > Tools > External Tools
[+]
set "Program" as path to your script/program ('py.test')
in "Arguments" use button [Insert Macro...] on the right. There will be a list of possibilities. For example you wanted $FileName$ for the current file.
If you want both of those commands in one External Tool command, then create a bash script:
#!/bin/bash -exu
py.test -m mymarker $#
autopep8 $#
Finally you can use it via [Tools]>[External Tools], [Right click on a file]>[External Tools] or you can add a shortcut to the command.
I solved similar problems with Ruby as shown in screenshot link below.
After that: right click on script-file, select in Pop-up menu External Tools -> [Your runner]

GNU screen source a custom bashrc file for new windows

At the office, we have a shared user we use half the time. I'm trying to get screen to automatically load a custom bashrc file that I created for myself when using the shared user. So far I have this which works well:
alias screen='screen -d -R -S redhar -c /home/redhar/.screenrc bash -rcfile '\''/home/goldenuser/.bashrc_redhar'\'''
This works well for the very first window it creates. The problem comes when I create a new window. Is there anyway to get a newly created window to automatically use the same rcfile?
So far I have considered the following option, but I'm looking for a more streamlined solution along the lines of a missing GNU screen config option I overlooked or something. My proposed solution:
In regular .bashrc which gets loaded automatically:
if [[ $SCREENFLAG == "REDHAR" ]]
then
. /home/goldenuser/.bashrc_redhar
exit
fi
Set alias to:
alias screen='SCREENFLAG=REDHAR screen -d -R -S redhar -c /home/redhar/.screenrc bash -rcfile '\''/home/goldenuser/.bashrc_redhar'\'''
Discovered the solution is to create a file with
bash -rcfile /home/goldenuser/.bashrc_redhar
then set your shell command in .screenrc to it
shell='<path to file created above>'